[Math] Evenly space holes in circle

geometryrecreational-mathematics

A picture is worth a thousand words:

Uneven Spirograph gear holes

This gear is part of an interactive SVG Spirograph I'm creating. I'm dynamically generating the gear based on a number of parameters (gear radius, number of teeth, etc). Notice how the holes scrunch up as they get close to the center? It's because I'm currently spacing the holes by a constant angle, and as they get close to the center, that angle doesn't move each hole very far.

Real-life Spirograph gears space their holes so that they appear equidistant from each other, even as they get close to the center:

A real Spirograph gear

My attempt to emulate this effect was partially successful – instead of spacing each hole by an absolute angle, I took the arc length between the first two holes and the last two holes and averaged them. I then moved each hole by this average arc length. This looks much better:

A better Spirograph gear

However, notice that the holes now wrap further around the gear – they sweep through about 450 degrees instead of exactly 360, like in the first image. This "sweep distance" is something I accept as a parameter when I create a gear, so I'd like it to accurately reflect the value passed in.

I'm assuming there's something wrong with how I'm calculating the average arc length – just averaging the smallest and largest arc length is probably an oversimplification that's resulting in extra spacing between the holes. Is there a better algorithm that will evenly space the holes around the gear while maintaining the correct "sweep distance"?

Best Answer

If $r_1<r_2$ is the range you want for the radii, then you want $\theta: [r_1,r_2]\to [0,2\pi]$ so that $\theta(r_1)=0$, $\theta(r_2)=2\pi$ and the velocity of the curve $\left(r\cos\theta(r),r\sin\theta(r)\right)$ is constant in amplitude.

The velocity is $(\cos \theta(r) -r\theta'(r)\sin\theta,\sin\theta(r) + r\theta'(r)\cos\theta(r))$, and the amplitude is $$\sqrt{\left(\cos \theta(r) -r\theta'(r)\sin\theta(r)\right)^2+\left(\sin\theta(r) + r\theta'(r)\cos\theta(r)\right)^2} = \sqrt{1+\left(r\theta'(r)\right)^2}$$

So for this to be constant as $r$ changes, $\theta'(r) = \frac{A}{r}$, and thus $\theta(r)=A\log r + B$, for some constants, $A,B$.

Now solve for $A,B$ using the boundary conditions $$A\log r_1 + B = 0\\A\log r_2 + B=2\pi$$

This gives: $$B=-A\log r_1\\ A=\frac{2\pi}{\log{r_2}-\log {r_1}}$$

So, $$\theta(r)=\frac{2\pi\log\frac r{r_1}}{\log\frac{r_2}{r_1}}$$

The to get $n$ points, just define $r_1=s_0,\dots,s_{n-1}=r_2\in [r_1,r_2]$ with $s_i$ equidistant in $[r_1,r_2]$.

So $s_k=r_1+k\frac{r_2-r_1}{n-1}$ and letting $R=r_2/r_1$, we get $s_k/r_1 = 1+k\frac{R-1}{n-1}$ and therefore $$\theta(s_k)=2\pi\frac{\log\left(1+k\frac{R-1}{n-1}\right)}{\log R}=2\pi\log_R\left(1+k\frac{R-1}{n-1}\right)=2\pi\log_R\frac{s_k}{r_1}$$

The $2\pi$ could, of course, be replaced by any angle to get different "sweeps" of the angle.

If you wanted the points to be equidistant, rather than just equidistant on the curve, that's quite a bit harder.

Related Question