Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

N circles around a circle.

by BrowserUk (Patriarch)
on Feb 20, 2017 at 02:41 UTC ( [id://1182323]=perlquestion: print w/replies, xml ) Need Help??

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Perl content: I will be writing a perl script to perform the calculations for any given inner circle size.

Starting with a circle of a supplied size, I want to arrange a given number (usually smaller) circles around the periphery of the given circle such that they all touch central circle and two of the smaller circles either side. Anyone know or have pointers to a formula?

Eg. Given an inner circle of 100 units, and the desire to arrange 8 circles around its periphery, what diameter do the 8 circles need to be so that they just touch the inner circle and each other?

Thanks.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re: N circles around a circle.
by tybalt89 (Monsignor) on Feb 20, 2017 at 03:20 UTC
    sub r_outer { ($R_center * sin( $pi / $n)) / (1 - sin $pi / $n) }

    semi-tested :)

      For the curious, the derivation for this is the same as for this geometry@SE post, except that here, the angle θ is known (θ = 2π/N) and you are trying to solve for r, rather than the other way around.

      Perfect. Thank you.

Re: N circles around a circle.
by choroba (Cardinal) on Feb 20, 2017 at 03:23 UTC
    Reminds me of Circles of Apollonius we did at high school.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1182323]
Approved by beech
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found