Advanced maths

Polygon visibility region calculator from interior viewpoint

A polygon visibility region contains the points that can be joined to an interior viewpoint without crossing a wall.

Your numbers

x,y rows; no holes or self intersections.
Strictly inside, away from boundary.

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 polygon visibility region contains the points that can be joined to an interior viewpoint without crossing a wall. This calculator approximates that boundary with a vertex-angle ray sweep, retaining the nearest intersection on every ray. It accepts concave simple polygons without holes and returns the visible boundary and approximate area.

THE FORMULAV(p)={q in polygon : segment pq lies in polygon}; each ray stops at its first boundary intersection.

A worked example

In the L-shaped room (0,0),(3,0),(3,1),(1,1),(1,3),(0,3), viewpoint (0.5,0.5) sees the full room, whose area is five. Moving the viewpoint into the horizontal arm hides part of the vertical arm behind the reflex corner at (1,1). That change is an occlusion effect, not a shortest-path detour.

Good to know

Approximate floating-point ray sweep, 3–32 simple polygon vertices, no holes. The viewpoint must be strictly interior. Rays use vertex angles and ±10^−8 radian perturbations. Thin slivers, nearly aligned vertices and near-boundary viewpoints are tolerance-sensitive; no exact rational visibility certificate.

The first intersection defines a wall hit

For each direction from the viewpoint, the calculator intersects the ray with every polygon edge and selects the nearest nonnegative hit. A farther intersection can lie behind a wall and must not be used even if it belongs to the same outer boundary. This nearest-hit rule is the essential difference between visibility and merely joining the viewpoint to all vertices.

The input order must follow the polygon boundary. Unordered points do not define a room, and nonadjacent touching or crossing edges make inside-outside tests ambiguous. The validation rejects those cases rather than guessing a new order that might represent a different shape or remove an intended concavity.

A viewpoint in the shared corner can see the full L-shaped roomView: (0.5,0.5)Room area: 5Visible area ≈ 5
The L polygon has area five. From (0.5,0.5), rays reach the entire room without crossing its boundary. Moving the viewpoint into an arm can hide part of the other arm behind reflex corner (1,1).

The Shortest path inside a simple polygon calculator covers a related task. This page focuses on polygon visibility region calculator from interior viewpoint with the method limits and worked example described below.

Vertex directions require one-sided rays

A ray aimed exactly at a reflex vertex can touch a corner while adjacent directions meet different walls. The sweep therefore includes tiny clockwise and counterclockwise angular perturbations. This captures the visible edge transitions numerically, but it can leave nearly duplicate boundary coordinates around corners.

The fixed angular perturbation is an approximation parameter, not an exact geometric predicate. Very small visible features may be blurred, and a viewpoint extremely close to a wall can magnify roundoff in intersection parameters. The returned area is labeled approximate because the polygon assembled from perturbed rays is not an exact symbolic visibility boundary.

Visibility and route planning answer different questions

An obstructed point can still be reachable along a path that bends around a corner. Visibility asks whether the straight segment is unobstructed, whereas the existing polygon shortest-path calculator asks how to travel through the room. The visible area therefore should not be used as the amount of floor space a mobile agent can eventually visit.

For the default viewpoint, the L-shaped room is star-shaped with respect to the selected point, so the visible area agrees with the room area within tolerance. Moving the viewpoint tests whether the reflex corner creates a hidden region. The boundary table retains sweep order so it can be plotted without inventing additional cross-connections.

A few questions, answered

Does this support holes?

No. A single simple boundary without holes is required.

Why are some neighboring output points very close?

They come from rays immediately before, at and after a vertex direction.

Find your calculator

Start typing to explore the library.