Shapes & spaces

Point-in-polygon calculator using winding number

Classify a point as inside, outside or on a simple polygon boundary, with a signed winding number and a coordinate plot.

Your numbers

One x,y pair per line. Use a decimal point, at most six decimal places, and no thousands separators. Coordinates must be within ±1,000,000.
One x,y pair per line. Use a decimal point, at most six decimal places, and no thousands separators. Coordinates must be within ±1,000,000.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A point can lie inside a polygon, outside it or directly on its boundary. This calculator preserves that three-way distinction. Enter the polygon vertices in their boundary order and a separate test point. The page first checks that the polygon is a simple ring with nonzero area. It then tests boundary segments and counts signed crossings to determine a winding number. Concave polygons are supported; self-crossing outlines are rejected rather than assigned an unstated fill rule.

THE FORMULABoundary first; signed upward and downward edge crossings give winding number w. Inside iff w ≠ 0.

A worked example

The polygon (0,0), (4,0), (4,4), (2,2), (0,4) has an inward notch. Test point (2,1) is inside, while (2,3) lies in the notch and is outside. Point (3,3) lies on one sloping edge and is reported as Boundary. Reversing the vertex order keeps all three classifications unchanged.

Good to know

Supports three through 300 boundary vertices, plus an optional repeated final copy of the first vertex. Coordinates use the stated six-decimal grid and range. Holes, multiple disjoint rings and self-intersecting polygons are excluded. Boundary means the supplied decimal geometry’s segment boundary, not a user-chosen proximity buffer.

A bounding box cannot detect the notch

Both (2,1) and (2,3) fit inside the rectangle from x = 0 to 4 and y = 0 to 4. Only the first belongs to the default polygon. Bounding-box checks are useful for quickly rejecting distant points, but they cannot replace a polygon containment test for concave outlines. The winding procedure follows the actual boundary edges instead of their rectangular envelope.

The boundary test runs before the crossing count. A point on an edge or vertex is therefore never arbitrarily assigned inside by a ray passing through a corner. Half-open vertical crossing conventions ensure that an ordinary vertex crossing is counted once. On a counterclockwise simple polygon, an interior point usually has winding number +1; reversing the ring produces −1, which still means inside.

A concave notch excludes a point that is still inside the bounding rectangle(2,3): outside(2,1): insideEdges: boundary
The filled point (2,1) is inside. The open point (2,3) is outside in the notch. A point on the sloping edge, such as (3,3), is Boundary.

The Convex hull calculator from unordered points fills concavities, so its enclosure cannot replace a containment test against a known concave outline.

Validate the ring before interpreting its interior

An unordered list of corners may connect into a bow-tie, and a path that retraces an edge is not a simple boundary. The calculator checks nonadjacent edge intersections and adjacent reversals, rejects zero-length edges and requires nonzero area. A final repeated first vertex is accepted as a common closing convention, but additional repeated vertices that create self-touching geometry are not silently removed.

The polygon coordinate calculator measures a known ordered outline. This page adds a containment decision for a specified point. It does not use a convex hull as a substitute, because a hull would fill concave notches and could classify outside points as inside. All coordinates must refer to one Cartesian plane. A location a small distance from an edge remains outside or inside according to that supplied geometry; this is not a geofencing accuracy estimate.

A few questions, answered

Does clockwise input break the test?

No. Clockwise order reverses the winding sign but leaves the inside, outside and boundary classifications unchanged.

Can I enter a polygon with a hole?

Not on this page. A hole needs multiple rings and an explicit rule for combining their interiors, which this simple-ring model excludes.

Find your calculator

Start typing to explore the library.