# Two circles overlap?

If we have two circles in the plane described by $(x_1, y_1, r_1)$ and $(x_2, y_2, r_2)$ we can determine if they are completely disjoint by simply:

$$(x_1 - x_2)^2 + (y_1 - y_2)^2 < (r_1 + r_2)^2$$

Assume this is not the case, we now want to know if one completely overlaps the other. (That is: if the second circles interior is a subset of the first circles interior.)

If $(x_1, y_1) = (x_2, y_2)$ than we can trivially compare radii, so lets assume their centers are distinct.

The way I have imagined is to create a parametric equation of the line that connects the two centers:

\begin{align} x_p(t) &= x_1 + t(x_2 - x_1) \\ y_p(t) &= y_1 + t(y_2 - y_1) \end{align}

Then we calculate the two line segments (represented as two pairs of t values) where the circles intersect this line. One is a subset of the other if and only if the corresponding circles are subsets of each other.

Is there a simpler approach I am overlooking?

-
Assuming you know the radii, you can also calculate the distance between the centers, and see if that value added to one of the radii is less than the other radius (intuitively, this is giving the point on one circle as far away as possible from the center) –  Clayton Jan 11 '13 at 0:06

The furtherest points between a circle and a point, would be on the line from the point, through the center of the circle.

Hence, circle 1 is contained in circle 2, if and only if circle 2 contains that furtherest point, which implies that

$$r_2 \geq \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2} + r_1$$

As such, one circle will be contained within the other if and only if

$$(r_1-r_2)^2 \geq (x_1-x_2)^2 + (y_1-y_2)^2$$

Note: This approach should be similar to how you show that 2 circles are disjoint (since the 2 nearest points again lie on the line connecting the circles).

-
Yes, it seems obvious now. Thank you. –  Andrew Tomazos Jan 11 '13 at 0:15

Try to draw it and see that the first circle is inside the other if and only if the distance between the centers plus the radius of the first must be less than the radius of the second

-