How this calculation works
Find a polygonal route with the fewest straight links between two interior points, allowing bends at newly constructed interior locations.
link distance(s,t) = minimum k such that a contained k-segment polygonal path joins s to tA worked example
In the rectangle (0,0),(4,0),(4,2),(0,2), the segment from (0.5,0.5) to (3.5,1.5) stays inside. Its minimum link count is one.
Good to know
Simple integer polygon with3–12vertices, rational strict-interior endpoints, noholes. Exact rational eartriangulation and staged visibility-cell arrangements, capped2500cells/500newlines and2000000visibility tests. Return replayable continuous bend points and a lower bound from prior reachable layers; caps/degeneracies return unresolved. This is not BFS restricted to original polygon vertices.
The objective counts straight pieces
A link is one straight segment of a polygonal path. The minimum-link objective counts these pieces without adding their Euclidean lengths. A route with a slightly greater total distance can be preferable if it uses fewer bends. This makes link distance different from the familiar shortest geometric route inside a room.
A second distinction concerns where bends may lie. The supported mathematical problem allows them at interior points or constructed windows, rather than only at original polygon corners. Restricting the search to a vertex visibility graph can miss a route with fewer links, even when that graph is sufficient for a length-minimizing path.
Compare this with the Shortest path inside a simple polygon calculator. Minimize the number of straight segments with unrestricted interior bend points, rather than Euclidean path length or a vertex-only visibility-graph route.
Visibility starts the construction
The points directly visible from the source form the one-link region. A segment is visible when its entire closed path lies within the permitted polygonal domain. For an interior source, the region boundary can include windows that cut across the polygon rather than follow the original boundary edges.
Those windows separate portions reached after different numbers of straight segments. Passing to the next illumination stage expands visibility through the previous windows. The first stage whose reachable region contains the target provides a lower bound and a constructive route of the same link count. Both parts matter: finding a route alone does not prove its optimality.
Preparing a simple polygon
Enter the boundary vertices in cyclic order without repeating the first vertex at the end. The supported polygon has no holes or self-intersections. The start and target must be strictly interior, so a boundary convention cannot silently alter whether the first or last link is feasible. Degenerate corners and ambiguous contacts may require rejection.
The geometry uses the actual supplied coordinates. Scaling the drawing or rotating it should not alter the minimum link count, but rounding coordinates can change visibility through a narrow passage. Exact rational predicates are particularly useful when a window endpoint lies on a polygon edge; arbitrary visual tolerances should not replace the containment tests.
The rectangular example
The default polygon is convex. In a convex set, every segment joining two of its points lies in that set. The entered start and target therefore connect directly, so a path with one link is feasible. The points differ, which rules out a path consisting of no motion and no links.
Its Euclidean length is square root of ten, but that length is incidental to the objective. Moving the target elsewhere inside the same convex rectangle changes the distance while retaining the one-link result. This illustrates why the calculator reports a link count and bend coordinates separately instead of displaying an ordinary shortest-distance value under a new label.
Replaying a minimum-link witness
Read the returned route as an ordered list beginning at the source and ending at the target. Consecutive pairs define its links. Verify that every link lies in the polygon and that consecutive collinear pieces have been merged; otherwise a route can appear to use more links simply because an unnecessary intermediate point was retained.
The illumination history explains why fewer links were insufficient. In particular, a target outside all earlier reachable layers cannot be joined by an earlier link count. A valid route with two bends is only an upper bound until the corresponding lower-layer exclusion is established. The output should retain both the path witness and its layer certificate.
Why corner-only search is inadequate
A visibility graph whose nodes are the original vertices models routes that bend at those vertices. That is a useful construction for other shortest-path problems, but it is not the general minimum-link state space. Optimal link paths may turn on an interior window, with no original vertex at the turning point.
For that reason, a failed corner-only search cannot establish that an unrestricted link path needs another segment. The supported solver must construct continuous windows or equivalent visibility regions. If the arrangement exceeds its resource cap, the correct status is unresolved. A sampled grid or a convenient vertex route must not be promoted to an exact minimum.
Interpreting ties and domain restrictions
Several paths may attain the same minimum number of links. Their bend locations can even vary over intervals. Returning one replayable witness is sufficient to establish feasibility at the certified count; it does not assert that the displayed path has the smallest length among all minimum-link paths. That secondary optimization is a different request.
Holes, moving obstacles and restricted turning angles are outside this initial model. They change the reachable-region construction and sometimes the computational difficulty. Keep those distinctions explicit when using the route for communication, machining or navigation. The geometric result certifies containment and link count for the entered static polygon, not a physically executable motion plan.
A few questions, answered
Are bends restricted to polygon vertices?
No. The intended problem permits constructed interior bend points and visibility windows.
Is this the shortest route in meters?
No. It minimizes straight-segment count, not total Euclidean length.
Can there be several optimal paths?
Yes. Several bend positions can realize the same minimum link count.
Does a resource error prove no route?
No. It means the bounded visibility construction did not establish an answer.