Epicycles

Draw one continuous line. Two stacks of circles will trace it.

N = 1024512 circles / axis

01 · Draw

Draw a shape

One continuous line. Lift whenever you like — the next stroke continues from the glowing end. Click to add straight segments.

empty

02 · Epicycles

The x stack will turn along the top, the y stack down the left, and their projections meet at the pen that redraws your curve.

N1024
n1–32

03 · Spectrum

x amplitudes y amplitudes

The amplitude of every harmonic appears here once there is a curve.

How the solver works

Every curve is a sum of turning circles.

x(t) = x0 + Σk Ak cos(k t + φk)
y(t) = y0 + Σk Bk cos(k t + ψk)

Two stacks

  1. 01

    Close the curve

    A Fourier series is periodic, so the open drawing becomes a loop: a straight segment back to the start, or a retrace that runs out and back along the same path. No jump means no ringing.

  2. 02

    Resample to N points

    The loop is cut into N points spaced equally by arc length. You pick N with the resolution slider — from 32 up to 16384 samples, 2^k each (1024 by default). Time t then advances at constant pen speed, no matter how fast you moved the mouse — and every gap moves at that same speed, or moves quickly or jumps instantly per the Gaps setting (interpolate, quick snap, or instant).

  3. 03

    Two real FFTs

    x[m] and y[m] are transformed separately. Each gives a mean (where its stack is anchored) and N/2 harmonics — the most that N samples can resolve (Nyquist).

  4. 04

    Harmonic → circle

    Harmonic k becomes a circle of radius Ak = 2|Xk|/N that turns k times per loop, starting at angle φk = arg Xk.

  5. 05

    Stack and project

    Circles ride on each other's rim. The x stack's last point gives the pen's x, the y stack (turned 90°) gives its y. The slider keeps the first n circles per axis.

One stack

Or read the drawing as one complex series.

The two stacks above are the same fit seen through two real signals. One stack instead treats the samples as a single complex signal z(t) = x(t) + i·y(t) and takes one complex FFT, which gives a coefficient ck for every signed frequency: +k turns counterclockwise, −k clockwise. Circles still ride on each other's rim — but the tip of the last one is the pen, so the curve grows straight out of the stack with no projections and no side trace.

z(t) = Σk ck eikt
ck = |ck| eiφk
k = −N/2 … N/2 → N−1 circles

Largest keeps the n biggest circles — the best possible n-circle fit. Low freq keeps harmonics 1…n, so n is literally the fastest rotation allowed. Either way the slider keeps the first n circles of the series in play, and with every circle in play the trace passes through all N samples exactly.