søndag den 22. april 2012

The Intersection of Two Circles

Two circles in a plane intersect in zero, one, two, or infinitely many points. The latter case occurs only in the case of two identical circles. The first case (zero points of intersection) occurs whenever the distance between the centers of the circles is greater than the sum of the radii or the distance between the center is less than the absolute value of the difference in their radii.
Problem: Give the general solution to this question:


Find the coordinates of the two (possibly equal) points of intersection of two non-concentric circles, A, and B, whose centers are (xA,yA) and (xB,yB) and whose radii are rA and rB. You may assume there is at least one point of intersection. In other words, you may assume the distance between the centers of the circles lies between the absolute value of the difference of their radii and the sum of their radii, inclusive.
Solution:


In this diagram, I have used the example in which circle A is red, centered at (-9,1) with a radius of 7, and circle B is green, centered at (5,-5) with a radius of 18. C is the midpoint of A and B. E and F are the intersections of the two circles, and D is the midpoint of E and F.



Let d be the distance between A and B, the centers of the two circles.


d = sqrt((xB-xA)2+(yB-yA)2)


Let K be the area of the triangle ABE. The lengths of the sides of this triangle are d, rA, and rB. Heron's Formula tells us


K = (1/4)sqrt((d+rA+rB)(-d+rA+rB)(d-rA+rB)(d+rA-rB))


By regrouping the four factors inside the square root, we get the area of the triangle in terms of d2 rather than in terms of d, and this is computationally easier:


K = (1/4)sqrt(((rA+rB)2-d2)(d2-(rA-rB)2))


C ((xB+xA)/2, (yB+yA)/2) is the midpoint between the centers of the circles.


D is the midpoint between the two points of intersection of the circles.


We will consider AB the "base" of triangle ABE, and DE the "height" of the triangle. Point D divides the base into two segments, AD, and DB, whose signed lengths will be dA and dB, where dA+dB=d. (The context in which I use signed distances is very narrow. By "signed" I mean only that distances measured along line AB from A to B are considered "positive" and distances in the other direction are considered "negative".)


Note the following facts, where all distances are signed:


CA+CB = 0, because C is the midpoint of A and B

dA-dB = AD-DB = AD+BD = (CA+AD)+(CB+BD) = CD+CD, so

CD = (1/2)(dA-dB)


By Pythagoras, we have rA2-dA2 = rB2-dB2, so


rA2-rB2 = dA2-dB2 = (dA+dB)(dA-dB) = d(dA-dB) = 2d(CD)


This way, the signed length, CD, which is negative in the diagram, is given by


CD = (1/2)(rA2-rB2)/d


The ratio of change in the x-coordinate to signed distance along line AB is (xB-xA)/d, and the ratio of change in the y-coordinate to signed distance along this line is (yB-yA)/d. From this we can calculate the coordinates of point D:


xD = xC + (1/2)(rA2-rB2)/d * (xB-xA)/d = (1/2)(xB+xA) + (1/2)(xB-xA)(rA2-rB2)/d2

yD = yC + (1/2)(rA2-rB2)/d * (yB-yA)/d = (1/2)(yB+yA) + (1/2)(yB-yA)(rA2-rB2)/d2


Did you wonder when we would make use of K, the area of triangle ABE? Well, your wait is over!


K = (1/2)(AB)(DE)

DE = 2K/(AB) = 2K/d = (1/2)sqrt(((rA+rB)2-d2)(d2-(rA-rB)2))/d


Line

Ingen kommentarer:

Send en kommentar