If you connect the centers of two adjacent little circles and the center of the big one, you'll get a triangle. The sides of this triangle have lengths $r+R, r+R$ and $2r$. A little trigonometry will get you that the top angle is
$$\theta=2\arcsin\left(\frac{r}{r+R}\right) \; .$$
Since you want the small circles to form a closed ring around the big circle, this angle should enter an integer amount of times in $360°$ (or $2\pi$ if you work in radians). Thus,
$$\theta=360°/n \; .$$
From this, you can compute that
$$r=\frac{R \sin(180°/n)}{1-\sin(180°/n)} \; .$$
Here's a plot of the result for $n=14$:
Here's the code in Scilab:
n=14;
R=1;
r=R*sin(%pi/n)/(1-sin(%pi/n));
theta=2*%pi*(0:999)/1000;
plot(Rcos(theta),Rsin(theta));
hold on;
for k=0:(n-1),
plot((r+R)*cos(2*k*%pi/n)+r*cos(theta),(r+R)*sin(2*k*%pi/n)+r*sin(theta));
end;
hold off;
Polar integration seems to be the best method for creating a general formula for this.
Re-expressing both circles as polar yields this:
$r1 = 1$ and $r2 = cos\theta+\sqrt(a^2-sin^2\theta)$ based off of the general formula for a polar circle, centered at $(1, 0)$ with radius $a$. Really all we need here are the points of intersection which can easily be solved by setting each equation equal and following algebraic and trigonometric rules
$$cos\theta+\sqrt(a^2-sin^2\theta) = 1$$
$$a^2-sin^2\theta=1+cos^2\theta-2cos\theta$$
Replacing $sin^2$ and $cos^2$ with 1 and solving for theta yields:
$$\theta=\pm arcos(a^2-2/-2)$$
From here it should be noted that we must add $\pi$ to the resulting angle because our result accounts for the part of the circle outside of the central unit circle. So our angles from which we base our integral are
$$\theta = \pi \pm arcos(a^2-2/-2)$$
At this point I believe you can evaluate this regularly
$$.5\int_{\theta_1}^{\theta_2} 1^2-[cos\theta+\sqrt({a^2-sin^2\theta})]^2 \,d\theta$$
There may be some errors I missed in my answer however this general method should work
Best Answer
You already have a formula for finding the center of one of the small circles:
Since you want the small circles all to be the same size and each one is the same distance from each of its neighbors, they will be evenly spaced around the circle. Since one full turn around the circle is the angle
2 * Math.PI
, you want one eighth of that, which is0.25 * Math.PI
. Stepping by that angle around the circle eight times, starting at the first circle, gets you back to the first circle while finding seven other equally-spaced points.The centers of the small circles should be at
where
n
ranges from $0$ through $7$, inclusive ($0 \leq n < 8$). The value $n=0$ is just the center of the first small circle, which you already know.To make a "gap" of size $20$ between each pair of small circles, just set the radius of the small circles accordingly. The distance between centers is
200 * 2 * Math.sin(Math.PI/8)
, subtract $20$ from that for the desired gap, then divide by $2$ to get the desired radius.