I needed 6 decimal places of accuracy, so first way of solution will not work for my case. However, your second strategy seems promising. Working on it. Thanks :D<br>~l0nwlf<br><br><div class="gmail_quote">On Thu, Feb 4, 2010 at 5:49 PM, Bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Shashwat Anand:<br>
<div class="im">> > Given 'n' circles and the co-ordinates of their center, and the radius of<br>
> > all being equal i.e. 'one', How can I take out the intersection of their<br>
> > area.<br>
<br>
</div>I can see two possible solutions, both approximate. In both solutions<br>
you first look if there are a pair of circles that don't intersect, in<br>
this case the intersect area is zero. You also remove all circles<br>
fully contained in another circle.<br>
<br>
The first strategy is easy to do, but it probably leads to a lower<br>
precision. Then you can sample randomly many times the rectangular<br>
area that surely contains all circles. You count how many of those<br>
random points are inside all circles. This gives you an approximate<br>
area of their intersection. Increasing the points numbers slowly<br>
increases the result precision.<br>
<br>
The second strategy is more complex. You convert your circles into<br>
polygons with a fixed number of vertices (like 50 or 100 or 1000 or<br>
more. This number is constant even if the circles don't have all the<br>
same radius). So you can turn this circle into a simple mesh of<br>
triangles (all vertices are on the circumference). Then you "subtract"<br>
the second polygonalized circle, this can create a hole and split<br>
triangles in pieces, and so on with successive circles. At the end you<br>
can compute the total area of the triangles left. This is doable, but<br>
you need time to do implement this. The advantage is that the<br>
numerical precision of the result is probably higher. If you implement<br>
this second solution you can implement the first one too, and use it<br>
as a test to avoid bugs. Visualizing the triangles with Pygame or<br>
MatPlotLib can be useful to look for bugs.<br>
<br>
Bye,<br>
bearophile<br>
<font color="#888888">--<br>
</font><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>