On Thursday, March 20, 2003, at 11:52 AM, Raymond E. Griffith wrote:
Here is a little routine I have written that will accurately calculate the
area of irregular polygons so long as there are no crossed lines. You can
have irregular shapes as funky as you like and this will work -- provided
there are no lines which cross.
The math behind this is fascinating.
I'm impressed. This looks elegant. (I haven't gotten into the math, yet.)
The work approaches two multiplies, one subtract and one add per edge.
However, if Tomas Nally's method was optimized, it would take only one multiply, one subtract and two adds per edge. (See mail forwarded by Heather.)
That is the same number of operations, but if multiplication is much more expensive than addition, then an optimization of Nally's method might be faster.
An optimization of Nally's method might be like Ray's only with a line much like this one (off the top of my head):
add ((item 1 of tLine) - (item 1 of tPreviousLine)) * ((item 2 of tLine) + (item 2 of tPreviousLine)) to tsum
And the tPreviousLine initialization is the last point instead of 0,0.
The area added to tsum each cycle is twice the area "under" the line segment or its negation.
(I don't know how either would work in weird cases.)
Dar Scott
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
