Math question: How to compute the area of polygons
Jim Hurley
jhurley at infostations.com
Mon Mar 24 12:40:01 EST 2003
>
> >> Jim Hurley wrote:
>(snip)
> > But you still get no contribution from the first repeat, but what is
>> 0 among friends.
>>
>> Regards,
>>
>Raymond wrote:
>Not quite: you are repeating the first line, but that does not mean that you
>are closing the loop.
>
>Now if you have a filled polygon, the first line and the last line in the
>points are the same, so you have no problem. OTOH, if you don't have a
>filled polygon or are simply submitting a set of points, you should do this:
>
>put line -1 of tList into pOld
>
>This will close the loop, and it is unlikely (though possible) that the
>contribution will be equal to 0.
>
>But the loop *must* be closed. If it is not closed you will likely get the
>wrong area.
>
>Cheers!
>
>Raymond
>
Raymond,
I try to keep my power dry and my polygons closed. I created them
using the polygon tool and then reshaping them using the reshaping
tool. That tool forces the polygon (actually the open connected line
segments) to close, that is, to add an extra line at the end of the
points which is identical to the first line. This assures the
accuracy of the area algorithm.
BTW: The filled property does not assure that the polygon is closed.
The default mode of the polygon tool is to create a filled polygon.
You can assign a background color and the open polygon fills with the
color. The best way to check the "closedness" is to check the the
points in the graphics tab on the properties pallet.
This is all very confusing and mostly a matter of semantics. It is
awkward to speak of *open* polygons to begin with. A polygon is by
definition a closed plane figure bounded by straight lines. What MC
and RR mean when they speak of a polygon is actually a "sequence of
connected straight line segments." There is no simple mathematical
term for this and so this is just another necessary compromise of the
scripting language.
But you are right, if the first and last lines in the graphics
points are not the same you need to deal with this in the area
algorithm.
Best regard,
Jim
More information about the use-livecode
mailing list