A spirograph is a toy which uses simple mechanics to produce an attractive set of curves, technically known as roulette curves.

A small wheel rolls without slipping around the interior edge of a large circle which marks the outside boundary of the spirograph pattern. A pen is place either on the circumference of the smaller wheel, or else at some other fixed point within it. As the wheel rotates, the pen traces out the roulette curve.

Several variables influence what the resulting curve looks like, including the ratio of the sizes of the inner wheel to the exterior circle, and the placement of the pen within the wheel.

Try altering the settings above to see how the curves change shape. Mathematically, the formula for these curves is

\[ x(\theta) = (R - r) \cos(\theta) + r p \cos\left(\frac{R + r}{r}\theta\right) \]

\[ y(\theta) = (R - r) \sin(\theta) - r p \sin\left(\frac{R + r}{r}\theta\right) \]

where:

*R* is the radius of the exterior circle,

*r* is the radius of the small rolling wheel,

*p* is the position of the pen within the small rolling wheel (0-1),

and

*θ* measures distance along the curve.