Envelopes II: Making Spirals

While I don’t intend to make a habit of midweek posts (though thanks for the idea, Dane!), last week’s entry was so popular that I thought I’d write a short post on how the spiral designs are created.  Here’s one of last week’s images to refresh your memory.

Day020spiral3

These are not difficult to create,  but because of all the overlap of lines, it’s not immediately obvious how they are generated.  The image below shows the first forty line segments drawn, and highlights the endpoints of these segments.

Day021spiralmethod

The first line drawn is horizontal, and the endpoints are 180 degrees apart.   More lines are generated by having the orange endpoint (starting at the right) move 4 degrees counterclockwise, while the green endpoints (starting at the left) move just 3 degrees.  As a result, the endpoints of the second segment are just 179 degrees apart on the circle.  The orange endpoints start gaining on the green endpoints, closing the gap by 1 degree with each successive segment.

So the final spiral includes exactly 180 segments, which may be expressed in a form which may be easily generalized (and which is used in the Python code).  Note that the “180” on the left side of the equation represents the number of segments drawn, and the “180” on the right indicates the angular distance that the endpoints of the initial segment are separated on the circle.

180 = \dfrac{180}{4-3}.

All 180 segments are shown below, where the endpoints are retained to illustrate the process (although note that many endpoints are written over as the algorithm progresses).

Day021spiralmethod2

The Python code is fairly short (here is the Sage link — look at some of the earlier posts about using Sage if you haven’t used it before). The only mathematics you need to understand is the standard conversion from polar to rectangular coordinates — it’s much easier to describe the endpoints first in polar coordinates since the radius of the circle is fixed and only the angles the endpoints make with the center of the circle change.

Finally, I include an image created with contrasting colors on the background as well.  Create your own version, and post as a comment!

Day021spiral3