# Overlapping circles

Consider two circles of radii $R$ and $r$ whose centres are separated by a distance $d$. This post derives a formula for the area of their intersection, $A$.

First note that $A=0$ if $d \ge R+r$: the circles do not intersect at all in this case. Also, $A = \pi (\mathrm{min}(R,r))^2$ if $d \le |R-r|$: the smaller circle is entirely enclosed in the larger in this case. For the case of partial overlap, $|R-r| < d < R+r$ the area to find is shaded in the diagram below.

The cosine formula gives the angles $\alpha$ and $\beta$:

$$\cos \alpha = \frac{r^2 + d^2 - R^2}{2rd} \quad \mathrm{and} \quad \cos \beta = \frac{R^2 + d^2 - r^2}{2Rd}.$$

The required area may be found as the sum of the two circle segments cut off by the chord CD. For the circle centred at A in the diagram above, its segment is the area of the circular sector ACD minus the area of the triangle ACD:

With $x=\mathrm{AE} = R\cos\beta$ and $h=\mathrm{CE}=R\sin\beta$, triangle ACD has area $xh=R^2\cos\beta\sin\beta=\frac{1}{2}R^2\sin2\beta$. The area of the circular sector ACD is simply $\beta R^2$ with $\beta$ measured in radians (the entire circle has area $\pi R^2$ and we want the fraction $\beta/2\pi$ of it).

Therefore, the shaded circular segment has area $\beta R^2 - \frac{1}{2}R^2\sin2\beta$.

Similarly, the area of the segment of the circle centred at B cut off by chord CD is $\alpha r^2 - \frac{1}{2}r^2\sin2\alpha$.

The total intersection area is therefore

$$A = \alpha r^2 + \beta R^2 - \frac{1}{2}r^2\sin2\alpha - \frac{1}{2}R^2\sin2\beta.$$

Currently unrated

#### Sam Ghatak 8 months, 2 weeks ago

Hi, I was trying to use your code given here :
http://scipython.com/book/chapter-8-scipy/problems/p84/overlapping-circles/

However the intersecting area given is wrong for the normal intersection case. For d= 5, r=3,R=3, the area given is 28.274333882308138

which is certainly not correct.

Currently unrated

#### Christian Hill 8 months, 2 weeks ago

Hi Sam,
Are you using Python 3? The whole of scipython.com is dedicated to this version of Python, which gives me 2.25077780634 for the overlap area.
If you use Python 2, the calculation of alpha and beta may be done using integer arithmetic, which rounds down and so gives the wrong angles if you pass in R, r and d as integers. You could try defining them as floats (i.e. R = r = 3.0; d = 5.0).
Let me know if it works?

Currently unrated

### New Comment

required

required (not published)

optional