-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|453|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Collisions and Physics


 
Pakz
Created : 13 November 2019
Edited : 13 November 2019
Language : Monkey2

Polygon vs Polygon Collision

Is one polygon colliding with another polygon



Based on my point vs polygon collision snippet. This one checks collision with two polygons.It is probably not that very effecient but computers always seem to get faster so it probably is workable.
It works by checking the lines of the two polygons. If they collide then there is a collision. When either polygons are inside the other a check is done by checking if this is the case.

Java had this collision checking build in the language and I had been looking to do this in other languages. I have not really tested this code with a lot of situations yet. If I find problems and can fix it then I wil update the code.

 

Comments


Wednesday, 13 November 2019, 04:57
Jayenkai
Yeah, that's probably how I'd do it, too.
Depending on how much faster the "Point to Polygon" test is, you might find it quicker to first do a check of all points of PolyA, to see if they're within PolyB (And maybe vice-versa)

That *might* be marginally faster, but .. again, you'd probably have to stress test both methods, and see which is actually faster.