Module frechet
Expand description
Fréchet distance between polylines (#147).
The Fréchet distance is the least leash length that lets two walkers traverse the two curves from start to end, each moving only forward. The discrete version walks vertex to vertex; the continuous version walks along the segments too, and is never larger.
discrete_frechet_distance: the Eiter-Mannila dynamic programme,O(nm)time andO(m)memory, iterative.frechet_at_most: the Alt-Godau decision,O(nm): can the curves be walked with a leash of lengtheps?frechet_distance: the continuous distance. The answer is always one of the critical values of the free space – a distance between two vertices, from a vertex to a segment, or from a point on a segment to two vertices of the other curve at once – so it is the least critical value the decision accepts, found by binary search over the sorted critical values. When there are more thanCANDIDATE_BUDGETof them (there areO(n^2 m + n m^2)), the range is first narrowed by bisection on the decision, so memory stays bounded.
The _2d functions lift the points to z = 0, which changes no distance.
§Rounding
Everything is f64. Critical values are computed in floating point, and
the decision reads its free-space intervals with the same helpers, so at
a vertex-to-vertex or vertex-to-segment critical value the decision sees
exactly the distance the candidate was built from. A passage that opens
at a point equidistant to two vertices is decided by comparing interval
ends, which carry a few units of rounding; there the answer can be the
next larger critical value. Nothing here is certified.
Enums§
- Frechet
Error - Why a Fréchet query was refused.
Constants§
- CANDIDATE_
BUDGET - Critical values held at once before the range is narrowed by bisection.
Functions§
- discrete_
frechet_ distance - Discrete Fréchet distance between the vertex sequences of
aandb. - discrete_
frechet_ distance_ 2d discrete_frechet_distancein the plane.- frechet_
at_ most - Whether the continuous Fréchet distance between
aandbis at mosteps. - frechet_
at_ most_ 2d frechet_at_mostin the plane.- frechet_
distance - Continuous Fréchet distance between the polylines
aandb. - frechet_
distance_ 2d frechet_distancein the plane.