Results 1 to 12 of 12

Thread: Packing circles? [Resolved]

  1. #1

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148

    Packing circles? [Resolved]

    Take one Circle radius r

    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.
    Dazzer

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    do you mean r and d or r and n?
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    r and n of course, typo.
    Dazzer

  4. #4

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    Anybody?
    Dazzer

  5. #5
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.
    Have I helped you? Please Rate my posts.

  6. #6
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    or since you want to find radius of little circle, do some of the above calculations backwards, I think this will work.
    Have I helped you? Please Rate my posts.

  7. #7

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    I think you misunderstand,

    One Big circle, radius R

    I want to pack n circles around the inside edge.

    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?
    Dazzer

  8. #8

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    In fact here is diagram to help explain what I want.
    Attached Images Attached Images  
    Dazzer

  9. #9
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    must they always touch the outer circle?
    Have I helped you? Please Rate my posts.

  10. #10

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    yes
    Dazzer

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    right then.. it took me a while to get around to it, but here's the code:
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim n As Integer
    4. Dim r As Double
    5. Dim r1 As Double
    6.  
    7.   'n = 3   '(currently set in loop below)
    8.   r = 2000
    9.  
    10. Dim centre_X As Double
    11. Dim centre_Y As Double
    12.    centre_X = r
    13.    centre_Y = r
    14.    Me.Show
    15.    
    16.  
    17. Const pi = 3.14159265358979         '180°
    18. Const pi2 = 3.14159265358979 * 2    '360°
    19. Const pi_d2 = 3.14159265358979 / 2  ' 90°
    20. Dim radians_per_circle As Double
    21. Dim ang As Double
    22. Dim i As Long
    23. Dim s As Double
    24.    
    25.   For n = 1 To 20
    26.     Me.Cls          'draw outer circle
    27.     Me.Circle (centre_X, centre_Y), r, vbBlack
    28.  
    29.                   'find radians (of outer circle) per inner circle
    30.     radians_per_circle = pi2 / n
    31.  
    32.                   'find radius of inner circle
    33.     s = Sin(radians_per_circle / 2)
    34.     r1 = (r * s) / (s + 1)
    35.    
    36.     For i = 0 To n
    37.       ang = (radians_per_circle * i) - pi_d2
    38.  
    39.       Circle (centre_X + (Cos(ang) * (r - r1)), _
    40.               centre_Y + (Sin(ang) * (r - r1))), _
    41.               r1, _
    42.               vbRed
    43.     Next i
    44.  
    45.     MsgBox n
    46.   Next n
    47.  
    48. 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

  12. #12

    Thread Starter
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    Thanks very much, perfect. Just what the doctor ordered.
    Dazzer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width