Geometry – Intersection of n Disks or Circles

geometry

Given that $n$ disks/circles share a common area, meaning that every two of them intersect or overlap one another, and we know their coordinates $(x_{1},y_{1},r_{1})$, $(x_{2},y_{2},r_{2})$, …, $(x_{n},y_{n},r_{n})$, where $x_{i}$,$y_{i}$,$r_{i}$ represent the $x$ axis coordinate, the $y$ axis coordinate, and the radius of the $i$-th disk/circle, respectively, can you provide a method to calculate the coordinate of the centroid of the intersection of these disks/circles?

Best Answer

The intersection of $n$ disks is a convex shape bounded by circular arcs that meet at vertices where two or more circles intersect.

enter image description here

The first thing to do is to identify these vertices and the arcs that connect them to each other. If no three circles are coincident,$^1$ then this isn't very hard: Consider every pair of circles; find their two intersection points, which form two candidate vertices; if a candidate vertex is inside all other circles, then it is indeed a vertex of the intersection. This gives you a set of vertices.$^2$ Each vertex lies on exactly two circles; using this connectivity, you can sort them in consistent order around the intersection shape.

Now you can decompose the intersection shape into a number of pieces: (i) the polygon (shaded blue above) that connects the vertices, and (ii) a collection of circular segments (shaded red), one for each arc of the shape. You can find the areas and centroids of each piece using closed-form formulas (polygon, circular segment). The centroid of the full shape is then just the weighted average of the centroids of each of the pieces, weighted by area.


$^1$If multiple circles are coincident on a vertex, then doing pairwise tests may not always get you a consistent set of vertices, especially if you're using floating-point arithmetic. You might be able to get around this to some extent by fudging the inside-circle test with some epsilon bias, but a truly robust solution would have to come from a computational geometry expert.

$^2$It's possible that the set of vertices turns out to be empty. Then there are two possibilities: either the intersection is equal to one of the circles, or the intersection is empty. It is easy to distinguish between these two cases by checking if there exists a circle that is entirely inside all the others.