Swirls and spirals appear in nature in all kinds of places. In the seeds of a sunflower, in the vortex of a hurricane, in the horns of a goat, in the shell of a snail, in the curling fronds of a fern, in this guy's beard.
In this totally naturally occurring jetty:
Spirals in Logo: 2 different ways
One of the classic shapes to construct in turtle logo is the Spiral.
The first way you write this program, is as a variation on a polygon. You go forward, you turn a bit, you go forward, you turn a bit. But you make it recursive, so that the amount you go forward can become smaller and smaller each time. Technically, this is called a 'spirangle'
to spiral :sides :length :ratio :angle if (:sides > 0) [ fd :length rt :angle spiral :sides-1 :length * :ratio :ratio :angle ] end setxy 50 100 spiral 60 40 0.95 30 setxy 200 80 spiral 120 15 0.995 15 setxy 350 100 spiral 200 7 0.995 6 setxy 100 200 spiral 200 2 1.005 7
If you look at that last example, we turned it around completely.
Instead of making a smaller and smaller line each time, we made a bigger and bigger line. (A ratio of 1.005) This created a spiral in the opposite direction! (Opposing chirality)
Spirals are Chiral!
It's worth nothing that spirals are chiral. And if you're ever stuck trying to remember that word for things have handed-ness... just remember the rhyming phrase: "Spirals are Chiral" and you'll be all set.
What is this "chiral" business you ask? There's a page for that.
Essentially every spiral can be either left-handed on right-handed. It can get smaller as it turns clockwise, or counter-clockwise.
Using Arc to draw a spiral
There is also an 'arc' function in Turtle graphics, that lets you draw smoother curves.
to spiral :length :ratio :angle :i if :i > 0 [ penwidth (:i/3 + 1) arc :length :angle pu fd (:length - :length/:ratio) pd lt :angle spiral :length/:ratio :ratio :angle (:i - 1) ] end spiral 120 1.05 60 30
Spiral with addition instead of multiplication
In this one the growth rate is linear, not compounding.
to spiral :sides :length :n :angle REPEAT :sides [ make "length :length + :n fd :length rt :angle ] end setxy 350 200 spiral 1400 1 0.01 8
- Wikipedia: Spirangle
- Wikipedia: Parastichy
- Wikipedia: Chirality
- Tumblr: James Myrick
- Whitney Music Box
- Wikipedia: Smithson's Spiral Jerry