0% found this document useful (0 votes)
299 views1 page

Circle Intersection Calculator

The document describes a program that takes input of parameters defining two circles and outputs whether the circles intersect. If they intersect, it outputs the point(s) of intersection rounded to three decimal places. If the circles are the same, it outputs "THE CIRCLES ARE THE SAME". For each problem, it reads three numbers for the x-center, y-center, and radius of each circle and compares them to determine if they intersect.

Uploaded by

Hello mister
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
299 views1 page

Circle Intersection Calculator

The document describes a program that takes input of parameters defining two circles and outputs whether the circles intersect. If they intersect, it outputs the point(s) of intersection rounded to three decimal places. If the circles are the same, it outputs "THE CIRCLES ARE THE SAME". For each problem, it reads three numbers for the x-center, y-center, and radius of each circle and compares them to determine if they intersect.

Uploaded by

Hello mister
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

453 Intersecting Circles

The equation of a circle with radius r and center (xc , yc ) is

(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)

You might also like