Thursday, October 20, 2016

more familiar spirals in Desmos: spirolaterals

After the last post about how to draw some types of spirals using Desmos, I was pointed to a treasure trove of spiral and Desmos goodness in the twitter microblogging of @Veganmathbeagle and @GHSMaths. I haven't yet had the chance to dig too deeply yet, but looking forward to it.

Also, @Desmos kindly improved upon one set of spirals: the "polygonal numbers on quadratic spiral" family, showing how to connect the dots and link up the points of the spiral (the improved graph is here). The technique: use the functions for x and y to create a family of parametrically defined line segments. To create a line segment between two points A and B, you can introduce a parameter t which moves you from A to B as t varies from 0 to 1, applying this idea to pairs of points on the graph allows you to connect up the discrete points.
parametric formula for line segment AB

Armed with this, I'm adding one more group of spirals to the list: spirolaterals.


Spirolaterals are easily drawn by hand by following this simple rule: draw line segments starting at 1 unit long and going up to n units long, turning 90 degrees between each segment, and then repeating the process from 1 again.

The first spirolateral traces out a square: move 1 space, turn 90 degrees, move 1 space, turn 90 degrees, move 1 space, turn 90 degrees,... you get the idea. The second spirolatoral yields a rectangle: move 1 space, turn 90 degrees, move 2 spaces, turn 90 degrees, move 1 space, turn 90 degrees, move 2 spaces, turn 90 degrees.... Maybe not so fascinating, but the third spiral gives an interesting shape of 4 rotated rectangles, and the fifth spirals off the page like an uncoiling spring.

I learned about spirolaterals from The Puzzle Universe (review here). The definition did not, to me at least, look like something easily expressed using equations. At the time I wrote a little Processing program to draw them:

some spirolaterals for small m values

If you are of a certain age, these might remind you of something you might draw in LOGO (Turtle graphics). But can you do it in Desmos? Yes you can. Here is one way to express the nth step of the mth spirolateral:

spirolateral 19 in Desmos graph here

Is this an efficient way of drawing spirolaterals? Maybe not: at each step you are effectively re-tracing the whole length of the spiral (the sum does this). But what I think is cool is that it can be done at all. In this case, something that you might think requires programming constructs (a loop, some temporary variables), can be compressed into simple equations. Here the key device is the modulo function (actually modulo plus 1), which ensures that you keep repeating the sequence 1 to m as you step around the spiral.

Other angles

I know what you want to do: you want to change the rules. Ok, one thing to try is to not to turn at a 90 degree angle, but some other angle: each choice of an angle gives a new family of spirolaterals.

spirolaterals based on 60 degree turns (graph here)

spirolaterals based on a 144 degree angle (graph here)

A general graph that has sliders to allow you to play with the angles is here.

Spirolaterals are a lot like the Euler spirals mentioned in the previous post. In a way, they are almost dual to those - Euler spirals keep the same magnitude for each step but keep increasing the angle that they turn by at each step, while spirolaterals keep the same angle but keep increasing the magnitude of each step (up to a limit, after which they repeat). Here is an improved version of the Euler spiral graph, this time with connecting lines.

Euler spiral (graph here)