Look at a map and drop a pin. Is it inside the city limits or not? Your eye answers instantly. A computer has no eyes — it only has a list of corner coordinates and the pin's (x, y). So how does it decide?
For a circle the test is trivial: compare the distance to the radius. But real shapes are polygons — countries, sales territories, the hit-box of a sprite, a fenced-off zone on a drone map — and they can be wildly irregular, with hundreds or thousands of corners and even concave dents that fold back on themselves.
The surprise is that one of the oldest tricks in geometry settles it with almost no math: fire a ray from the point off to infinity and count how many edges it crosses. The answer to inside-or-out is hiding in whether that count is odd or even.
Comments
Loading comments...