I want to fit n circles of the same radius (r1) along the inside edge of that circle so that each inner circle touches the next. (much like an old style dialing telephone).
How do i compute the radius r1 from the two values r and d.
Last edited by darrenl; Mar 26th, 2004 at 10:46 AM.
try this:
let's say the big circle has a diameter of 10cm.
and the little on have a radius of 1cm.
draw the big circle, then a smaller circle inside it with 4cm radius ( (10/2)-1 ).
This line will go through the centres of all the smaller circles. Then find the length of this circumferencde, on divide it by the diameter of the smaller circles. This should find the number of smaller circles taht can fit in.
I need to calculate the optimum radius of the smaller circles so that I can pack them inside the edge of the large circle.
If the radius of the large circle is 10cm and I have to pack 2 circles inside of it, then the radius of the little circles is 10/2=5, but this does not work for packing 3,4,5,6,7,8.....
is there an equation for this, or do I have to iteratively suck and see?
right then.. it took me a while to get around to it, but here's the code:
VB Code:
Private Sub Form_Load()
Dim n As Integer
Dim r As Double
Dim r1 As Double
'n = 3 '(currently set in loop below)
r = 2000
Dim centre_X As Double
Dim centre_Y As Double
centre_X = r
centre_Y = r
Me.Show
Const pi = 3.14159265358979 '180°
Const pi2 = 3.14159265358979 * 2 '360°
Const pi_d2 = 3.14159265358979 / 2 ' 90°
Dim radians_per_circle As Double
Dim ang As Double
Dim i As Long
Dim s As Double
For n = 1 To 20
Me.Cls 'draw outer circle
Me.Circle (centre_X, centre_Y), r, vbBlack
'find radians (of outer circle) per inner circle
radians_per_circle = pi2 / n
'find radius of inner circle
s = Sin(radians_per_circle / 2)
r1 = (r * s) / (s + 1)
For i = 0 To n
ang = (radians_per_circle * i) - pi_d2
Circle (centre_X + (Cos(ang) * (r - r1)), _
centre_Y + (Sin(ang) * (r - r1))), _
r1, _
vbRed
Next i
MsgBox n
Next n
End Sub
basic explanation:
In the outer circle there are 2*pi radians, this is divided equally for each of the inner circles (radians_per_circle), each basically forming a "triangle" (not strictly true for small values of n).
If you divide each of these triangles into 2, you can use standard trig. (treating r1 as the 'opposite', and r-r1 as the hypotenuese (sp?)) to get this formula:
r1 = sin(radians_per_circle/2) * (r - r1)
which can be rearranged...
=> r1 = sin(radians_per_circle/2) * r - sin(radians_per_circle/2) * r1
=> r1 + r1 * sin(radians_per_circle/2) = sin(radians_per_circle/2) * r
=> r1 * (1 + sin(radians_per_circle/2)) = sin(radians_per_circle/2) * r
..to this:
=> r1 = (sin(radians_per_circle/2) * r) / (sin(radians_per_circle/2) + 1)
which is what I used above.
It's not 100% accurate, but I think it's close enough