# Spirograph

> A wheel rolling inside a ring, with a pen that traces a hypotrochoid; the wheel animates, and the sizes of the ring and wheel and the pen's distance from the wheel's centre can be edited.

A Spirograph is a toothed wheel that rolls inside a toothed ring, with a pen in one of its holes. The pen traces a curve called a hypotrochoid. This document rolls the wheel: the ring has radius $R$, the wheel radius $w$, and the pen sits at distance $d$ from the wheel's centre.

When the wheel's centre has moved through the angle $s$ around the ring, the wheel itself has turned the other way by $\frac{R - w}{w}s$, because it rolls without slipping: the arc it has covered on the ring equals the arc that has touched it. The pen is therefore at $a(s) = (R - w)\cos s + d\cos\left(\frac{R - w}{w}s\right)$ and $b(s) = (R - w)\sin s - d\sin\left(\frac{R - w}{w}s\right)$. With $R = 5$ and $w = 3$ the wheel's centre goes round three times before the pen returns to its start, and the curve has five lobes: in general the curve closes after $w/\gcd(R, w)$ turns and has $R/\gcd(R, w)$ lobes.

$T$ animates the wheel over three turns of its centre, which is the whole path for these sizes; the faint curve is that path, the red curve is the part traced so far, and the spoke joins the wheel's centre to the pen. Edit $R$, $w$ and $d$ to change the pattern ($w$ must stay between $0$ and $R$; other sizes may need more or fewer turns to close): with $d = w$ the pen is on the rim and traces a hypocycloid with cusps; with $R = 2w$ the curve is an ellipse, and a diameter of the ring when $d = w$ as well.

After a JSXGraph example by The Center of Mobile Learning with Digital Technology.

- [Open the interactive version](https://graph-paper.io/showcase/en/spirograph)
- [Learn more on Wikipedia](https://en.wikipedia.org/wiki/Spirograph)
