epicycles
A drawing machine that redraws images as sums of rotating circles
Links
Date
2026
Built a drawing machine that takes an image and redraws it with stacked rotating circles, a complex Fourier series you can watch work. Drop in a logo or sketch a path by hand, and it extracts the outlines, runs a DFT on each one, and drives chains of epicycles whose tips trace the drawing in ink. Inspired by this Mathologer video on epicycles and Homer Simpson's orbit. This was a really fun project, and I mostly wanted to feel the magic of Fourier transforms.
How it works
The image becomes closed paths first. Flat-color art is segmented by palette: cluster the colors, vote out the background using the image border, and trace each remaining region with marching squares. Photos fall back to an Otsu-thresholded silhouette or Sobel edges. SVGs get re-authored to 1024px before rasterizing so small icons don't trace jagged. Every path found this way gets its own machine, and they all draw simultaneously.
The math
Each path is resampled to evenly spaced points and read as one period of a complex signal, treating the drawing plane as the complex plane:
The discrete Fourier transform decomposes that signal into coefficients:
Each coefficient is a circle. Writing , the amplitude is the circle's radius, the signed frequency is how fast it spins and in which direction, and the phase is where it starts. Stack the circles tip to tail, big ones first, and the pen is the partial sum
over the largest-amplitude terms. With all terms the inverse transform reproduces the sampled path exactly; with fewer, you watch the approximation converge.
The n slider
Truncation error is the fun part. At the machine draws a wobbly approximation, at the shape is unmistakable, and with all 512 terms the reconstruction is exact to floating point. Half the circles spin clockwise: you can't close a non-circular curve without negative frequencies.