Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sprochet

Point within polygon

This topic is 6133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a small collision detection app and I''m wondering how to check if a point is within a polygon.. As of now, I''m trying to add the inverse cosines of the dot product between each vertex in the poly and the plane intersection point, but I can''t get i to work. Can anyone who has successfully done this point me to a tutorial or show me some sourc code?

Share this post


Link to post
Share on other sites
Advertisement
Imagine a horizontal line extening from negative infinity to the point you''re testing. Now, count the number of line segments of your polygon that this ray intersects with. If the number of intersections is odd, the point is inside the polygon. Otherwise, it''s outside.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!