April 22, 2011

It turns out a spiral isn't too bad to implement.

The key trick with a spiral is to combine the distance from the center with the rotation around the center (obtained with atan2). Once this is obtained, taking the sine can be used to oscillate along a path that grows outward in a spiral.


: square dup * ;
: dist square swap square + sqrt ;
: 2dup over over ;
: spiral 0.5 - swap 0.5 - 2dup dist push atan2 0.01 * pop + 100 * sin ;
x y spiral x y spiral x y spiral

Forth Haiku
blog comments powered by Disqus