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?
Geometry – Intersection of n Disks or Circles
geometry
Related Solutions
It's not very clear whether the problem is about disks or about circles. Here are some suggestions for both cases.
If it is about disks, then you can use Helly`s theorem. It says that $n \geq 3$ disks on a plane intersect if and only if every $3$ disks among them intersect. And for $3$ disks I believe it should be quite easy to produce an exact solution (i.e. one that is 100% precise if all centers and radii are given as rational numbers).
This is not the fastest approach, but I believe it can be implemented precisely without any serious complications, and without the use of floating point operations.
If the problem is about circles and not about disks, then you can also make the solution precise, but you will have to manipulate elements of some quadratic extension of $\mathbb{Q}$, i.e. you'll have to do symbolic manipulations with expressions like $a + b\sqrt{c}$.
UPDATE: since you're talking about code, I should add this bit: it all depends on the exact circumstances and the exact quality/speed requirements.
a) If this is a programming contest, then I wouldn't use Helly's theorem. Instead, I would do something like the following, which takes time $O(n^2 \ln n)$.
If all the disks have a common point, then they also have a common point that lies on the border of one of the disks. So, for every disk $D$, I would check whether or not there is a point on its border (which is a circle $S$) that belongs to all other disks.
To do that, I would find the intersections of this border $S$ with every other disc. Each such intersection is an arc of $S$, a point on $S$, an empty set, or the whole $S$. And then I'd determine whether or not these arcs have a common point, which can be done in time $O(n \ln n)$ by sorting the endpoints of the arcs (say) clockwise. I would do it all using floating-point arithmetic with an appropriate epsilon value. In fact, this is what I did a couple of times in actual competitions back in the day.
b) If the code should be industrial and absolutely precise, then it should be possible (in principle) to do the same as above, but instead of floating point arithmetic do precise arithmetic in an appropriate finite field extension of $\mathbb{Q}$. But I've never tried to implement this myself. Could be kind of difficult.
c) If execution time is not as important but you still need absolute precision, then I would go with Helly's theorem. It could simplify the code thus making it much more robust, but execution time will grow to $n^3$.
The region is obtained from three 60°-sectors of a disc, which all overlap in an equilateral triangle. Hence the total area is that of a half disk minus two triangles. You can find the radius of the disc/side of the triangle with Pythagoras.
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.
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.