Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!odin!bedlam.asd.sgi.com!davis From: davis@bedlam.asd.sgi.com (Tom Davis) Newsgroups: comp.graphics Subject: Re: Wanted: algorithm to compute intersection of square and circle Message-ID: <1991Apr26.011221.3305@odin.corp.sgi.com> Date: 26 Apr 91 01:12:21 GMT References: <1991Apr25.192400.8438@cfa203.harvard.edu> Sender: news@odin.corp.sgi.com (Net News) Reply-To: davis@bedlam.asd.sgi.com (Tom Davis) Organization: Silicon Graphics, Inc., Mountain View, CA. Lines: 10 If you just need a numerical approximation, why not approximate the circle with an n-sided regular polygon, and use standard clipping procedures to clip that polygon against the square. Then if the (clipped) vertices are (x[0], y[0]), (x[1], y[1]), ... (x[m-1], y[m-1]), the area is given by: 1/2 * sum { x[i](y[i+1] - y[i]) - y[i](x[i+1] - x[i])} The sum goes from i = 0 to i = m-1, and assume x[m] = x[0] and y[m] = y[0]. Pick a big enough n, and you ought to do OK.