Math question: How to compute the area of polygons

Jim Hurley jhurley at infostations.com
Wed Mar 19 08:39:00 EST 2003


>Malte wrote:
>
>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.


Malte,

I think I have  a better understanding of what you are trying to 
achieve. I don't think it is particularly valuable to calculate 
areas. In collision detection you need to know whether there are 
overlapping interior points of the two areas. This is rather complex 
for arbitrarily shaped polygons. Could you  settle for making each 
sprite a circle, perhaps of differing diameters? In this way you 
would only need to determine whether their centers were closer than 
the sum of  the radii, a very simple task. The radii could be custom 
properties of the sprites.

Jim




More information about the use-livecode mailing list