views:

114

answers:

2

Prob Statement: 'N' equii radii circles are plotted on a graph from (-)infinity to (+)infinity.Find the total area of intersection i.e all the area on the graph which is covered by two or more circles. Please refer to the below image for better view.

alt text

+2  A: 

Firstly a correction: these aren't circles. They're ellipses (circles being a special case of ellipses where a = b). You can calculate the intersection of two ellipses so given N ellipses you need to check each pair, so the entire operation is O(n2) (multiplied by whatever the intersection operation is).

Take a look at Intersection of Ellipses and The Area of Intersecting Ellipses.

Edit: the intersection of circles is an easier problem but follows the same principle. Take a look at Intersection Of Two Circles and Circle-Circle Intersection.

cletus
sorry, my image isn't that perfect... all the curves in he image represent equi radii circles.
This is hard because you have to deal with cases where more than 2 overlap.
dmckee
+1  A: 

Easiest (not necessarily fastest or "best") way to code is to find the bounding box that contains all circles and then use a numerical stochastic method to integrate.

Now by being smart you can probably group circles and box them separately, i.e work in a number of bounding boxes. And even handle certain special cases exactly.

But a pure stochastic method has the beauty of being easy to implement (but potentially slow).

This is only acceptable if you are happy to have an "approximate" (but arbitrarily close to correct) answer.

Michael Anderson
Good if rough or modest precision is acceptable. *Definitely* want to detect overlapping groups and draw bounding boxes around each group though: there is the potential for insane quantities of whitespace otherwise.
dmckee