## Sunday, February 24, 2019

### Spirograph designs

Spirograph produces a set of geometrical art work by rotating one gear relative to another fixed gear. Beauty of this art lies in its ability to retain perfect symmetry across all angles. The vibrant colors and curvy edges that are sometimes adjacent and sometimes crossing each other in a particular order around a hidden center makes for a soothing and a riveting gaze.

This blog is an attempt to break down the math behind the beautiful curves created by spirographs. To motivate, I would like to show you a video of an online spirograph that I created at https://www.mathscroll.com/mathchallenge/spirograph.

The application takes 4 inputs - radius of the outer circle (R) within which the inner circle with radius (r) revolves around with a pen held at distance (d) from its center. The fourth input (N) is the number of revolutions the inner circle does on the outer circle. Apart from these inputs, we will need one more variable, 𝜱, an infinitesimally small angle by which the inner circle rotates. To build the formula, we would need a very basic knowledge of coordinate geometry and trigonometry.

Lets start with some simplifying assumptions while making it work for a specific simple situation. Once we establish a basic formula, we can generalize it for a more complicated case. We will start with building a formula for the path of a moving pen at the edge of a freely rotating circle (i.e. = r) on a flat base.

Situation: Assume a circle with a pen held at the bottom of the white circle (point A) starts rotating clockwise  (to point B) turned by an angle 𝜱 without slippage. Rotation will force the circle to move right to take red circle's position. In the below figure, pen's movement can be broken down into two simpler motions - clockwise rotation of point A to point B, and as the circle moves to the right, point B translates to point B'.

If we assume point A initially was at (x,y = 0,0). For a small clockwise rotation 𝜱, point A will rotate to point B. Using basic trigonometry, we can get the coordinates for point B (x,y = - r*sin𝜱, r - r*cos𝜱). As the circle rotates freely, it moves forward, and hence point B will move to point B'. To figure out the coordinates of point B'. We could use vectorial addition of vectors AB and BB'.

i.e. vector AB' = vector AB + vector BB'

Vector BB' is the distance traveled by the circle to the right, the arc length = r*𝜱.

If we assume vector notations then,

vector AB' = (- r*sin𝜱)i   +  (r - r*cos𝜱)j
and vector BB' = (r*𝜱)i
=> vector AB' = (r*𝜱 - r*sin𝜱)i + (r - r*cos𝜱)j

Thus point B' coordinates is at (x,y = r*𝜱 - r*sin𝜱, r - r*cos𝜱).

If we allow 𝜱 to take on values from 0 to 360 degrees, we will get the below curve traced in red. Not a very interesting design, but it forms the basis for more interesting designs later on. The red curve generated is called a cycloid

Let's now relax the assumption d = r, i.e. the pen could be anywhere on the line between the center and point A in the above figure. The change expected in the formula is to replace r by d except for in the term representing the distance traveled by the rotating circle, the arc length measure (r*𝜱). As the circle radius (r) did not change, the horizontal distance traveled by the circle will remain as is. Graphically, the new curve traced is very similar to the red one above, just thinner (at d < r), as shown below. These curves are called trochoids, and one of the special cases is cycloid at d = r.

Let's move this circle inside another bigger circle with radius (R). As the smaller circle freely rotates  anticlockwise inside the bigger circle, it moves clockwise relative to the bigger circle shown below.

Let us assume the center of the bigger circle, point O, to be at origin (x,y=0,0). Relative to the origin, the initial coordinates of the center of the smaller circle, point O'  is (x,y=R-r,0). This is also called vector OO'. In a small amount of time when smaller circle moved by an angle 𝛳 relative to bigger circle, corresponding point O' in the new location can be given by (x,y = (R-r)*cos𝛳,-(R-r)*sin𝛳).  This is the new vector OO'. Let us assume pen is at the edge of a smaller circle @ point A (i.e. d = r). It would trace the red arc shown above in the drawing. One way to calculate coordinates of the new point A is linear addition of point O' relative to point O and new point A relative to point O',

i.e. vector OA = vector OO' + vector O'A

Using the above, we could get point A as

X coordinate = (R-r)*cos𝛳 + d*cos𝚽                  ------(1)
Y coordinate = -(R-r)*sin𝛳+d*sin𝚽                    ------(2)

However, one can imagine that there is a one-to-one relationship between 𝛳 and 𝚽, assuming new slippage. If the smaller circle were to only translate, point A translates to point C. From point C to point A, arc length r*(𝛳+𝚽), is precisely the distance rotated by the smaller circle. However, from larger circle's point of view, the distance traveled by the smaller circle is R*𝛳.

i.e. R*𝛳 = r*(𝛳+𝚽)
=> (R-r)*𝛳 = r*𝚽
=> 𝚽 = [(R-r)/r]*𝛳

on replacing 𝚽 above in equation (1) and (2),

X coordinate = (R-r)*cos𝛳 + d*cos[(R-r)/r]*𝛳                 ------(1)
Y coordinate = -(R-r)*sin𝛳+d*sin[(R-r)/r]*𝛳                   ------(2)

If we allow 𝛳 to take on values from 0 to 360 degrees for a bigger circle of R = 200 units, and smaller circle r = 25 units, we will get the below curve traced in red. Please note that R/r = 8, exactly as the same number of cycloids below.

Hope this gives you a good understanding of the math behind spirograph designs!

Mathscroll Team
www.mathscroll.com

Mathscroll is a math calculator - pre algebra, algebra, pre calculus, and calculus solver with detailed steps, tutorials, videos, and thousands of practice problems.