# How can I find the points at which two circles intersect?

Given the radius and $x,y$ coordinates of the center point of two circles how can I calculate their points of intersection if they have any?

-
Do you have two circles in mind? This will likely be easier with an example. –  JavaMan Dec 11 '12 at 7:06
for any two circles –  Joe Elder Dec 11 '12 at 7:10

This can be done without any trigonometry at all. Let the equations of the circles be $$(x-x_1)^2 + (y-y_1)^2 = r_1^2, \tag{1}$$ $$(x-x_2)^2 + (y-y_2)^2 = r_2^2. \tag{2}$$ By subtracting the two equations and expanding, we in fact obtain a linear equation for $x$ and $y$; after a little rearranging it becomes $$-2x(x_1 - x_2) - 2y(y_1 - y_2) = (r_1^2 - r_2^2) - (x_1^2 - x_2^2) - (y_1^2 - y_2^2).$$ (If the circles intersect, this is the equation of the line that passes through the intersection points.) This equation can be solved for one of $x$ or $y$; let's suppose $y_1 - y_2 \ne 0$ so that we can solve for $y$: $$y = -\frac{x_1 - x_2}{y_1 - y_2} x + \dotsc. \tag{3}$$ Substituting this expression for $y$ into $(1)$ or $(2)$ gives a quadratic equation in only $x$. Then the $x$-coordinates of the intersection points are the solutions to this; the $y$-coordinates can be obtained by plugging the $x$-coordinates into $(3)$.

-

Let $C_1 = (x_1,y_1), C_2 = (x_2,y_2)$ be the centers of the two circles and $r_1,r_2$ be their radii respectively.

Their equations are $$(x-x_1)^2 + (y-y_1)^2 = r_1^2$$ $$(x-x_2)^2 + (y-y_2)^2 = r_2^2$$

They intersect only iff $|r_1-r_2|\leq|C_1-C_2|\leq|r_1+r_2|$, where $|C_1-C_2|$ is the distance between the two centers. If equality holds, the circles touch and there is one solution. For strict inequalities, they intersect and they have two solutions.

Just solve the system of equations. Suppose that $x_0$ is a point on the first circle. Then, its parametric representation is $x_0 = (x_1+r_1\cos\theta,y_1+r_1\sin\theta)$ for some $\theta$. If $x_0$ also lies on the second circle, which will make it a point of intersection, it must also satisfy the equation of the second circle i.e. $$(x_0-x_2)^2 + (y_0-y_2)^2 = r_2^2$$ Substitute the parametric form, and find out the value(s) of $\theta$.

-

Example 1: Find the points of intersection of the circles given by their equations as follows:

$(x - 2)^2 + (y - 3)^2 = 9$

$(x - 1)^2 + (y + 1)^2 = 16$

Solution to Example 1:

We first expand the two equations as follows:

$x^2 - 4x + 4 + y^2 - 6y + 9 = 9$

$x^2 - 2x + 1 + y^2 + 2y + 1 = 16$

Multiply all terms in the first equation by -1 to abtain an equivalent equation and keep the second equation unchanged

$-x^2 + 4x - 4 - y^2 + 6y - 9 = -9$

$x^2 - 2x + 1 + y^2 + 2y + 1 = 16$

We now add the same sides of the two equations to obtain a linear equation

$2x - 3 + 8y - 8 = 7$

Which may written as

$x + 4y = 9 \textbf{ or } x = 9 - 4y$

We now substitute $x$ by $9 - 4y$ in the first equation to obatin

$(9 - 4y)^2 - 4(9 - 4y) + 4 + y^2 - 6y + 9 = 9$

Which may be written as

$17y^2 -62y + 49 = 0$

Solve the quadratic equation for y to obtain two solutions

$y = \frac{(31 + 8\sqrt{2})}{17} \approx 2.49$

and $y =\frac{31 - 8\sqrt{2}}{17} \approx 1.16$

We now substitute the values of y already obtained into the equation $x = 9 - 4y$ to obtain the values for x as follows

$x = \frac{29 + 32\sqrt{2}}{ 17} \approx - 0.96$

and $x = \frac{29 - 32\sqrt{2})}{17} \approx 4.37$

The two points of intersection of the two cirlces are given by

$(- 0.96 , 2.49)$ and $(4.37 , 1.16)$

-

You can to use this solution in JAVA code, in this solution is used the mathematical expresion which was upper descrbed: http://ideashare.net/java/check-if-circle-is-intersect-to-another-circle/

-