Circle Intersection Calculator
Circle Intersection Calculator
(x − xc )2 + (y − yc )2 = r2
Write a program that compares two circles to see if they intersect and, if they do, computes the
points of intersection. (There can be 1, 2, or and infinite number of such points).
Input
The input to this program will consist of a pair number of lines. Each two lines represent a intersection
problem. Each line will contain 3 real numbers constituting the xc , yc and r parameters for one circle.
Output
For each problem, the output should be the words ‘NO INTERSECTION’ if the circles do not intersect.
When they have an infinite number of intersection points, the output should be the words ‘THE
CIRCLES ARE THE SAME’
If they do intersect at 1 or 2 points, the output should be a line with one or two pairs, respectively,
of real numbers giving the x and y coordinates of any point of intersection. Pairs must be sorted first
by their x coordinate and when these are equal by the y coordinate.
Each pair is to be printed in parenthesis with numbers accurately rounded to three digits to the
right of the decimal point, as the sample below.
Sample Input
0.0 0.0 1.0
3.0 0.0 1.0
0.0 0.0 1.0
0.0 0.0 1.0
0.0 0.0 1.0
1.0 0.0 1.0
Sample Output
NO INTERSECTION
THE CIRCLES ARE THE SAME
(0.500,-0.866)(0.500,0.866)