Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Fourier epicycles

Draw any shape and watch a chain of spinning circles redraw it with a Fourier transform; build square, sawtooth and triangle waves from sines.

or draw your own in the box in one go

24

How to use

  1. Pick a shape, or draw your own in the white box: press, draw one closed outline without lifting, then let go. The end joins back to the start.
  2. Spinning circles, each riding on the one before, redraw the shape with the red pen. Move Circles to keep fewer or more of them, biggest first.
  3. The table shows how far the redraw is from the original. With all 256 circles it is exact at the sample points.
  4. Waves from sines builds square, sawtooth and triangle waves out of sine waves and measures the overshoot at the jumps.

Keyboard and touch

TabMove between tabs, sliders, boxes and buttons
Arrow keys on a sliderOne circle or term more or fewer
Finger, pen or mouse in the boxDraw your own shape (one stroke)
Space on Pause or PlayStop or restart the circles

Tips

  • Smooth, round shapes need only a few circles; sharp corners need many, because a corner is made of high speeds.
  • A circle needs just one spinning circle (plus the fixed centre); a heart looks right with about 10, a star with about 30.
  • Watch the square wave: however many terms you add, the sum overshoots by about 9 % of the jump next to it. This is the Gibbs phenomenon; the bump gets narrower but never shorter.
  • The sawtooth's terms shrink like 1/n and the triangle's like 1/n², which is why the triangle wave looks right with only a handful.
  • If your device asks for reduced motion, the whole redraw is shown at once without spinning.

About this tool

The outline is first resampled to 256 points evenly spaced along its length. Each point (x, y) is treated as the complex number x + iy, and the discrete Fourier transform Xk = (1/N) Σ zn e−2πikn/N gives one circle per frequency: its radius is |Xk|, its starting angle the angle of Xk, and it turns k times per lap (frequencies above N/2 are counted as negative, turning the other way). Adding all N circles gives back every sample exactly; keeping only the biggest K gives the best K-circle redraw in the least-squares sense (Parseval's theorem).

The waves tab sums the classic Fourier series of a square wave, a sawtooth and a triangle wave of height 1. The overshoot is found by checking 4,001 points beside the jump; as the number of terms grows it approaches about 1.179 for the square wave, 8.95 % of its jump of 2 (Gibbs, 1899). Everything is drawn in your browser.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product