|
If the polygons overlapped, you could check the point against each polygon in turn. Yes this could be slow, depending on the complexity and number of polygons. It can be greatly speeded up by comparing against the polygon's rectangular extents, and/or by sorting polygons.
re. the odd/even bit: Try it on a piece of paper. Draw a polygon. Start with a simple one like a square.
Point outside square:
- If ray misses square => 0 intersections
- If ray passes through square => 2 intersections
Point inside square:
- Ray always has one intersection
Try more complicated polygons with concave faces/etc, and you'll find an odd number of intersections occur when the point is inside the polygon.
Richard |