Skip to content

Instantly share code, notes, and snippets.

@smosher
smosher / normals.pl6
Created September 20, 2011 12:15
basic normal calculation
sub vector-to-unit( @vec ) { @vec >>/>> sqrt( [+] @vec >>**>> 2 ) }
sub cross-product( @v1, @v2 ) {
( @v1[1,2,0] >>*<< @v2[2,0,1] )
>>-<<
( @v1[2,0,1] >>*<< @v2[1,2,0] )
}
sub surface-to-normal( @a, @b, @c ) {
my @b2 = @b >>-<< @a;
my @c2 = @c >>-<< @a;
my @normal = cross-product( @b2, @c2 );
@smosher
smosher / phasedist.io
Created July 30, 2014 19:48
Phase Distortion Synthesis
// https://en.wikipedia.org/wiki/Phase_distortion_synthesis
// NB. completely untested
Range
pi := 3.14159265
tau := 2 * pi
FreqCtr := Object clone do(