Skip to main content
gamedev.net
🔒 Locked

Point in a shape problem.

Started by soivex Apr 4, 2007 at 3:20 AM 0 replies 550+ views
Original Post
soivex
soivex
Hello. I'm using "number of intersections" method to check in my point inside or outside of my 2d shape. My shape have about 360 points. First, i'm creating a horisontal ray starting from my point and checking it for intersections with every small lines in my shape. Then i count the number of intersections. If this number is not even, then my point is inside. It works good, but sometimes it fails. It fails, because my ray can be colinear with the number of small lines (part of one edge for example), and it make inpossible to count right number of intersections. Please help, how to avoid this situation? Thanks!
Vorpy
Vorpy
Test which side of the ray each point is on. If the point is on the ray, break the tie arbitrarily and consistently. Depending on how you decide which side of the ray each point is on, your number of intersections may vary by a multiple of 2, which will not affect the outcome of the test.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.