Tangent to two circles
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.
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]
[edited by - uber_n00b on May 28, 2004 2:15:18 AM]
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...
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?
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.
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.
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]
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]
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]
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]
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)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement