# Intersection of two circles

## Introduction

Given (see figure 1 and figure 2): $M1=(x1,y1)$ , $M2=(x2,y2)$ , $r1$ and $r2$.

From Pythagoras:

$d = sqrt((x2-x1)^2+(y2-y1)^2)$

• If $d > r1 + r2$, then no solutions; one circle completely outside the other.
• If $d < |r1 - r2|$, then no solutions; one circle completely inside the other.
• If d = 0 and $r1 = r2$, then infinite number of solutions; circles are coincident.

Pythagoras again:

$△M1MP: a^2 + h^2 = r1^2 and △M2MP: b^2 + h^2 = r2^2$

Subtract both equations:

$a^2 - b^2 = r1^2 - r2^2 ⇔ a^2 -(d-a)^2 = r1^2 - r2^2 ⇔ ...$

Hence:

$a = (r1^2 - r2^2 + d^2)/(2d)$

How much is a when the two circles touch at one point, i.e. $d = r1 + r2$ ?

Then substituting a in  yields:

$h = sqrt(r1^2 - a^2)$

Similar triangles in figure 3:

$△WM1M2 ~ △UMP$ :

$((xm-xp)/(y2-y1))=(h/d)$ Or for the other intersection point (not visible in figure 3): $((xp-xm)/(y2-y1))=(h/d)$

Hence:

$xp = xm ± h/d*(y2-y1)$

$△WM1M2 ~ △VM1M$ :

$((xm-x1) / a )=((x2-x1)/d)$ $xm = a/d*(x2-x1) + x1$

And substituting ${x}_{m}$ in the previous equation for ${x}_{p}$ results in:

$xp = a/d*(x2-x1) + x1 ± h/d*(y2-y1)$

And similar for the y-coordinates:

$yp = a/d*(y2-y1) + y1 -/+ h/d*(x2-x1)$

So, this yields two xy-coordinates $\left({x}_{p},{y}_{p}\right)$, one for each intersection point. If both circles touch in one point (h = 0), then ${\left({x}_{p},{y}_{p}\right)}_{1}={\left({x}_{p},{y}_{p}\right)}_{2}$.