Spirograph Simulator

Trace hypotrochoids and epitrochoids — the mathematical curves behind the classic Spirograph toy. Roll a virtual gear inside or outside a fixed ring, adjust the pen offset, and watch intricate geometric art emerge from simple parametric equations.

FREE Mathematics Geometry NEW · Session 45
Type Hypotrochoid
R : r 5 : 3
GCD 1
Turns 3
Done 0%
Playback
Presets (1–6)
Curve Type
Geometry
Speed
Options
Keyboard: Space — play/pause  ·  R — reset  ·  1–6 — presets

The Mathematics of Spirograph Curves

The Spirograph toy, patented by British engineer Denys Fisher in 1965, produces curves that mathematicians call roulettes — the path traced by a point fixed to one curve as it rolls along another. The two types produced by Spirograph gears are hypotrochoids (inner rolling gear) and epitrochoids (outer rolling gear). Both families have been studied since the 17th century and appear in optics, planetary gear systems, and the Mandelbrot set.

Parametric Equations

For a small circle of radius r rolling inside a fixed circle of radius R, with the pen at distance d from the rolling circle's centre:

Hypotrochoid:  x(t) = (R−r)·cos(t) + d·cos((R−r)/r · t)
               y(t) = (R−r)·sin(t) − d·sin((R−r)/r · t)

Epitrochoid:   x(t) = (R+r)·cos(t) − d·cos((R+r)/r · t)
               y(t) = (R+r)·sin(t) − d·sin((R+r)/r · t)

Period:        T = 2π · r / gcd(R, r)

The curve closes after r / gcd(R, r) full rotations of the inner gear. The HUD shows this count as "Turns". For simple ratios like R=5, r=3 (gcd=1), the curve closes after exactly 3 turns, drawing a 5-lobed rose. For R=6, r=4 (gcd=2), it closes after only 2 turns, giving a 3-lobed figure.

Preset Parameter Reference

PresetRrdTypeTurns to CloseCharacteristic
Classic Rose 5 3 4.0 Hypo 3 3-petal rose with rounded ends
Five-Point Star 7 2 6.0 Hypo 2 5-pointed star / pentagram shape
Daisy Seven 9 2 7.0 Hypo 2 7-petal daisy pattern
Cardioid 4 4 4.0 Epi 1 Heart-shaped cardioid (r = R special case)
Inner Loops 7 4 3.0 Hypo 4 Inner loops with 7 arms
Galaxy Web 11 3 8.0 Hypo 3 11-arm complex web pattern

Special Cases & Named Curves

Deltoid (Hypo, d=r, R=3r)

A 3-cusped hypocycloid with cusps forming an equilateral triangle. The envelope of the Simson line for a triangle inscribed in a circle.

Astroid (Hypo, d=r, R=4r)

A 4-cusped hypocycloid: x=R·cos³(t), y=R·sin³(t). Appears as the envelope of a line of constant length sliding along two perpendicular axes.

Cardioid (Epi, d=r, R=r)

The simplest epitrochoid: a heart-shaped curve with one cusp. Forms the main cardioid of the Mandelbrot set and the polar pattern of cardioid microphones.

Nephroid (Epi, d=r, R=2r)

A 2-cusped epicycloid resembling a kidney. Appears as the caustic in the bottom of a tea cup (the bright curved line formed by reflected light).

Rhodonea / Rose Curves

When d < r in a hypotrochoid, the petals don't cross the origin. Increasing d beyond r creates inner loops. At d = |R−r|, the curve passes through the origin.

Wankel Rotary Engine

The rotor in a Wankel engine traces an epitrochoid. The rotor's apex traces the inner housing shape, which is a 2-lobed epitrochoid with specific gear ratios.

Period & Closure: Number Theory Connection

The number of inner-gear rotations before the curve closes equals r / gcd(R, r). This is a consequence of the Euclidean algorithm: the gear returns to its starting orientation only when the total rotation is a multiple of 2π for both the outer and inner angles simultaneously. In terms of the toy's gear teeth, if the outer ring has R teeth and the inner gear has r teeth, the curve closes after r / gcd(R,r) full revolutions of the inner gear — exactly when the teeth re-mesh at their original starting position.

Turns to close = r / gcd(R, r)   =   lcm(R,r) / R
Lobes / petals ≈ (R−r) / gcd(R, r)   [for hypotrochoid, d near r]

Curriculum Connections

LevelTopicConnection
GCSE Maths Coordinates, circles, loci Hypotrochoids as parametric loci of moving points
A-Level Maths Parametric equations, trigonometry Differentiating x(t), y(t); finding cusps (dx/dt = dy/dt = 0)
A-Level FM Complex numbers, polar curves Expressing roulettes in polar form; r = a + b·cos(nθ)
IB HL Maths Calculus, vectors Arc length integral ∫√(ẋ²+ẏ²)dt; curvature κ = (ẋÿ−ẏẍ)/|v|³
University Differential geometry, group theory Roulettes as orbits of the rolling group; Klein's Erlangen programme
Engineering Gear design, engine mechanics Wankel rotor profiles; cycloidal gear tooth profiles

Keyboard Shortcuts

Space Play / Pause
R Reset canvas
1 Classic Rose
2 Five-Point Star
3 Daisy Seven
4 Cardioid
5 Inner Loops
6 Galaxy Web

Frequently Asked Questions

What is a spirograph and what equations describe its curves?
A spirograph uses interlocking gears to trace roulette curves. When a small gear of radius r rolls inside a fixed outer ring of radius R, the pen traces a hypotrochoid: x(t) = (R−r)cos(t) + d·cos((R−r)/r · t), y(t) = (R−r)sin(t) − d·sin((R−r)/r · t), where d is the pen-to-centre distance. Rolling outside gives an epitrochoid.
How many petals does a spirograph pattern have?
For a hypotrochoid with pen on the gear rim (d = r), the number of cusps equals R / gcd(R, r). The curve closes after r / gcd(R, r) inner-gear rotations. For example, R=5, r=3 (gcd=1) gives 5 cusps and closes after 3 turns; R=9, r=2 (gcd=1) gives 9 cusps and closes after 2 turns.
What real-world objects use spirograph-type curves?
The Wankel rotary engine rotor traces an epitrochoid. Cardioid microphones have polar patterns shaped like a cardioid epitrochoid. The tea-cup caustic (the bright crescent when sunlight reflects inside a mug) is a nephroid. Cycloidal gear tooth profiles reduce friction in precision gearboxes. The Mandelbrot set's main cardioid boundary is a cardioid.
What happens when the pen offset d equals the inner radius r?
When d = r, the pen sits exactly on the rim of the rolling circle, tracing a hypocycloid (hypo case) or epicycloid (epi case) — both are special cases with angular cusps. Set R=3r for a deltoid (3 cusps), R=4r for an astroid (4 cusps), and R=r in epi mode for a cardioid.

Related Simulations & Articles