Spirographs, Hypotrochoids & Epitrochoids: The Maths of Rolling Circles
A spirograph toy traces the path of a point on a small gear rolling inside or around a larger ring. The result is never quite circular — instead it produces intricate petalled curves whose exact shape depends on a single ratio of integers. Behind this childhood toy lies a beautiful branch of geometry connecting gear ratios, greatest common divisors, Fourier series, and planetary motion in a single unified picture.
1. The Cycloid: Rolling on a Line
Before gears, consider the simplest rolling-circle curve: fix a circle of radius r rolling along a straight line without slipping. A point on the rim traces a cycloid:
The cycloid has two famous physical properties. It is the brachistochrone: the curve of fastest descent between two points under gravity — faster even than a straight line. And it is the tautochrone: no matter where on the arch you release a frictionless bead, it reaches the bottom in exactly the same time (Huygens, 1659). This made the cycloid the basis of the first accurate pendulum clock escapement.
If the tracing point is not on the rim but inside (at distance d < r) or outside (d > r), the curve is a prolate or curtate cycloid respectively — smoother loops or cusped arches depending on d.
2. Hypocycloids: Rolling Inside a Circle
Now roll the small circle inside a fixed outer circle of radius R. The tracing point is on the rim of the small circle (radius r). The resulting curve is a hypocycloid:
The astroid (R/r = 4) appears in many contexts: the evolute of an ellipse is an astroid; the envelope of a moving ladder (one end on a wall, one on the floor) is an astroid. Its equation x^(2/3) + y^(2/3) = R^(2/3) looks deceptively simple for such an intricate geometric object.
3. Hypotrochoids: The Spirograph Curve
A hypotrochoid generalises the hypocycloid by placing the tracing point at distance d from the centre of the rolling circle, not necessarily on the rim:
The Spirograph toy (invented 1965 by Denys Fisher) provides physical gear sets with specific R and r values. The small gear's pen-holes correspond to different values of d. By choosing different gear combinations and holes, children (and mathematicians) explore this two-parameter family of curves.
Rose Curves as Special Cases
When d = R − r (tracing point at the origin of the rolling circle if it were at the outer rim), the hypotrochoid collapses to a rose curve r = cos(nθ) in polar coordinates, where n = R/r. This is why rose curves with 3, 5, 7 petals have odd denominators — the rolling circle must complete an integer number of full rotations inside the fixed ring.
4. Epitrochoids: Rolling Outside
An epitrochoid results from rolling the small circle outside the fixed circle — a single sign change in the equations:
The cardioid (Greek: heart) is one of the most recognisable mathematical curves. Beyond its appearance as the Mandelbrot set's main body boundary, it is the directrix of a parabolic microphone and the shape of the polar gain pattern of a cardioid microphone element — hence the microphone type's name.
The nephroid appears as the caustic (bright curve) you see on the inside of a cylindrical coffee mug in sunlight. The reflected or refracted rays from the curved surface envelope a nephroid — a natural optical phenomenon explained by epitrochoid geometry.
5. Petal Counting & the GCD Rule
How many petals (lobes) does a spirograph curve have? The answer involves the greatest common divisor (GCD) of the two gear radii:
This formula is the mathematical reason why toy spirographs print the number of "teeth" on each gear. Given tooth counts, you can predict the exact pattern before drawing it — or conversely, choose gear combinations to achieve a desired number of petals.
6. Period, Closure, and the LCM
A spirograph curve closes (returns to its starting point) after the parameter t has advanced by 2π × (LCM(R, r) / R) — the time for the system to return to exactly its initial gear alignment. Using gear teeth counts T_R and T_r:
This means drawing the complete spirograph curve in code requires sweeping t from 0 to 2π × p (where p is the numerator of the reduced gear ratio, not just 2π). Stopping at 2π draws only a partial curve — often a confusing bug when first implementing spirographs.
7. Lissajous Figures: A Special Limit
As the outer circle radius R → ∞ while r stays fixed (gear ratio → ∞), rolling inside a circle locally approximates rolling along a line. In the limit, the hypotrochoid becomes a Lissajous figure — the parametric curve traced by two independently oscillating sinusoids:
Lissajous figures appear on an oscilloscope when two sinusoidal voltages drive the X and Y deflection plates. The shape immediately reveals the frequency ratio — a circle means equal frequencies, a figure-eight means one frequency doubles the other. This is used in audio labs to tune frequencies and measure phase relationships between signals.
The connection to spirographs is more than formal: both are generated by combining two circular motions. A hypotrochoid combines a circle of radius (R−r) rotating at rate 1 with a circle of radius d rotating at rate (R−r)/r. A Lissajous figure combines a horizontal oscillation (half a circle) at rate a with a vertical oscillation at rate b. The visual similarity — closed petalled curves — reflects this shared circular superposition.
8. Fourier Epicycles: Any Curve from Circles
Spirograph curves are built from two circles. But Fourier epicycles generalise this to any number of circles — and with enough circles, you can approximate any closed curve, not just algebraic ones.
This is the basis of the popular "Fourier epicycles drawing" visualisations — where a chain of rotating arms traces out a portrait, a national border, or a handwritten letter. Each arm corresponds to one Fourier mode; the full chain sum approximates the complex Fourier series of the original curve.
The mathematical content is the same as audio Fourier analysis: just as a sound wave is decomposed into frequency components (harmonics), a 2D closed curve is decomposed into circular rotations at different frequencies. The "fundamental frequency" arm goes around once per period; higher harmonics add the fine wiggles and sharp corners.
9. Drawing Spirographs in JavaScript
A complete, interactive spirograph renderer in under 50 lines:
The simulation at Spirograph Simulator on this site lets you interactively drag sliders for R, r, and d, and watch the curve build in real time — with the inner gear visibly rolling around the outer ring to show the geometric construction.
Extensions
- Multiple layers: Layer several hypotrochoids with different colours and slightly different parameters for mandala-style compositions.
- Animated drawing: Increment t step by step on each animation frame, plotting one point at a time — the pen visibly travels the curve.
- 3D spirograph: Add a slowly rotating tilt to the inner gear's axis between steps — the curve lifts off the plane into a closed tube on a torus surface.
- Gear ratio sweeper: Animate r from 1 to R over 60 seconds — watch the curve morph through every gear ratio, from straight lines to dense flower-like rosettes.