Introduction: The Math Behind a Spirograph

https://www.geogebra.orgThe spirograph is among those pass-time we spent when young. Personally, I was fascinated by the precision of the drawings it helped us create. We turn round and round and we reach back exactly the starting point after some rotations. And, of course, I was convinced that this precision is nothing else than simple math. But, I've never stopped asking myself to understand the maths behind it. On year ago, as a coding teacher for teenagers (upgrade-code.org), I imagined a summer code camp in which we develop a software spirograph. Through my preliminary research, I found the Inspirograph of Nathan Friend. It is a complete software spirograph with even additional shapes that rarely exist in real life. According to his blog post about his project, he had millions of page views and contributions. And many talked about the soothing effect of drawing with spirographs.

But still remains for me the same question : "What is the math behind the spirograph ?"

So, in order to answer the question, I will do it in 3 phases :

* Phase 1 (this instructable): emulate geometrically the spirograph using Geogebra application

*Phase 2 (coming instructable): emulate the spirograph using Object Oriented programming approach with a visual coding platform (meo.codimeo.com which based on Snap!)

* Phase 3 (coming instructable): create a trinket of an analytical and more linear approach to emulate a spirograph with Python

Supplies

The only requirement for this instructable is the access to Geogebra web application, using any computer , a tablet or even a smartphone :

https://www.geogebra.org

In order to save your creations, it may be useful to create a free account.

Step 1: Analyzing the Initial Situation

The spirograph is compound of 3 parts :

  • The fixed gear
  • The mobile gear
  • The pen

Let's take as an example, the spirograph with a fixed internal gear of 105 teeth, a mobile gear of 30 teeth located inside the fixed gear and the pen located at halfway between the mobile gear center and its border.

Geometrically speaking, this can be modeled as in the figure, knowing the following naming conventions :

  • Point A: is the center of the fixed gear,
  • Point B: is the point of contact between the mobile and the fixed gear,
  • Point C: is the center of the mobile gear.
  • The Pen (Point P): is located on the segment [CB]

When the mobile gear is turned clockwise, using the pen, around its center C, it runs anti-clockwise around the center A.

Step 2: When the Mobile Gear Is Rotated

With the pen, the mobile gear is pushed around its center (point C) to the right. That causes the gear to rotate to the left, around the center (point A) of the fixed gear. The different points have now new positions after the rotation around the center A :

  • Point A stays the same
  • Point C is rotated to point C'
  • Point B is rotated to point B'

At the same time, the pen rotated around both point A and the center of the mobile gear, point C'. And since this center is moving around point A, the trail of the pen will have the beautiful curve of our spirograph.

Equally, like the pen, the point B moved around point A, and also around the moving point C'. Point B is, at the start, the contact point between the mobile and the fixed gear. This contact point moved to point B'. But the physical point B, itself, rotated around the center of the mobile gear (point C') to reach the point B".

Let's analyze precisely what happened. And for this, we will create a model using Geogebra.

Step 3: Using Geogebra - First Constructions

Geogebra is a very good geometry simulation tool. It has many other mathematical features like Computer Algebra System calculator (CAS Calculator), Graphing Calculator. But, we will focus, here, on the geometry application. The tool is free to use and it can be used without creating an account. Nevertheless, it is advised to create an account in order to save your work.

In the following, we will go through the different steps to create the geometry model of the spirograph. But, for those who are in a hurry, here is the link to the complete model : https://www.geogebra.org/m/c3cvgkcb. The spirograph is combined of an external fixed gear of 105 teeth and an internal mobile gear of 30 teeth.

  1. Open the browser and go to: https://www.geogebra.org/
  2. Click on "Geometry" link available under "More Apps"
  3. In the new browser window, click on the algebra view. (Note: normally, the standard tools are used to draw points, circles and segments and transform them. But, here, formulas with parameters are required to simulate correctly the situation)
  4. In the first row, next to the big Plus symbol, enter the following formula : "M = 105". This is the number of teeth of the fixed gear.
  5. A new row appears. Enter : "N = 30". This is the number of teeth of the mobile gear.
  6. From now on, at each step, enter the different formulas, bolded, between quotation marks. Each formula is commented if not self-explanatory.
  7. " A = (0,0) ". This is the center of the fixed gear.
  8. " B = (10,0) ". This the extremity of the radius of the fixed gear, and that will be in contact with the extremity of the mobile gear. The "B" should be capitalized so that the system understands it is a point. Otherwise, the formula will be interpreted as a vector. The number 10 is randomly selected. We could put 1, 5 or even 261. We just need to correctly zoom the
  9. " Segment(A, B) ". The segment representing the radius of the fixed gear.

Step 4: Placing the Center of the Mobile Gear

The next step is to place the center (point C) of the mobil gear somewhere on the segment (A, B). In fact, Point B is the contact point between the fixed gear and the mobile gear. So the common tangent to the two gears in Point B, is perpendicular to both radiuses of the two gears: Segment (A, B) and Segment (C, B). Which means that the two segments are parallel and have a point in common (Point B). As a conclusion, both segments, and the three points A, B, and C are aligned.

The question, now, is how far Point C is located from Point A on segment (A, B).

The distance AC = AB - CB.Which is the same than :

[Formula 1] AC = AB * (1 - CB / AB)

From one side, we all know that the circumference of a circle is :

[Formula 2] C = 2 * PI * R where R is the radius of the circle.

From another side, the circumference of a gear, as a circle, is :

[Formula 3] C = N * L, where N is the number of teeth of the gear, and L is the length a one teeth.

That leads to C = N * L = 2 * PI * R and to the fact that :

[Formula 4] L = 2 * PI * R / N

If the following notations is used:

Rf = radius of fixed gear

Rm = radius of mobiel gear

M = number of teeth of the fixed gear

N = number of teeth of the mobile gear

and, since, one tooth of the mobile gear has the same length than one of the fixed gear (that's why they fit together), the following formula will demonstrate the link between radiuses :

[Formula 5] L = 2 * PI * Rf / M = 2 * PI * Rm / N

And can be simplified as follow :

[Formula 6] Rf / M = Rm / N

or

[Formula 7] N / M = Rm / Rf

Because, Rf = AB and Rm = CB, the [Formula 1] gives :

AC = AB * (1 - CB / AB) = AB * (1 - Rm / Rf) = AB * (1 - N / M)

Now back to Geogebra, Point C is placed using this formula :

[Formula 8] Point (f, (1 - N / M))

where f is the segment (A, B)

Step 5: Drawing the Circles

Here is the list of formulas to put in Geogebra to build the circles :

  1. Circle(A, B) : Cercle "c" de centre A et passant par le point B. Ici pas besoin de spécifier le rayon puisqu'il est implicitement matérialisé par le segment (A, B).
  2. Circle(C, B) : Cercle "d" de centre C et passant par le point B.

In order to emphasize that those circles are the gears, we will change their settings and display them accordingly:

  • Next to each line definition of the circles, click on the vertical three dots
  • Select Settings
  • The settings pane appears to the right with several tabs
  • Select the "Color" tab and select your desired color
  • After that, click on the "Style" to select dotted line style and thickness of 2
  • Repeat this for both circles, Red for the mobile gear (circle(C,B)) and blue for the fixed gear (circle(A,B)). Of course, you can choose your colors.

Step 6: Preparing the Animation

To simulate the spirograph, the mobile gear needs to rotate around the center A of the fixed gear. If, "alpha" (α) is the angle of rotation. To show this:

  • To define α, use the keyboard to the bottom left of the screen to type the greek letter
  • Put : α = 30
  • Then to rotate the mobile gear around the center A, rotate, first, the point C and, after, the mobile circle.
  • For that, add the formula using capital letter "C" for Point C: Rotate(C, α * π / 180,A)
  • And the formula using little letter "d" for Circle d: Rotate(d, α * π / 180,A)

At the same time, the new contact point between the two gears is the rotation of B around center A with angle α:

  • Add the formula: Rotate(B, α * π / 180,A)

Now, if the mobile gear rotates only one tooth, the contact point will rotate of one tooth on the fixed gear. A full rotation of the mobile gear around its own center means the run N teeth of the fixed gear, which is equivalent of a portion of :

[Formula ] N / M

of a full round of the fixed gear (M being the number of teeth of the fixed gear). Since a full rotation of the mobile gear is the angle 2 * π, the contact point with the fixed gear runs , proportionally, an angle equal to:

[Formula ] 2 * π * N / M

More generally, when the mobile gear turns with an angle γ, the contact point with the fixed gear turns with an angle:

[Formula ] β = γ * N / M

Which leads to the fact that:

[Formula ] γ = β * M / N

So, since the mobile gear has rotated of angle α around center A, the contact point with the fixed gear will rotate of angle α as seen before, which is the same than the angle β. That means that:

[Formula ] γ = α * M / N

The first contact point with the fixed gear will move to a new position that is the rotation of the point B' around center C' with the angle γ:

  • Add the formula: Rotate(B', α * (M / N) * π / 180,C')

To visualize both tracks of the contact point on both gears:

  • Add the formula: Segment( A , B' )
  • Change the settings of this segment to a dashed thin line (1 point thick)
  • Add: Angle( B , A , B' )
  • Add: Segment( C' , B'' )
  • Change the settings again to a dashed thin line
  • Add: Angle( B', C', B'' )
  • Add: Arc(

Finally, let's add the pen.

Step 7: Add the Pen

Physically, there are 2 kind of mobile gears: Kind "A" and Kind "B". The "A" kind has little holes aligned with the one tooth of the gear. The "B" kind has the holes aligned with the gap between 2 consecutive teeth.

In our simulation, we will focus on kind "A". so, the Pen, at start, will be supposed to be aligned between the center of the mobile gear and the contact point with the fixed gear. After rotation with angle α, the Pen will be aligned with the center of the mobile gear, point C', and the point B". The position P of the Pen will chosen between those 2 points using a scale from 0 (point C') to 10 (point B"):

  • To define P, the pen position between point C' and point B", type letter P with the keyboard,
  • And, put : P = 9
  • Add the formula: Segment( C' , B" )
  • The identifier of the segment will appear as "i"
  • Add the formula: Point( i, P / 10)
  • Rename the resulting point name to "Pen"
  • Click on the 3 dots to opens the settings pane
  • Under the tab "Basic", check the box of "Show Trace".

Now the simulation can start


Step 8: The Simulation

You remember the α parameter. It is represented by a slider. It can be automatically incremented to make the mobile gear turn and run the simulation. Here are the steps to change the options of this slider before starting the simulation:

  • Open the settings of the parameter α
  • Click on the tab "Slider"
  • Select "speed" parameter and enter a value less than 0.2 (so that the simulation can be enjoyed)
  • Finally, you can hit the little "Play" symbol next to the slider of parameter α

The different parameters can be tweaked at will to simulate actual physical gears and situations. And, one may try to find the good formula to guess the maximum alpha for each simulation required to finish the whole loop :-)


Made with Math Contest

Participated in the
Made with Math Contest