From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Searching for a very specific algorithm Date: Thu, 29 May 1997 21:41:14 -0700 Organization: Alcyone Systems Message-ID: <338E5A6A.4D22B301@alcyone.com> References: <338E2DAE DOT F88C30E AT sercomtel DOT com DOT br> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 35 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Alessandro Moure wrote: > Hi all. I am developing a data manipulation tool kit and I am > experiencing a hard time trying to find the area inside a closed, > generic region. I have the points of the border line of the region > stored in a vector. Does any body knows how to do it? The most general form would be a corrolary of Green's theorem, which allows you to calculate the area (double integral over a region) with a line integral: 2 dA = x dy - y dx. and integrate over the curve. If your curve is parameterized with parameter t, you can write this as 2 dA = (x dy/dt - y dx/dt) dt, and integrate. Since in general you won't be able to find dx/dt or dy/dt, and possibly won't be able to antidifferentiate the right side of the equation, you can change this to deltas and write deltaA = (1/2) (x deltay/deltat - y deltax/deltat) deltat, and add up the deltaA's from t = 0 to t = t' (the end of the closed curve), and compute deltax == x(t + deltat) - x(t) and deltay == y(t + deltat) - y(t). -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Covenants without the sword / are but words." / Camden