65
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ Do you have two circles in mind? This will likely be easier with an example. $\endgroup$
    – JavaMan
    Dec 11, 2012 at 7:06
  • 6
    $\begingroup$ for any two circles $\endgroup$
    – Joe Elder
    Dec 11, 2012 at 7:10
  • 1
    $\begingroup$ I've just been working on this idea myself... $\endgroup$
    – Rhodie
    Nov 27, 2018 at 22:58

9 Answers 9

59
$\begingroup$

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 $(2)$ from $(1)$ and then 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)$.

$\endgroup$
2
  • $\begingroup$ When you say by subtracting the two equations? Do you mean from each other? $\endgroup$
    – smac89
    Apr 6, 2016 at 16:11
  • 1
    $\begingroup$ I'm sure this is a correct answer, but it's like a teaser for an actual solution. "By subtracting (2) from (1)" - show me. "then expanding" - show me. "linear" in italics - why, what's the significance of that? "After a little rearranging" - show me. "+ ..." in (3) - show me, I've no idea what's meant to be there. It's the perfect example of why maths can often be a struggle for some - all the assumed knowledge, understanding, and unexplained mental leaps. $\endgroup$
    – stephent
    Oct 23, 2023 at 4:35
40
$\begingroup$

Easy solution is to consider another plane such that the centers are along an axis.

Given the points $(x_1,y_1)$ and $(x_2,y_2)$. We focus on the center point of both circles given by $$ \left( \frac{x_1+x_2}{2}, \frac{y_1+y_2}{2} \right). $$

The distance between the centers of the circles is given by $$ R = \sqrt{ (x_2-x_1)^2 + (y_2-y_1)^2}. $$

We can consider the following orthogonal vectors $$ \vec{a} = \left( \frac{x_2-x_1}{R}, \frac{y_2-y_1}{R} \right), \vec{b} = \left( \frac{y_2-y_1}{R}, - \frac{x_2-x_1}{R} \right). $$

a b coordinate plane

In the $(\vec{a},\vec{b})$ plane we get the equations $$ \big( a + R / 2 \big)^2 + b^2 = r_1^2,\\ \big( a - R / 2 \big)^2 + b^2 = r_2^2. $$

Whence $$ a = \frac{r_1^2 - r_2^2}{2R},\\ b = \pm \sqrt{ \frac{r_1^2+r_2^2}{2} - \frac{(r_1^2-r_2^2)^2}{4R^2} - \frac{R^2}{4}}. $$ The intersection points are given by $$ (x,y) = \frac{1}{2} \big( x_1+x_2, y_1+y_2 \big) + \frac{r_1^2 - r_2^2}{2R^2} \big( x_2-x_1, y_2-y_1 \big)\\ \pm \frac{1}{2} \sqrt{ 2 \frac{r_1^2+r_2^2}{R^2} - \frac{(r_1^2-r_2^2)^2}{R^4} - 1} \big( y_2-y_1, x_1-x_2 \big), $$ where $R$ is the distance between the centers of the circles.  

$\endgroup$
6
  • 2
    $\begingroup$ A new user has some questions about this, can't comment here. Can you help him please? math.stackexchange.com/questions/1899322/… $\endgroup$
    – iamvegan
    Aug 21, 2016 at 20:12
  • 1
    $\begingroup$ It would be helpful to include a geogebra sketch of this solution. I have trouble visualizing it also. $\endgroup$ Aug 21, 2016 at 21:20
  • 7
    $\begingroup$ Wrote some JS code that implements this. Should be easy to port to other languages: gist.github.com/jupdike/bfe5eb23d1c395d8a0a1a4ddd94882ac $\endgroup$ Jan 12, 2017 at 21:10
  • $\begingroup$ in the scenario where two circles overlap , do you express this R=0 condition? $\endgroup$ Oct 5, 2019 at 21:50
  • 2
    $\begingroup$ There is only one plane in $\mathbb{R^2}$, and this is $\mathbb{R^2}$. What you do is the change of the coordinate plane or coordinate system. $(\vec{a},\vec{b})$ do not define a coordinate plane you additionally need an origin which should be $\left( \frac{x_1+x_2}{2}, \frac{y_1+y_2}{2} \right)$, I think. You do not explain what a and b is, and why they satisfy these equations. To deduce the final equation one dos not need a complicate concept like transformation of coordinate systems, that is simple analytic geometry, For me this answer needs a lot of improvements $\endgroup$
    – miracle173
    Jun 16, 2021 at 2:31
21
$\begingroup$

A nice way to look at this is to first consider the case when the center of one circle is at the origin and the center of other lies on the x-axis. Let the centers be at $(0,0)$, $(d,0)$ and the radii be $r_1$, $r_2$. The two equations simplify to $$x^2+y^2=r_1^2$$ and $$(x-d)^2+y^2=r_2^2$$ Use the first to find $y^2$ and substitute in the second. $$(x-d)^2+r_1^2-x^2=r_2^2$$ expand and simplify $$-2xd+d^2+r_1^2=r_2^2$$ so the points of intersections are $(x,y), (x,-y)$ with $$x=\frac{r_1^2-r_2^2+d^2}{2d}$$ and from Pythagorus $$y=\sqrt{r_1^2-x^2}.$$ This part came from mathworld.

For the general position case with centers $(x_1,y_1)$ $(x_2,y_2)$. Let $$\begin{align} d&=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\\ l&=\frac{r_1^2-r_2^2+d^2}{2d}\\ h&=\sqrt{r_1^2-l^2} \end{align}$$ General position Now $\left(\tfrac{x_2-x_1}{d},\tfrac{y_2-y_1}{d}\right)$ $\left(\tfrac{y_2-y_1}{d},-\tfrac{x_2-x_1}{d}\right)$ are two orthogonal unit vectors and we can rotate and translate to get the general solution $$\begin{align} x&=\frac{l}{d}(x_2-x_1) \pm \frac{h}{d}(y_2-y_1) + x_1,\\ y&=\frac{l}{d}(y_2-y_1) \mp \frac{h}{d}(x_2-x_1) + y_1.\\ \end{align}$$

$\endgroup$
2
  • 1
    $\begingroup$ I like this solution a lot, due to its geometric meaning. The interpretation is clear once a diagram is made. I suggest either a diagram or some text such as the following should be included: $\endgroup$ Feb 23 at 21:32
  • 1
    $\begingroup$ I like this solution a lot, due to its geometric meaning. The interpretation is clear once a diagram is made. I suggest either a diagram or some text such as the following should be included: 1. Change "... one point is at the origin and the other lies on the x-axis." to "one circle is centered at the origin and the other on the x-axis." 2. The two points of intersection have the same x-value. [This for the first case.] 3. Here l and h are the rotated versions of x and y from the special case above. $\endgroup$ Feb 23 at 21:40
5
$\begingroup$

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$.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks. I used this way. A useful formula to find out $\theta$ is $a\cos\theta+b\sin\theta = \sqrt{a^2+b^2}\,\cos\bigl(\theta - \text{atan2}(b,a)\bigr)$. $\endgroup$ Dec 16, 2019 at 17:38
5
$\begingroup$

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 circles are given by

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

$\endgroup$
1
4
$\begingroup$

After going through most of the answers posted here, I still struggled implementing them. After much searching around I found this page: http://www.ambrsoft.com/TrigoCalc/Circles2/circle2intersection/CircleCircleIntersection.htm

It includes extensive notation on every part of the equation as well as drawings, a calculator and JavaScript implementation. Hope it can help others.

$\endgroup$
2
1
$\begingroup$

Make equations of circles both start with $ x^2 +y^2,$ subtract one from the other to get equation of its radical axis which is a straight line. Intersection of this radical axis and one of the circles can be found by plugging in for x or y of one circle into the other.

EDIT1

If the discriminant of this quadratic equation that is the real guide is $(>0,0,<0)$ then the intersections are respectively $ (2, 2$ coinciding points at tangent,2) in number which are the required ( real,real,complex) points.

$\endgroup$
0
$\begingroup$

By first applying coordinate transformations a reduced algebra solution is possible. Given Circle (x1,y1,R) and Circle (x2,y2,P) find the two intersection points of the circles. Define d=distance(C1,C2). There are multiple conditions for Zero and One intersection points. Here we assume two points thus d<P+R, d+P>R, and d-P>-R.

  1. Translate to place (x1,y1) at the origin.
  2. Rotate to place (x2,y2) at (0,d) where d=distance(C1,C2).
  3. $Y=(R^2-P^2+d^2)/2d$ see figure and derivation below
  4. $X=\sqrt{R^2-Y^2}$
  5. $$xy=\begin{bmatrix}+X & Y \\-X & Y \\\end{bmatrix} $$ Two solution points in transformed space
  6. $theta=atan2(x2-x1,y2-y1)$ A Matlab quadrant atan where -pi<atan2()<=pi See below
  7. xy=xy*rot(theta)+[x1 y1] where $$rot(t)=\begin{bmatrix}cos(t) & -sin(t)\\ sin(t) & cos(t)\\\end{bmatrix}$$

In the transformed space, see figure, many simplifications occur. $R^2=X^2+Y^2$, $P^2=X^2+(d-Y)^2$ after subtraction gives $R^2-P^2=Y^2-(d-Y)^2$ = $Y^2-d^2+2dY-Y^2$=$2dY-d^2$ thus $Y=(R^2-P^2+d^2)/2d$. Substitution of Y into the first equation yields $X=\sqrt{R^2-Y^2}$ De-Rotate and de-translate to see the points in the original coordinate system. Circles in Transformed Space

The atan2 function as used with (dx,dy) gives the rotation angle from the +Y-axis.

function theta=atan2(dx,dy)
 if dx==0
  if dy>0
   theta=0;
  else
   theta=pi;
  end
 elseif dy==0
  if dx>0
   theta=pi/2;
  else
   theta=-pi/2;
  end
 elseif dx>0
  if dy>0
   theta=atan(dx/dy);
  else
   theta=pi+atan(dx/dy);
  end
 elseif dx<0
  if dy>0
   theta=atan(dx/dy);
  else
   theta=atan(dx/dy)-pi;
  end
 end % if
end % theta=atan2(dx,dy)
$\endgroup$
1
-3
$\begingroup$

following the very nice hint of arkeet you can after defining a,b,c,g,h using rc1,zc1,rc2,zc2, as the center point of the circles and R1 and R2 their radii and assuming that rc2!=rc1 (the case where rc2=rc1 can be also done in the manner or arkeet, however the present assumption was useful to me)

g = (zc2 - zc1)/(rc2 - rc1); h = (R1*R1-R2*R2 + zc2*zc2 - zc1*zc1 + rc2*rc2 - rc1*rc1 )/(2*(rc2 - rc1));

a = (g*g+ 1); b = -2*g*h + 2*g*rc1 - 2*zc1; c = h*h -2*h*rc1 + rc1*rc1 + zc1*zc1 - R1*R1;

zplus = (-b +sqrt(b*b-4*a*c)) / (2*a); zminus = (-b -sqrt(b*b-4*a*c)) / (2*a); and rplus = -gzplus+h; rminus = -gzminus+h;

you can test this by verifying that the intersection points do lie on the 2 circles.

$\endgroup$
1
  • 2
    $\begingroup$ As written this is very hard to read. Please look over this guide to formatting mathematics (it is very Latex like if you are familiar with that): meta.math.stackexchange.com/questions/5020/… The reference has essentially everything you could want. The first few lines or a paragraph or two should be enough to get you running nicely on this site. $\endgroup$
    – TravisJ
    Jul 20, 2015 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .