I cant understand the line “the test point is on the interior if, and only if, the ray crosses the boundary an odd number of times.”
why odd number of time when the polygon vertices are in even number ?
It will be a greate help if u explain it to me . Thanks in advance
I don’t know more .But what I think …is :
It means : if a ray passes a boundry of a polygon for the first time , it gets inside the polygon .when it again passes the boundry it comes out .similarly for the third time when it passes the boundry it again becomes the test point which is on the interior of the polygon i.e inside the polygon.
@biprotip: It’s explained on wikipedia. https://en.wikipedia.org/wiki/Point_in_polygon. The tricky part is when the ray you cast encounter a vertex. Because a vertex belongs to 2 edges, it can make your calculation wrong.