2

I’m building a radial menu in a game engine (Unity). I need to place my menu items in a “carousel”. So, I need to know the size/scale of my items to fit nicely on a circle, forming a circular menu, laying close to each other and covering the whole outer circle. In other words, how many small circles can I put ON a circumference of another, say a unit circle, where center of those smaller circles lays on the circumference. Or, in yet another words, simply put, say given the size of a ball bearing, how many balls fit inside? Whats the math finding the size/radius of those small circles?

Edited: I actually needed the r and not the n, so the final equation is indeed enter image description here and the code looks like this: enter image description here

Gusto
  • 123
  • 4
  • 1
    It might be easier to figure out if you want to put $n$ circles what the radius of those circles would be. Then take the inverse of that function and figure out give the radius how many you can fit. If you fit $n$ circles (assuming $n \ge 4$) you want each circle to span an arch of $\frac {360}n$ and thus it becomes a simply trig problem. The radius of the small circle will be the short leg of a right triangle where the radius of the big circle is the longer leg. The angle of this right triangle is $\frac {\frac {360}n}2=\frac {180}n$. – fleablood Jan 07 '22 at 20:13
  • it turned out I needed actually to find out the radius of a small circle "r" and not the number of circles "n", so I chosen the @Woody3 answer to be the closest since he came up with the equation of finding the "r" – Gusto Jan 07 '22 at 21:38

3 Answers3

4

Consider three tangent circles of radii $r$, $r$ and $1$ (WLOG). The centers form an isoceles triangle of sides $r+r$, $1-r$ and $1-r$. The small angle is

$$\theta= 2\arcsin\frac{r}{1-r}=\frac{2\pi}{n}$$ for $n$ small circles, and

$$r=\frac1{\csc\dfrac\pi n+1}\approx\frac\pi{\pi+n}.$$

The exact formula works as of $n=2$.

enter image description here

  • The final c# unity code looks like this: int n = ItemList.Count; float R = _menuRadius; float r = R / (1f / (Mathf.Sin(Mathf.PI / n)) + R) * 2f; – Gusto Jan 07 '22 at 21:33
2

It might be easier to figure out if you want to put $n$ circles what the radius of those circles would be. Then take the inverse of that function and figure out give the radius how many you can fit. If you fit $n$ circles (assuming $n \ge 4$) you want each circle to span an arch of $\frac {360}n$ and thus it becomes a simply trig problem. The radius of the small circle will be the short leg of a right triangle where the radius of the big circle is the longer leg. The angle of this right triangle is $\frac {\frac {360}n}2=\frac {180}n$.

So if $n$ is the number of circles. $R$ is the radius of the big circle and $r$ is the radius of the small circle we have the following relations.

$\frac {r}{R} = \frac {\sin \frac {180}n}{\cos \frac {180}n} = \tan\frac {180}n$ so

$n = \lfloor \frac {180}{\arctan \frac Rr}\rfloor$

fleablood
  • 124,253
1

Here's an approximate calculation that will work if the ball bearings have radius $r$ much less than $1$.

The the center of each ball bearing will be at distance $1-r$ from the center of the unit circle. Those centers will lie on a concentric circle with circumference $2\pi(1-r)$ and will cover a little bit less than $2r$ of that circumference. So you will be able to fit $\pi(1-r)/r$ ball bearings.

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199