Re: Common area of circles

2010-02-05 Thread Shashwat Anand
Here is my approach: # input circles, remove duplicates, store them # check whether all circle intersect: if no: print '0.0' if yes: # calculate intersection points of two circles. # check if that point lies in rest all circles if yes: store it as polygon-coordinates (hull) calculat

Re: Common area of circles

2010-02-04 Thread John Nagle
Chris Rebert wrote: On Thu, Feb 4, 2010 at 2:39 AM, Shashwat Anand wrote: Given 'n' circles and the co-ordinates of their center, and the radius of all being equal i.e. 'one', How can I take out the intersection of their area. How is this at all specific to Python? This also sounds suspiciou

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
maximum number of circles = 10**6 runtime <= 5 sec center of circles , -1000<=xi,yi<=1000 (float) [for int it was easier] intersection is there and the area will be non-zero (it can always be checked if intersection is taking place and if no, then area = 0.00) This was a programming contest pro

Re: Common area of circles

2010-02-04 Thread Mark Dickinson
On 2/4/2010 7:05 AM, Shashwat Anand wrote: > I want to calculate areas. > like for two circles (0, 0) and (0, 1) : the output is '1.228370' > > similarly my aim is to take 'n' co-ordinates, all of radius '1' and > calculate the area common to all. > The best I got was monte-carlo methods which is i

Re: Common area of circles

2010-02-04 Thread Dave Angel
Shashwat Anand wrote: I want to calculate areas. like for two circles (0, 0) and (0, 1) : the output is '1.228370' similarly my aim is to take 'n' co-ordinates, all of radius '1' and calculate the area common to all. The best I got was monte-carlo methods which is inefficient. Is there any other

Re: Common area of circles

2010-02-04 Thread Gerard Flanagan
Gary Herron wrote: Gerard Flanagan wrote: A brute force approach - create a grid of small squares and calculate which squares are in all circles. I don't know whether it is any better than monte-carlo: That's just what the monte-carlo method is -- except the full family of monte-carlo met

Re: Common area of circles

2010-02-04 Thread Gary Herron
Gerard Flanagan wrote: On 2/4/2010 7:05 AM, Shashwat Anand wrote: I want to calculate areas. like for two circles (0, 0) and (0, 1) : the output is '1.228370' similarly my aim is to take 'n' co-ordinates, all of radius '1' and calculate the area common

Re: Common area of circles

2010-02-04 Thread Gerard Flanagan
On 2/4/2010 7:05 AM, Shashwat Anand wrote: I want to calculate areas. like for two circles (0, 0) and (0, 1) : the output is '1.228370' similarly my aim is to take 'n' co-ordinates, all of radius '1' and calculate the area common to all. The best I g

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
thanks, all of you On Thu, Feb 4, 2010 at 7:31 PM, Terry Reedy wrote: > On 2/4/2010 7:05 AM, Shashwat Anand wrote: > >> I want to calculate areas. >> like for two circles (0, 0) and (0, 1) : the output is '1.228370' >> >> similarly my aim is to take 'n' co-ordinates, all of radius '1' and >> cal

Re: Common area of circles

2010-02-04 Thread Terry Reedy
On 2/4/2010 7:05 AM, Shashwat Anand wrote: I want to calculate areas. like for two circles (0, 0) and (0, 1) : the output is '1.228370' similarly my aim is to take 'n' co-ordinates, all of radius '1' and calculate the area common to all. The best I got was monte-carlo methods which is inefficien

Re: Common area of circles

2010-02-04 Thread Xavier Ho
It's an interesting problem. Never thought it was this difficult. I can't account for all geometrical enumerations, but assuming all 4 circles intersect, here's the solution for this particular senario. It's probably not going to be useful to you since you're working on geometrical approximations n

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
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 ~l0nwlf On Thu, Feb 4, 2010 at 5:49 PM, Bearophile wrote: > Shashwat Anand: > > > Given 'n' circles and the co-ordinates of their cen

Re: Common area of circles

2010-02-04 Thread Bearophile
Shashwat Anand: > > Given 'n' circles and the co-ordinates of their center, and the radius of > > all being equal i.e. 'one', How can I take out the intersection of their > > area. I can see two possible solutions, both approximate. In both solutions you first look if there are a pair of circles t

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
I want to calculate areas. like for two circles (0, 0) and (0, 1) : the output is '1.228370' similarly my aim is to take 'n' co-ordinates, all of radius '1' and calculate the area common to all. The best I got was monte-carlo methods which is inefficient. Is there any other approach possible. On

Re: Common area of circles

2010-02-04 Thread Xavier Ho
I'm not sure what you're after. Are you after how to calculate the area? Or are you trying to graph it? Or an analytical solution? What do you mean by "take out the intersection"? -Xav On Thu, Feb 4, 2010 at 9:47 PM, Shashwat Anand wrote: > I wanted some general suggestion/tips only > > > On Th

Re: Common area of circles

2010-02-04 Thread Shashwat Anand
I wanted some general suggestion/tips only On Thu, Feb 4, 2010 at 5:11 PM, Chris Rebert wrote: > On Thu, Feb 4, 2010 at 2:39 AM, Shashwat Anand > wrote: > > Given 'n' circles and the co-ordinates of their center, and the radius of > > all being equal i.e. 'one', How can I take out the intersect

Re: Common area of circles

2010-02-04 Thread Chris Rebert
On Thu, Feb 4, 2010 at 2:39 AM, Shashwat Anand wrote: > Given 'n' circles and the co-ordinates of their center, and the radius of > all being equal i.e. 'one', How can I take out the intersection of their > area. How is this at all specific to Python? This also sounds suspiciously like homework,