Math question: How to compute the area of polygons
Geoff Canyon
gcanyon at inspiredlogic.com
Wed Mar 19 11:09:01 EST 2003
If you're looking for collision detection, I think it would be faster
to check the line segments of polygon A against the line segments of
polygon B to see if any of them intersect. If they do, there's a
collision. There may be a faster way than that, but I think at least
that it would be faster than computing the areas.
But before you even do that, you should come up with a rough, simple
calculation that will tell you there is no collision, or that you need
to do the more exact test. So for example, if polygon A has no point
more than 30 pixels away from its loc, and polygon B has no point more
than 25 pixels away from its loc, then your first calculation would be
the distance between the loc of A and the loc of B; if it's more than
55 pixels, there is no intersection. If it's less, then you do the more
exact calculation.
On Wednesday, March 19, 2003, at 02:04 AM, Malte Brill wrote:
> -Smaller than both areas summed -> Objects collided.
>
> If I had a neat algorithm for that job, I think it could be quite fast.
>
regards,
Geoff Canyon
gcanyon at inspiredlogic.com
More information about the use-livecode
mailing list