Combined area of overlapping circles
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
For two circles, the combined covered area is the sum of both circle areas minus the region they share. The challenge is that the overlap depends on the distance between the centers, so the formula changes across three geometric cases: no overlap, one circle fully inside the other, and partial overlap.
Core Sections
Start from inclusion-exclusion
The union area of two sets follows a simple rule:
- area of circle one
- plus area of circle two
- minus the overlap area counted twice
For circles with radii r1 and r2, the union area is:
So the real work is computing overlap correctly.
Handle the easy cases first
Before using any trigonometry, check the relative position of the circles. Let d be the distance between their centers.
- If
d >= r1 + r2, the circles do not intersect. The overlap is zero. - If
d <= abs(r1 - r2), one circle lies completely inside the other. The overlap is the area of the smaller circle. - Otherwise, the circles partially overlap and you need the lens-area formula.
These checks are important because the full formula is less numerically stable near the edge cases.
Use the partial-overlap formula
For the partial-overlap case, the shared region is made of two circular segments. The standard formula is:
Once you have that overlap value, subtract it from the total of the two circle areas.
Implement it in Python
This function returns the total covered area of both circles together, not the overlap by itself.
Understand what the formula is measuring
The two acos terms describe the areas of the two sectors cut by the chord of intersection. The square-root term subtracts the kite-shaped region that was counted inside both sectors. That decomposition is why the result is the lens-shaped overlap area.
You do not need to memorize the derivation to use the formula correctly, but knowing the geometric pieces makes debugging much easier.
Numerical considerations
Floating-point rounding can push the acos input slightly outside the valid range from -1 to 1, especially when circles nearly touch. In production code, clamp the argument before calling acos.
That small defensive step can prevent domain errors in edge cases.
More than two circles is a different problem
The neat closed-form solution above is specific to two circles. For many circles, exact union area becomes much more complex. At that point, people often switch to computational geometry libraries, plane sweep methods, polygon approximation, or Monte Carlo estimation depending on the precision requirements.
Common Pitfalls
- Applying the partial-overlap formula without first checking the no-overlap and containment cases.
- Returning the overlap area when the real question asks for the combined union area.
- Forgetting that one circle entirely inside another means the union is just the larger circle’s area.
- Ignoring floating-point edge cases near tangency, which can make
acosfail unexpectedly. - Assuming the two-circle formula scales directly to many circles, even though that becomes a more complex geometric problem.
Summary
- The combined area is
area1 + area2 - overlap. - Always distinguish between no overlap, full containment, and partial overlap.
- The partial-overlap case uses a standard lens-area formula based on
acosand a square-root term. - Implement edge-case checks before the full formula for correctness and stability.
- For more than two circles, you usually need a different computational approach.

