Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CrazedGenius

Tangent to two circles

This topic is 5283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone point me to a bit of source code that can easily compute the segment that is tangent to two circles? I can probably brute force it, but I figured I''d check to see if anyone has a quick pointer to an elegant solution. (I know how to do it geometrically, I''m looking for a simple function). thanks.

Share this post


Link to post
Share on other sites
Advertisement
How is the segment that is tangent to two circles not perpendicular to the segment connecting their radii? ^^ That's about as close to source code as I get to writing, sorry.

[edited by - uber_n00b on May 28, 2004 2:15:18 AM]

Share this post


Link to post
Share on other sites
not sure what you mean by "segment connecting their radii". The proper segments will be perpendicular to some specific radial lines (that the definition...). The trick is to figure out *which* radii...

Share this post


Link to post
Share on other sites
Well only one segment formed by their two radii will be a line segment (namely the segment that connects the centers of the circles). Better?

Share this post


Link to post
Share on other sites
hmmm...

I''m not sure that you understand what I mean - lines going through the center will not be tangent. Related to your first response; there will be two tangents, they are neither parallel to each other nor parallel to the connecting line unless you''re talking about the special case of the two circles having the same radius. I''m asking for a general solution.

Share this post


Link to post
Share on other sites
I am fairly sure I did not misunderstand you. Here is a drawing of my interpretation of your question: http://www.geocities.com/vsage3/bored.JPG
Am I wrong?

Edit: there are three such segments. Do you need equations for the other two that aren't shown in my picture? I asked a trusted friend about your question and she replied something similar.

[edited by - uber_n00b on May 29, 2004 1:06:10 AM]

Share this post


Link to post
Share on other sites
Ah, THOSE tangents. So many common tangents.. Yes those were the other two. Now that I mention it there are more.. 7?! Anyway No matter. I'm just about done with the equation gimme a minute. Ok I sketched it out and here's the result:

Let P = asin((R2-R1) / Distance Between Centers)

The endpoints of the segment are therefore (x1-R1*sin(P)), y1+R1*cos(P)) and (x2-R2*sin(P), y2+R2*cos(P))

where the center of circle 1 of radius R1 is (x1, y1) and the center of circle 2 of radius R2 is (x2, y2)

I did make the assumption R2 >= R1. Oops on me. (I simplified it from the previous post)


[edited by - uber_n00b on May 29, 2004 1:29:11 AM]

Share this post


Link to post
Share on other sites
I hope so ^^. I''ll switch my major next year to English if it doesn''t (I screwed up the formula the first time I posted it so I hope you''re using the one posted now)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!