Expand description
Exact planar shortest path over a visibility graph.
§Why exact, and what that means here
axiolid-field already answers route questions, but by sampling a grid:
its answer is only as good as the resolution. On a polygon set the shortest
path is exactly computable, because the optimal path is a polyline whose
interior vertices are region or barrier vertices. No discretisation, no
resolution parameter.
“Exact” is a claim about the COMBINATORICS, and it is earned by deciding
every segment-crossing and sidedness question with certified orient2d
rather than a tolerance comparison. Which edges exist in the visibility
graph is therefore exact. The path LENGTH is still a sum of square roots
evaluated in binary64, so it carries ordinary floating-point rounding.
Overstating that as “exact length” would be a false claim, so it is not
made.
§Not a verdict
The kernel owns the region, the graph, the path and the typed unreachable
reason. It does not own why a route was requested, what clearance is
required, or whether a length is acceptable. Same line navigate.rs draws.
§Input size is bounded explicitly
Visibility graph construction is quadratic in vertices and cubic to verify,
so a large input silently becomes a hang. MAX_VERTICES caps it and
oversized input is REFUSED, never truncated: truncating would answer a
different question than the one asked, and the caller would not be told.
The cap is a default, not a law. shortest_path_within takes the
budget as a parameter, because what is affordable depends on the
caller’s deadline rather than on the kernel. And the refusal carries a
PROVEN lower bound — the straight-line distance between the endpoints,
which no route can beat — so an over-budget query still yields a usable
fact instead of only an error.
Structs§
- Cost
Region - A polygon inside which travel costs
factortimes its length. - Distance
Map - Shortest-path distances from every point of a region to the nearest of several targets.
- Farthest
- The greatest distance from a subregion to the nearest target.
- Forced
Walk - The shortest walk from an origin to a target that enters a polygon.
- Length
Interval - A closed interval of lengths.
- Reach
- The nearest target from a point, and the route there.
- Route
- A shortest path and its length.
- Skeleton
- The skeleton: nodes and the edges joining them.
- Skeleton
Node - One node of the skeleton.
- Wall
- A wall edge: which polygon, which ring (0 the outer,
kthek-th hole) and which edge of it (from pointedgeto the next). - Weighted
Forced Walk - The cheapest walk from an origin to a target that enters a polygon, over weighted maps.
- Weighted
Map - Weighted distances to the nearest of several targets, bracketed.
- Weighted
Reach - The nearest target by weighted distance, bracketed, and a walk there.
Enums§
- Farthest
Error - Why no bracket was produced.
- MapError
- Why no distance map was built.
- Node
Kind - What a skeleton node is.
- Route
Error - A malformed query, as opposed to an honest “no route”.
- Skeleton
Error - Why no skeleton was built.
- Unreachable
- Why no path was produced.
Constants§
- MAX_
CELLS - Cells
farthest_pointrefines at most. - MAX_
VERTICES - Maximum vertices, counting region, barrier and endpoint vertices.
- MAX_
WEIGHTED_ NODES - Graph nodes a weighted map builds at most: region, barrier, target and cost-polygon vertices, and the points along cost edges.
Functions§
- distance_
map - A distance map from
targetsoverregion, avoidingbarriers. - distance_
map_ weighted - A distance map whose targets each start at their own distance: the
distance from a point is the least, over targets, of the route’s
length to the target plus the target’s weight (#197). For a way out
that carries the rest of a walk beyond it, such as a stair landing.
With every weight zero it is
distance_map. - distance_
map_ within distance_mapwith a caller-chosen vertex budget.- distance_
map_ within_ weighted distance_map_weightedwith a caller-chosen vertex budget.- farthest_
point - The greatest distance to the nearest target over the points of
subregionin the map’s free space, bracketed to withintolerance. - farthest_
point_ within farthest_pointwith a caller-chosen cell budget.- forced_
walk - The shortest walk from an origin of
fromto a target oftothat entersthrough, bracketed to withintolerance. - forced_
walk_ within forced_walkwith a caller-chosen cell budget.- shortest_
path - Shortest path from
starttogoalinsideregion, avoidingbarriers. - shortest_
path_ within shortest_pathwith a caller-chosen vertex budget.- skeleton
- The skeleton of
region, its boundary sampled at mostspacingapart, keeping the nodes whose nearest walls spread at leastprunetimes their clearance apart (1.5 drops the spurs into right-angled corners; 0 keeps every node). - weighted_
distance_ map - A weighted distance map from
targetsoverregion, avoidingbarriers, with travel insidecostsweighted by their factors and points along cost edges at mostspacingapart. - weighted_
distance_ map_ seeded - A weighted distance map whose targets each start at their own cost:
the distance from a point is the least, over targets, of the weighted
cost of a walk to the target plus the target’s weight (#198), as
crate::distance_map_weightedis for plain maps. With every weight zero it isweighted_distance_map. - weighted_
distance_ map_ seeded_ within weighted_distance_map_seededwith a caller-chosen node budget.- weighted_
distance_ map_ within weighted_distance_mapwith a caller-chosen node budget.- weighted_
farthest_ point - The greatest weighted distance from a subregion to the nearest target
over its points in the free space, bracketed to within
tolerancewhere the map’s own bracket allows: the result is never narrower than the gap between the map’s bounds at the farthest point. - weighted_
farthest_ point_ within weighted_farthest_pointwith a caller-chosen cell budget.- weighted_
forced_ walk - The cheapest walk from an origin of
fromto a target oftothat entersthrough, where both maps weight travel by the same cost regions (#198):forced_walkforWeightedMaps. Origins’ start weights (seecrate::weighted_distance_map_seeded) count. - weighted_
forced_ walk_ within weighted_forced_walkwith a caller-chosen cell budget.