#### Archived

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

# Tangent to two circles

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

## 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 on other sites
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 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 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 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 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 on other sites
ah - I wasn''t totally clear. picture a bicycle chain - I need those two tangents.

##### 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 on other sites
Fantastic. I''ll try it, but it looks like what I thought it would look like. Many thanks!

##### 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)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 13
• 13
• 9
• 25
• ### Forum Statistics

• Total Topics
634449
• Total Posts
3017510
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!