From: rusin@washington.math.niu.edu (Dave Rusin) Newsgroups: sci.math Subject: Re: Geometry: Finding Tangent Lines Date: 30 Nov 1996 05:14:35 GMT In article <329B12C3.1775@harc.edu>, Bob Henry wrote: >I am writing a script to find the end points of a line tangent to 2 >circles (open belt). I know the center point and radius of each >circle. Can anyone help me with a simple (the scripting language is not >very robust) formula to find the tangent line. How simple? There are actually four lines tangent to the two circles, two of which you want, and two of which would result from crossing the belt into a figure-8. The four possible slopes can be computed from the coordinates (a,b) and (a2,b2) of the centers of the circles and their radii r and r2 respectively. Two of them are the roots of the quadratic 2 2 2 2 (r - 2 r2 r + r2 - b2 + 2 b b2 - b ) + 2 ( b - b2 )( a - a2 ) m 2 2 2 2 2 + (r - 2 r2 r + r2 - a2 + 2 a a2 - a ) m ; the other two are roots to a similar equation obtained by replacing r2 with -r2. If your scripting language allows for the extraction of square roots, you can solve for m with the quadratic formula; otherwise you'll have to roll your own approximation program (with Newton's method, say). You can then solve for the other necessary data point of the line (e.g. the y-intercept or whatever you wish to use) rationally in terms of a, b, a2, b2, r, r2, _and_ m. It's not particularly interesting. dave ============================================================================== Newsgroups: sci.math From: jedhudson@cix.compulink.co.uk ("John Hudson") Subject: Re: Geometry: Finding Tangent Lines Date: Sun, 1 Dec 1996 17:14:42 GMT Bob Henry wrote on 26/11/96 > I am writing a script to find the end points of a line tangent to 2 > circles (open belt). I know the center point and radius of each > circle. Can anyone help me with a simple (the scripting language is not > very robust) formula to find the tangent line. Sounds like a similar triangles problem. Join the circle centres (spelled centers in USA I am told) and extend the line on the smaller circle side. Extend the tangent until it meets this line. This occurs a distance L from the smaller circle centre and distance M from the point where the tangent touches the smaller circle. If A is the smaller circle radius, B is the larger radius, D is the distance between the centres, then by proportionality (B-A)/D = A/L and L = DA/(B-A) Now ALM is a right angle triange so M^2=L^2+A^2 and M=sqrt(L^2-A^2) If N is the distance between the tangent points on the circles, (the unknown) then again by proportions A/M = (B-A)/N So N = M(B-A)/A = sqrt([DA/(B-A)]^2 - A^2)*(B-A)/A = sqrt(D^2 - (B-A)^2) Having got this simple result it becomes clear that there is a geometrical construction: join the tangent point on the smaller circle to the radius in the larger circle by a line parallel to the line between the centres. This forms a right angle triange with the tangent line and the larger radius. The last equation could be seen straight off without any algebra. Ah well.. To get coordinates, compute L then sin(theta)= A/L. This would allow the angle between the radii to the tangents and the line joining the centres to be determined and hence the coordinates of the tangent points. John