Math question: How to compute the area of polygons

Malte Brill malte.brill at t-online.de
Wed Mar 19 05:08:00 EST 2003


Hi Dar,Jim,Mr. Miscdas, Bob, Gernot and all!

Thank you very much for your replys. I really appreciate this.

Dar wrote:
>Do you mean a smallest polygon that contains exactly the union of the
>points in the two polygons?  (If the polygons do not overlap this might
>include a thin bridge with no area.)

A thin bridge would be o.k.

Jim wrote:

>Depending on what you have in mind, this might be much easier using
>Turtle Graphics.

>Hope this gets you going.

Thanks for your code Jim! A very good start!

I´m still experimenting with collision detection. I would like to try the
following:

-Create a Polygon with n-sides around my sprites. Compute the area of each
 polygon. 
-Store it in a custom property to make checking faster.
-Check: intersect(SpriteX,SpriteY)
-True: Compute the area of the union of polyX,polyY
-Smaller than both areas summed -> Objects collided.

If I had a neat algorithm for that job, I think it could be quite fast.

But I am not that what one calls a math-person so I don´t know how to teach
Rev what I want to do. Could one base something like this on Turtle
Graphics?

>One caveat. The algorithm  in my previous message assumes the polygon
>is simply connected--all points accessible without crossing the
>boundary. It calculates the area of a polygon transversed in the
>counter-clockwise sense as positive, and negative if transversed in
>the clockwise sense. Thus the area of a symmetric figure eight-like
>polygon would  be zero.

>But this complication can be overcome if it  is an issue.

This shouldn´t be an issue. I just have to be careful creating my polys. :-)

Mr. Miscdas wrote:

>If you are dealing only with regular polygons, see the following:
>http://www.efunda.com/math/areas/RegularPolygonGen.cfm

Thanks a lot for that link.

Bob wrote:

>The area of a regular polygon with n sides of length l =
>1/4n(l squared) (cot 180/n)

>The area of a circumscribed polygon = n(r squared)tan(pi/n) where pi =
>3.14 and
>r = the radius of the circumscribed circle = (l/2)cosec(180/n)

>Sorry the above is not in strictly math format.

Thanks for the information.
I guess the first assumes all sides have the same length. That´s a bit
problematic for me.

It´s a pitty, but I don´t understand the 2nd one. I guess it assumes
calculating a circle around the Poly, containing all points of it. But how
do I get the circle? What does cosec mean?

Thanks to Gernot for the explanation in german.

Danke! Es hilft auserordentlich ein so komplexes Thema in der eigenen
Sprache zu diskutieren.
For the none germans:it really helps discussing such a complex topic in ones
own language :-) 

Thanks for helping me so much, but I guess I will need some time to figure
out a method to do what I want, so this has to wait until I have finished my
Player-app.

Regards,

Malte




More information about the use-livecode mailing list