# Circle-Circle Intersection¶

You are given two circles on a 2D plane, each one described as coordinates of its center and its radius. Find the points of their intersection (possible cases: one or two points, no intersection or circles coincide).

## Solution¶

Let's reduce this problem to the circle-line intersection problem.

Assume without loss of generality that the first circle is centered at the origin (if this is not true, we can move the origin to the center of the first circle and adjust the coordinates of intersection points accordingly at output time). We have a system of two equations:

Subtract the first equation from the second one to get rid of the second powers of variables:

Thus, we've reduced the original problem to the problem of finding intersections of the first circle and a line:

And this problem can be solved as described in the corresponding article.

The only degenerate case we need to consider separately is when the centers of the circles coincide. In this case $x_2=y_2=0$, and the line equation will be $C = r_1^2-r_2^2 = 0$. If the radii of the circles are the same, there are infinitely many intersection points, if they differ, there are no intersections.