# Find the radius of adjacent small circles moving around a bigger circle

Consider the following figure:

On the left, we have small circles perfectly aligned within a bigger one. The same distance from the center of the big circle and the same radius.

On the right, we make the blue circles closer to the center and the red circles far from the center. They still have the same radius but a little bigger than the previous one to remain adjacent. The movement of the small circles is controlled using an angle $$\theta$$ like illustrated below:

When $$\theta = 0$$ we have the initial configuration where the blue line illustrates the distance between the center of two adjacent circles. The red line illustrates the same distance when $$\theta$$ is different from 0.

The goal is to express the radius of the circles using $$\theta$$. In other words, I need to find the length of the red line (that I will divide by 2 to get the radius). The number of small circles is known so $$\alpha$$ is known. Same for the size of the big circle so the $$R$$ is known.

I also want to know the distance moved by each circle (illustrated by the arrow)

For the context, It's for a HTML/CSS demo I wrote about it here: https://frontendmasters.com/blog/creating-wavy-circles-with-fancy-animations/. I was able to find formulas that seemed to work. I am reviewing them again and I think I made a few mistakes because I am getting overlap between the circles for some values.

An extra question (not mandatory) is to calculate the distance illustrated in green:

The distance between the center of the big circle and the center of the red line (where the small circles touch)

I've done the following Desmos graph, which illustrates the calculation below, as per request I'll write up the answer here as well.

I am going to use the following diagram for reference:

Note that with the above diagram, we have $$\theta = \angle AEC = \angle BED$$ and $$\alpha = \angle AOB$$.

Furthermore, lets denote $$R=\left|OA\right|=\left|OB\right|$$

By the fact that angles in a triangle sum up to $$\pi$$, and the fact that $$AOB$$ is an isosceles triangle, we also have:

$$\angle EOA = \angle EOB = \frac{\alpha}{2} \\\ \angle EAO = \angle EBO = \frac{\pi}{2} - \frac{\alpha}{2} \\ \angle EAC = \pi - \angle EAO = \frac{\pi}{2} + \frac{\alpha}{2} \\ \angle ECA = \pi - \angle EAC - \angle AEC = \frac{\pi}{2} - \frac{\alpha}{2} - \theta \\ \angle BDE = \pi - \angle BED - \angle EBD = \frac{\pi}{2} + \frac{\alpha}{2} - \theta$$

Now, using the definition of $$\sin$$ in the right triangle $$AEO$$ we get

$$\left|AE\right| = \left|OA\right| \sin \left(\frac{\alpha}{2}\right) = R \sin \left(\frac{\alpha}{2}\right)$$

Using the law of sines in triangle $$AEC$$ we get

$$\frac{\left|AE\right|}{\sin \angle ECA} = \frac{\left|AC\right|}{\sin \angle AEC}$$

And from the above, we get

$$\left|AC\right| = R \sin \left(\frac{\alpha}{2}\right) \frac{\sin(\theta)}{\sin\left(\frac{\pi}{2} - \frac{\alpha}{2} - \theta\right)}$$

Similarly, using the law of sines in the triangle $$BED$$ gives

$$\left|BD\right| = R \sin \left(\frac{\alpha}{2}\right) \frac{\sin(\theta)}{\sin\left(\frac{\pi}{2} + \frac{\alpha}{2} - \theta\right)}$$

From here, you can calculate the coordinates of the points $$C$$ and $$D$$, and to find the new radius of the circles you could take half the distance between $$C$$ and $$D$$. Sparing the arduous calculation (involving several trig identities), we get that the radius of the circles is

$$r := R\frac{\sin\left(\frac{\alpha}{2}\right)\cos^{2}\left(\frac{\alpha}{2}\right)\cos\left(\theta\right)}{\cos^{2}\left(\frac{\alpha}{2}\right)\cos^{2}\left(\theta\right)-\sin^{2}\left(\frac{\alpha}{2}\right)\sin^{2}\left(\theta\right)}$$

Note: the denominator could also be written as $$\cos\left(\frac{\alpha}{2}+\theta\right)\cos\left(\frac{\alpha}{2}-\theta\right)$$.

Furthermore, by symmetry around the line $$OA$$ (when including all circles) to prevent overlap of the inner circles, we need to require that the distance from $$D$$ to the line $$OA$$ is greater than $$r$$, again after doing the calculation by hand it turns out that the condition for that is

$$\cos\left(\frac{\alpha}{2}+\theta\right) > \frac{1}{2}$$

which holds (give the constraints of the problem) when

$$0 \leq \theta < \frac{\pi}{3} - \frac{\alpha}{2}$$

Edit:

After doing a bit more work, it appears that we can simplify the expression further into the following (unless I've made some mistake)

$$r=\frac{R\sin\left(\alpha\right)}{4}\left(\frac{1}{\cos\left(\frac{\alpha}{2}+\theta\right)}+\frac{1}{\cos\left(\frac{\alpha}{2}-\theta\right)}\right)$$