Lab / 01

South Africa, drawn by circles

The border of South Africa redrawn by two chains of spinning arms - one for the outer border and one for the hole in the middle where Lesotho sits. Every arm is a circle turning at a fixed whole-number speed. Put them tip to tail and the last one traces the country. Drag the slider to see how many circles it takes before the Cape Peninsula shows up.

The maths

z(t) = Σ ck · e2πikt, t ∈ [0, 1)
ck = (1/M) Σ zn · e−2πikn/M

The border is sampled as M evenly spaced points and each point is read as a complex number, z = x + iy. The discrete Fourier transform turns that list into M coefficients. Each coefficient ck is one arm: its length is |ck|, it turns k times per drawing, and it starts at angle arg(ck).

The arms are sorted longest first. N = 1 is a single arm pointing from the hub to the middle of the country. N = 2 adds a circle. Somewhere around 20 it starts to look like a map, and by 150 you get False Bay.

Why two chains

One Fourier series draws exactly one closed loop. South Africa is not one loop - it is a country with another country inside it. Lesotho is one of only three countries in the world entirely surrounded by a single other country (the other two are San Marino and Vatican City, both inside Italy).

So the drawing runs two independent series from the same hub: a long one for the outer border (1400 sample points) and a shorter one for Lesotho (360 points). The RMS error is the average distance between the drawn line and the real border, as a share of the outline's size.

Border data: Natural Earth 1:10m (public domain). Prince Edward Islands left out. Source on GitHub