Math question: How to compute the area of polygons

miscdas at boxfrog.com miscdas at boxfrog.com
Wed Mar 19 09:51:01 EST 2003


Malte Brill writes:
[snip]
> 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. 
> 
>>If you are dealing only with regular polygons, see the following:
>>http://www.efunda.com/math/areas/RegularPolygonGen.cfm
> Regards, 
> 
> Malte 
> 
==========
Herr Brill, 

It appears you have decided to go a more difficult route of using irregular 
polygons. I suspect this is because you want to draw an irregular polygon to 
enclose your Sprite. Check this link; you may decide to use regular polygons 
instead. http://mathforum.org/library/drmath/view/52053.html
(By the way, think of a circle as a regular polygon with an infinite number 
of sides with the length of a side infinitely small.) 

Now that you mentioned Sprites and collision detection, did you look at the 
intersect function? It seems to me that you could simply test the inersect 
of each of the sprites with each other. If for some reason the sprintes are 
not objects that the intersect can be determined, then drawing your polygon 
around the sprites and then testing the intersect for each polygon will get 
you collision detection. 




More information about the use-livecode mailing list