Afterglowscreensavers

Fourier Epicycles Screensaver

Fourier Epicycles is a free, in-browser screensaver that turns a closed shape into a chain of rotating circles. Each circle is one term of the shape’s discrete Fourier transform — a radius, a starting angle and a whole-number frequency — and the tip of the chain traces the shape back out. It is the construction Ptolemy used for the planets, which turns out to be able to draw anything at all given enough circles. Nothing to download, and ESC exits at any time.

Live preview

Fourier Epicycles screensaver — Circles on circles, drawing anything.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Fourier Epicycles screensaver works

The shape is sampled at 256 points around its outline and each point treated as a complex number. A discrete Fourier transform finds, for every integer frequency k from −K/2 to K/2, a coefficient whose magnitude is a circle’s radius and whose argument is where on that circle the arm starts.

The circles are chained largest-first from the centre. At time t the arm of circle k points at angle k·t plus its phase, and the next circle’s centre sits at that arm’s tip. Adding the arms is exactly evaluating the inverse transform, so the last tip retraces the outline as t goes round once.

With a full set of coefficients the trace is exact; with fewer circles the high-frequency detail is dropped and the shape is a smoothed version of itself. Epicycles sets how many terms are kept. Negative frequencies matter: they turn the other way and are what let the trace bend both directions.

Shapes include a heart, the butterfly curve, a lemniscate, a star, a rose and a random blob built from a few random harmonics; in cycle mode each is traced for forty seconds before the next.

From Ptolemy to the Fourier transform

Epicycles began as astronomy. Ptolemy’s 2nd-century Almagest placed each planet on a small circle (an epicycle) riding on a larger one (the deferent), which explained the apparent backward, retrograde motion of the planets. The idea is older than Ptolemy: it is often attributed to Apollonius of Perga and was developed by Hipparchus. Adding circles improved the fit, much as adding terms improves a Fourier series.

The mathematics came later. Joseph Fourier showed that periodic functions can be written as sums of sines and cosines, and treating x and y together as one complex number turns each term into a rotating arm. Positive and negative frequencies spin in opposite directions, so a combination of them can trace a loop that is not circular at all. Epicycles can be written as a complex Fourier series, and Giovanni Schiaparelli is credited with noting the parallel.

Practical limits show up in the details. A smooth outline needs only a handful of circles, whereas a shape with sharp corners needs many, because the sum converges slowly there and rounds the corner off or overshoots it. That a path can be fitted by enough circles does not make Ptolemy’s model true, since a good fit says nothing about whether the planets actually move that way.

A worked example

At the defaults — Cycle, 40 epicycles, Speed 4 — a large slow circle carries a smaller faster one, which carries a smaller one still, down to a flicker of tiny circles at the tip, and the tip lays down a blue heart over about twenty seconds. Drop the count to 8 and the same heart comes out as a soft rounded blob; raise it to 100 and the sharp point at the bottom of the heart snaps into focus.

Settings & tips

Frequently asked questions

Can epicycles really draw any shape?
Any closed curve that can be sampled, yes: a Fourier series converges to it, and every term of the series is a circle rotating at a fixed rate. This is why Ptolemy’s epicycles could fit the planets even though the underlying model was wrong — enough circles can fit anything.
What does the number of epicycles change?
How many frequency terms are kept. Few terms give a smooth, rounded approximation of the shape; more add finer detail and sharper corners, at the cost of a longer chain of circles.
Will this slow my computer down?
It is tuned to run smoothly on an ordinary laptop. If it feels heavy, raise the Pixel size or lower the speed in the settings; every control takes effect immediately.
Is the Fourier Epicycles screensaver free?
Yes. It runs free in your browser with nothing to download or install, and it keeps working offline once the page has loaded.
How do I exit the Fourier Epicycles screensaver?
Press the ESC key at any time to leave fullscreen and return to the page.
Did Ptolemy’s epicycles use the Fourier transform?
No. Ptolemy’s model was a geometric construction, and the epicycle idea predates him. The connection is that both rely on sums of circular motion; the formal link came from later mathematics.
Why do some circles turn clockwise?
The transform includes negative frequencies, which correspond to arms rotating the opposite way. Without them, only counter-clockwise combinations would be available and many shapes could not be drawn.
Why are sharp corners drawn less cleanly than curves?
Corners contain rapid changes that need many high-frequency circles to reproduce. With a limited number the corner is rounded or slightly overshoots, a behaviour related to the Gibbs phenomenon.

← All Generative screensavers