How to calculate the intersection points of two circles?

Circle-circle interection points

The aim of this page is to calculate the coordinates on the intersection points between two circles \( C_1 \) and \( C_2 \).

Here are our hypotheses:

Our goal is to calculate the coordinates of the intersection points \( P_3 \) and \( P_4 \) as a function of \( P_1 \), \( P_2 \), \( r_1 \) and \( r_2 \).

Intermediate steps

Intermediate steps for calculating the circle-circle intersection

Here are the intermediate steps for computing the intersection points:

  1. Calculating the distance \( d \) between circle centers
  2. Checking cases
  3. Calculating the length of \( a \) and \( b \)
  4. Calculation of h
  5. Calculating the coordinates of \( P_5 \)
  6. Calculation of vectors \( \overrightarrow{P_5P_3} \) and \( \overrightarrow{P_5P_4} \)
  7. calculating the coordinates of \( P_3 \) and \( P_4 \)

Distance between centers

Let's start by calculating the \( d \), the distance between the centers. By applying the Pythagorean theorem we can write:

$$ d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 } \label{eq:d} $$

Checking cases

According to the values of \( d \), we now have five cases:

\( d > r_1 + r_2 \) \( d < \lvert r_1 - r_2 \rvert \)
Circles are too far apart and do not intersect One circle is inside the other and do not intersect
\( d = 0 \) and \( r_1 = r_2 \) \( d = r_1 + r_2 \)
Circles are merged and there are an infinite number of points of intersection There is a single intersection point

Calculating a and b

To calculte the distance \(a\) let's start by writing \( h \) as a function of \( a \) and \( b \) . In the right triangles \( P_1 P_5 P_3 \) the Pythagorean theorem gives:

$$ r_1^2 = h^2 + a^2 \label{eq:h1} $$

We can apply the theorem in the right triangle \( P_2 P_5 P_3 \):

$$ r_2^2 = h^2 + b^2 \label{eq:h2} $$

By substituting \eqref{eq:h2} to \eqref{eq:h1} we get the following equation:

$$ r_1^2 - r_2^2 = a^2 - b^2 \label{eq:ab} $$

Since \( d = a +b \), we can write the folowing system of two equations:

$$ \left\{ \begin{split} & r_1^2 - r_2^2 = a^2 - b^2 \\ & d = a +b \end{split} \right. $$

By injecting \( b = d-a \) in equation \eqref{eq:ab}, we obtain the following relation:

$$ r_1^2 - r_2^2 = a^2 - (d-a)^2 $$

The \( –a^2 \) terms on each side cancel out. You can then solve for \( a \):

$$ \begin{split} r_1^2 - r_2^2 &= a^2 - d^2 - a^2 + 2ad \\ r_1^2 - r_2^2 &= - d^2 + 2ad \\ 2ad & = r_1^2 - r_2^2 + d^2 \end{split}$$

We get :

$$ a = \dfrac{r_1^2 - r_2^2 + d^2 }{2d} $$

Similarly in the triangle \( P_2 P_5 P_3 \) :

$$ b = \dfrac{r_2^2 - r_1^2 + d^2 }{2d} $$

All of these values are known:

Calculation of h

Once \( a \) and \( b\) are know, it becomes easy to calculate the length \( h \) by apoplying the Pythagorean theorem in the right triangles \( P_1 P_5 P_3 \)

$$ r_1^2 = h^2 + a^2 $$

$$ h = \sqrt{ r_1^2 - a^2 }$$

Coordinates of P5

The next step is to calculate the coordinates of \( P_5 \).

Calculate the coordinates of P5

Since the vectors \( \vec{P_1P_5} \) and \( \vec{P_1P_2}) \ are colinear, we can write:

$$ \vec{P_1P_5} = \dfrac{a}{b} \times \vec{P_1P_2} $$

We can deduce the coordinates of \( P_5 \):

$$ \begin{split} x_5 &= x_1 + \dfrac{a}{d} \times (x_2 - x_1) \\ y_5 &= y_1 + \dfrac{a}{d} \times (y_2 - y_1) \end{split} $$

Vectors P5P3 and P5P4

The second to last step is the calculation of vectors \( \overrightarrow{P_5P_3} \) and \( \overrightarrow{P_5P_4} \) . Let's consider the vector \( \overrightarrow{P_1P_2} \) given by the following relation:

$$ \overrightarrow{P_1P_2} = \begin{pmatrix} x_2 - x_1 \\ y_2 - y_1 \end{pmatrix} $$

By multiplying this vector by a rotation matrix around the z-axis, we can calculate the perpendicular vectors:

Clockwise

$$ \overrightarrow{P_1P_2}^{\bot \circlearrowright} = \begin{pmatrix} 0 && 1 \\ -1 && 0 \end{pmatrix} \times \begin{pmatrix} x_2 - x_1 \\ y_2 - y_1 \end{pmatrix} = \begin{pmatrix} y_2 - y_1 \\ x_1 - x_2 \end{pmatrix} $$

Counterclockwise

$$ \overrightarrow{P_1P_2}\ {}^{\bot \circlearrowleft} = \begin{pmatrix} 0 && -1 \\ 1 && 0 \end{pmatrix} \times \begin{pmatrix} x_2 - x_1 \\ y_2 - y_1 \end{pmatrix} = \begin{pmatrix} y_1 - y_2 \\ x_2 - x_1 \end{pmatrix} $$

We already calculated the norm of vector \( \lVert \vec{P_1P_2} \rVert = d \) and norm of vectors \( \lVert \vec{P_5P_3} \rVert = \lVert \vec{P_5P_4} \rVert = h \).

By applyting the ratio \( \frac{h}{d} \) to the vectors \( \overrightarrow{P_1P_2}^{\bot} \) we can deduce the expressions of vectors \( \overrightarrow{P_5P_3}^{\bot} \) and \( \overrightarrow{P_5P_4}^{\bot} \):

$$ \overrightarrow{P_5P_3}^{\bot} = \dfrac{h}{d} \times \overrightarrow{P_1P_2}^{\bot \circlearrowleft} =\begin{pmatrix} \dfrac{h(y_2 - y_1)}{d} \\ \dfrac{h(x_1 - x_2)}{d} \end{pmatrix} $$

$$ \overrightarrow{P_5P_4}^{\bot} = \dfrac{h}{d} \times \overrightarrow{P_1P_2}^{\bot \circlearrowright} =\begin{pmatrix} \dfrac{h(y_1 - y_2)}{d} \\ \dfrac{h(x_2 - x_1)}{d} \end{pmatrix} $$

Intersection points

Once the vectors \( \overrightarrow{P_5P_3} \) and \( \overrightarrow{P_5P_4} \) are known, the coordinates of \(P_3\) and \(P_4\) can be deduced by translating \( P_3\) from these vectors. We finally get:

$$ P_3 =\begin{pmatrix} x_5 - \dfrac{h(y_2 - y_1)}{d} \\ y_5 + \dfrac{h(x_2 - x_1)}{d} \end{pmatrix} $$

and

$$ P_4 =\begin{pmatrix} x_5 + \dfrac{h(y_2 - y_1)}{d} \\ y_5 - \dfrac{h(x_2 - x_1)}{d} \end{pmatrix} $$

We can even rewrite this answer:

$$ \begin{split} x &=& x_5 ~\pm~ \dfrac{h(y_2 - y_1)}{d} \\ y &=& y_5 ~\pm~ \dfrac{h(x_2 - x_1)}{d} \end{split} $$

Download

Here is the Matlab script used to check the results from this page:

circle_circle_intersections.m

Matlab confirmation of the calculation of the intersection points of two circles

See also


Last update : 03/13/2022