The parametric equation for a circle is
x = R.cos (θ) y = R.sin (θ)
As 'θ' varies from 0 to 2π this will trace one lap around the circle ('R' is the radius). This is our basic wheel. If we multiply θ by a positive integer this will be equivalent to making the wheel rotate faster. A negative integer will make the wheel rotate in the opposite direction. To create the spirograph patterns we combine two wheels rotating at different speeds, say n1 and n2.
x = R1.cos (n1θ) + R2.cos (n2θ) y = R1.sin (n1θ) + R2.sin (n2θ)
Here the second wheel of radius R2 makes n2 full turns as it travels n1 times around the inner wheel of radius R1.
These are idealised wheels, when using the toy, the radius of the inner wheel would be R1-R2. The other way we differ from the toy is that in the physical version the rates n1 and n2 are determined by the number of teeth on the wheels, which are constrained by the wheels' radii. We aren't limited in this way.
The starting positions of the wheels can be changed by adding in a phase component: ψ;
x = R1.cos (n1(θ+ψ1)) + R2.cos (n2(θ+ψ2)) y = R1.sin (n1(θ+ψ1)) + R2.sin (n2(θ+ψ2))
Although it would be difficult with the plastic toy, mathematically it's quite simple to add additional wheels, for instance, having a third wheel rotating around the other two can be represented as
x = R1.cos (n1θ) + R2.cos (n2θ) + R3.cos (n3θ) y = R1.sin (n1θ) + R2.sin (n2θ) + R3.sin (n3θ)
For two wheels the symmetry is |n1-n2| (assuming n1 and n2 have no common factors). If they do have a common factor, say 'k', then the symmetry would be |n1-n2| / k and the algorithm will draw over the same pattern k times.
For more wheels the symmetry is the highest common factor of the set of differences. With three wheels it will be
hcf (n1-n2, n1-n3, n2-n3) / k = hcf (n1-n2, n2-n3) / k
Where 'k' is the largest common factor of n1, n2, n3.
This four wheel animation. The speeds are [3, -13, 11, 19] and the sizes [3,3,2,1]. The differences in the rates are all multiples of 8, so the pattern has 8-fold symetry. The animation is created by changing the relative phases of the wheels.
(c) John Whitehouse 2012