[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] exact collisions



On Mon, 2005-04-04 at 10:38 +0200, gen2n wrote:
> Could you give me a kick how do do each of them and which could be better?

Hmm, I could stir up the "point inside triangle" test in Python code. If
it's a static triangle the routine could be optimized a bit.

Perpixel testing could do it, but it's generally a slow test. Especially
in your case where you already have geometry representing your objects.

If you look in the "old" PCR, you can find some rough code to do line
intersection testing. You could test all the edges of the square against
all the edges of the triangle. This wouldn't be right in the case where
one shape completely encloses the other.
http://www.pygame.org/pcr/los_blocking_lines/index.php

Hmm, PCR to the rescue, I see someone's already submitted the 'point in
polygon' algorithm.
http://mu.arete.cc/pcr/syntax/pointInPolygon/1/pointInPolygon.py