Fourier Drawing Machine: How Spinning Circles Can Draw Anything
Ptolemy was wrong about the planets but right about one thing: any path, however complex, can be drawn by circles within circles. Fourier made it rigorous. The drawing machine makes it visible.
In 150 AD, Ptolemy described the motion of planets as circles upon circles — epicycles. He was wrong about the planets. But the mathematical structure he discovered was profound: any closed curve, no matter how irregular, can be described exactly as a sum of circular motions stacked tip-to-tail.
Joseph Fourier made this precise in 1822. For any periodic path through 2D space, you can find a set of rotating vectors — each with its own radius, speed, and starting angle — that sum to trace the path exactly. The Fourier Drawing Machine makes this visible. We'll walk through it in three steps, and you can run each step yourself.
Step 1: Give it something to draw
Upload any image (logos, letters, and silhouettes work best), draw a freehand closed shape, or pick one of the preset samples. Your input gets stored and passed to Step 2 — nothing leaves your browser.
Step 2: Find the outline
The Fourier series works on a 1D path — a sequence of (x, y) points sampled at equal time intervals around a closed curve. If you uploaded an image, we need to extract that curve first. The algorithm converts the image to grayscale, applies Otsu thresholding to produce a binary black-and-white mask, then runs a marching-squares contour tracer to find the dominant closed boundary.
If you drew freehand, you already gave us the path. Step 2 still shows it — confirming what gets passed to the Fourier transform. You can adjust the sensitivity and mode if the auto-detection missed the shape you wanted.
Step 3: The Fourier Transform
We now have a sequence of N complex numbers z₀, z₁, …, z_{N−1}, where each zₖ = x(k) + iy(k) encodes a 2D point as a single complex value. The Discrete Fourier Transform decomposes this sequence into N rotating vectors, one for each frequency n:
The k-th point on the path, encoded as a complex number: z(k) = x(k) + i·y(k). This treats the 2D coordinate as a complex number.
A rotating reference signal at frequency n. Multiplying by this and summing over all k measures how much of frequency n is present in the path.
Divides by the number of samples so that the coefficients don't grow with path resolution — cₙ represents amplitude, not total energy.
The number of evenly-spaced points sampled from the path. More samples → more frequencies computed → finer reconstruction.
Each coefficient cₙ is itself a complex number. Its magnitude |cₙ| becomes the radius of a spinning circle (arm length). Its argument ∠cₙ is the starting angle of that circle. Its index n is the number of full rotations per period — n=0 is a static offset, n=1 spins once per period counterclockwise, n=−1 spins once clockwise, n=3 spins three times counterclockwise, and so on.
Stack all N circles tip-to-tail, each spinning at its own rate, and the position of the final tip at time t is exactly the original path point z(t). The reconstruction formula is the inverse transform:
Encodes the nth circle. Its magnitude |cₙ| is the radius of the circle; its argument ∠cₙ is the starting angle.
Which frequency. n = 0 is a static offset. n = ±1 is the fundamental. n = ±2 is the second harmonic, spinning twice as fast.
A unit circle in the complex plane rotating at frequency n. As t goes from 0 to T, e^(2πint/T) completes exactly n full rotations.
The time for one complete cycle — how long it takes the path to close and start over.
In practice we sort the circles by radius (largest first) and let you choose how many to include. With all N terms the reconstruction is mathematically exact. Remove high-frequency terms and the path smooths — fine detail disappears, but the coarse shape survives. The Gibbs phenomenon makes sharp corners always overshoot by ~9%, no matter how many terms you add.
Use the Circles slider to remove high-frequency terms and watch what happens to the traced path. Open the Formula panel to see the actual computed coefficients for your shape — the amplitude, frequency, and phase of each spinning arm.
Why this matters beyond drawing
The drawing machine is a toy, but the mathematics is foundational. JPEG compression uses the 2D Discrete Cosine Transform (a close relative) to decompose images into frequency bands, discard what the eye can't see, and store only what remains. MP3 and AAC do the same for audio. MRI scanners collect data directly in Fourier space and reconstruct images by computing the inverse transform. WiFi and 4G use OFDM — Orthogonal Frequency Division Multiplexing — to pack multiple signals into a single channel by modulating independent frequency bands. The Fast Fourier Transform, which computes all N coefficients in O(N log N) instead of O(N²), makes all of this practical at scale.
The deeper you go with Fourier analysis, the more you realize: the universe has a preference for sinusoids. Light, sound, heat, quantum wavefunctions — all naturally decompose into frequency components. What makes the drawing machine valuable isn't the drawing. It's making that decomposition viscerally visible in a way no equation alone can.
See more interactive experiments.
The playground is where I put things built for the joy of building — visualizations, tools, and demos you can use right in the browser.
Browse the Playground