Michael Bradford Williams

Home / Programming / Spirographs

A Spirograph is a well-known toy that allows one to draw a variety of beautiful curves. Each curve follows the trajectory of a point inside a small gear that moves inside of a larger gear (with inward facing teeth). The curves have a very interesting and long-studied mathematical basis, which is explained well here.

If we assume that the gears are circles, and the larger circle has radius 1, then let \(k \in [0, 1]\) represent the radius of the smaller circle. Let \(\ell \in [0, 1]\) represent the proportional distance from the center of the smaller circle to the curve, at the start of the drawing. Then the resulting curve can be parametrized by time: \(c(t) = (x(t), y(t))\). It turns out that the functions \(x(t)\) and \(y(t)\) have a nice form (see the above link for a derivation) with \(k\) and \(\ell\) as additional adjustable parameters:

\[ \begin{align*} x(t) &= (1-k) \cos(t) + k \ell \cos\left( \frac{1-k}{k} t \right) \\ y(t) &= (1-k) \sin(t) + k \ell \sin\left( \frac{1-k}{k} t \right) \end{align*} \]

The time parameter \(t\) of the curve can range over all real numbers, but we only need one period of the curve, which is \(2\pi\) times the least common multiple of the periods of the trig functions involved. Also, technically, we should have \(k \in [0, 1]\) and \(\ell \in [0, 1]\), but there is no mathematical reason for such restrictions in the above equations (except when \(k=0\)).

Below is a program to draw Spirograph-like curves, where \(k\) and \(\ell\) can be adjusted.

Here is a larger version that is more suited to desktop browsers.

\(k\):
\(\ell\):

Your browser is currently unsupported.