Why it matters

Point-in-polygon is fundamental test. Understanding shapes GIS + graphics.

Advertisement

The architecture

Ray from point.

Count edge crossings.

Odd = inside; even = outside.

Ray casting flowPoint + raytest directionCount crossingswith edgesOdd = insideeven = outsideWinding number handles complex/self-intersecting polygons robustly
Point in polygon.
Advertisement

How it works end to end

Ray casting O(n).

Handle edge cases: vertex on ray, edge parallel.

Winding number for complex polygons.