出处:http://fypandroid.wordpress.com/2011/07/03/how-to-calculate-the-intersection-of-two-circles-java/
Let’s say you’re trying to find the intersection points of the circles C1 and C2 where C1 has it’s center point at (-9, 1) and has a radius of 7, and C2’s center lies at (5, -5) and has a radius of 18.
Note that I posted the image to make clear what the variables names in the formula’s are.
First calculate the distance, ‘d’, between the center-points of the two circles:
- d = √(|-9 – 5| + |1 – -5|)
- = 15.23
Now we calculate ‘d1′:
- d1 = (r1^2 – r2^2 + d^2) / 2*d
- = (7^2 – 18^2 + 15.23^2) / 2*15.23
- = (49 – 324 + 231.95) / 30.46
- = -43.05 / 30.46
- = -1.41
Now we solve ‘h’, which is 1/2 * ‘a’
- h = √(r1^2 – d1^2)
- = √(7^2 – -1.41^2)
- = √(49 – 1.99)
- = 6.86
To find point P3(x3,y3) which is the intersection of line ‘d’ and ‘a’ we use the following formula:
- x3 = x1 + (d1 * (x2 – x1)) / d
- = -9 + (-1.41 * (5 – -9)) / 15.23
- = -10.29
- y3 = y1 + (d1 * (y2 – y1)) / d
- = 1 + (-1.41 * (-5 – 1)) / 15.23
- = 1.55
Last but not least, calculate the points P4_i and P4_ii which are the intersection points of the two circles:
- x4_i = x3 + (h * (y2 – y1)) / d
- = -10.29 + (6.86 * (-5 – 1)) / 15.23
- = -12.99
- y4_i = y3 – (h * (x2 – x1)) / d
- = 1.55 – (6.86 * (5 – -9)) / 15.23
- = -4.75
- x4_ii = x3 – (h * (y2 – y1)) / d
- = -10.29 – (6.86 * (-5 – 1)) / 15.23
- = -7.59
- y4_ii = y3 + (h * (x2 – x1)) / d
- = 1.55 + (6.86 * (5 – -9)) / 15.23
- = 7.86
So, as you can see, the intersection points are (-12.99, -4.75) and (-7.59, 7.86)
Reference
http://bytes.com/topic/java/answers/645269-circle-circle-intersection-more