CPKit
v1.6.1

Point in Polygon

GeometryHard

Verify point containment in closed shapes using Ray Casting sweeps.

Alt+Shift+P

Ray Casting Crossing Grid (Drag Test Point P or polygon corners)

A (-3, 3)B (3, 2)C (2, -2)D (-2, -3)Test Point (P) (0, 0)
Containment Result:INSIDE POLYGON
Ray Crossings Log:
• Ray crossed edge between B and C. Status toggled: INSIDE

Time Complexity

O(N) linear sweep of edges

Space Complexity

O(1) auxiliary
Conceptual Overview

Point in Polygon checks if a coordinate lies inside a closed polygon using the Ray Casting algorithm (even-odd rule).

Mathematical Formula
\text{Cross check: } y_{1} > y_{P} \ne y_{2} > y_{P} \text{ and } x_{P} < \frac{(x_2-x_1)(y_P-y_1)}{y_2-y_1} + x_1
Source: CP-Algorithms geometry reference