Epicycles
a picture drawn by turning circles
About ← All projects
Scroll or pinch to zoom · drag to move · double-click to fit
×1.0
Circles per side
–
Distance from the line
–
RMS, as a share of the picture's spread
Fastest circle
–
turns per cycle
Traced line
–

Error by number of circles

How far the drawn curve stays from the traced line, for every number of circles per side (log scale). The dot is the count being drawn.

Table view

The circles

Each circle is one term r cos(k t + φ). It starts at angle φ and turns k times while the pen goes round once, so term k spins k times as fast as term 1.

Top chain → x

Left chain → y

How it works

  1. Simplify first. An uploaded picture opens in the Prepare picture window. An edge-preserving (bilateral) filter flattens texture, posterizing leaves a few tone levels, a flood fill from the border turns the background pure white, and a tone curve with a hard cutoff and a gamma above 1 makes light areas white too, so texture, background and light shading do not become scribble.
  2. One closed line. The picture is reduced to pixels on its outline (an Otsu threshold) or on its edges (Canny-style: blurred, thinned to one-pixel lines, with the threshold set well above the photo's grain), or placed as shading: points as dense as the picture is dark, by error diffusion. An uploaded picture with two clear tones is traced by its outline, any other by its edges, and a dark background is detected from the border. These are thinned on a grid and joined into one cycle: nearest neighbour first, then 2-opt, which reverses any stretch whose reversal makes the line shorter, so crossings go away. Separate shapes get joined by straight jumps, because a single line has to visit them all.
  3. Even steps. The cycle is resampled to 1,024 points evenly spaced along its length. A parameter t runs from 0 to 2π once round.
  4. One series per side. Each coordinate is expanded separately: x(t) = a₀ + Σ rk cos(k t + φk), and the same for y(t). Each term is one circle. Chained end to end above the picture, the circles' tip sets x; chained down the left, it sets y. The guide lines from the two tips meet at the pen.
  5. One, two, three … With one circle per side the pen draws an ellipse, the best single-frequency fit. Each extra circle adds detail at a higher speed. The error falls toward zero as the count rises.

Taylor or Fourier?

These turning circles are a Fourier series. A Taylor series in time, c₀ + c₁t + c₂t² + …, never comes back to where it started, so it cannot draw a closed loop. Still, the two ideas are closely related. Write z = eit, a point going round the unit circle once per cycle. Then x(t) = Re(A₀ + A₁z + A₂z² + A₃z³ + …) with Ak = rkeiφk. That is a Taylor (power) series in z. Each power zk is a point going round k times as fast, so the term's place in the expansion sets its circle's speed, and its coefficient sets the circle's size and starting angle.