Page 1 of 1

detect if shapes are contained within non convex region

Posted: Fri Mar 05, 2010 5:11 am
by kreuters
hey there

i am using chipmunk for an iphone puzzle game, works great. i am a bit stuck though, i have a bunch of active shapes and i need to detect if they are all within a non-convex polygonal region defined by a bunch of vertices. what would be the easiest way to achieve this?

Re: detect if shapes are contained within non convex region

Posted: Fri Mar 05, 2010 7:03 am
by kreuters
was quite easy in the end, if anyone has the same problem, i used this:

http://www.ecse.rpi.edu/Homepages/wrf/R ... npoly.html

and first checked if the bounding boxes for each shape were in the bounding box of the goal region, if so then check if each shape vertex is contained in the goal region using the above algorithm.