Simplification
Simplifying a curve replaces it by one with fewer vertices, within a given Frechet distance of it.
Simplification to a width
FrechetDist.frechet_simplify_to_width — Function
frechet_simplify_to_width( P, w )Greedy simplification of P with Frechet error about w. From the first vertex, it repeatedly jumps to a far vertex such that the part of P it skips stays within width w of the shortcut (by binary search with frechet_width_exceeds). Returns the simplification and the indices of its vertices in P.
FrechetDist.frechet_simplify_w_exp — Function
frechet_simplify_w_exp( P, w )frechet_simplify_to_width with an exponential search ahead of each binary search, so the cost of a jump depends on its length rather than on the rest of P. Faster when the simplification keeps many vertices; it may choose different vertices.
FrechetDist.frechet_simplify_to_cardin — Function
frechet_simplify_to_cardin( P, sz )Simplifies P by refining the allowed Frechet error until the simplification has at least sz + 2 vertices, or at least half the vertices of P, whichever comes first. The vertices kept are a subset of those of P, in order. Returns the simplification and the indices of the kept vertices in P. Note that the number of vertices returned can be considerably larger than sz.
When the simplification found is exact (Frechet distance zero, for example for a straight track), no curve with more vertices exists at that accuracy, and it is returned even if it has fewer than sz + 2 vertices.
FrechetDist.simplify_morphing_sensitive — Function
simplify_morphing_sensitive( m, factor )Simplifies both curves of m where the morphing leaves slack: a vertex may move by up to (m.lower_bound - r) / factor, where r is the leash length at the vertex; vertices without slack, and their neighbours, stay. Returns the simplified curves (PS, QS). factor must be positive.
Palettes and hierarchies
A palette is a sequence of simplifications of a curve at decreasing widths; a polygon hierarchy stores them so that an approximation of any accuracy can be read off.
FrechetDist.frechet_palette — Function
frechet_paletteThe palette of P, as a vector with one entry per vertex.
FrechetDist.frechet_palette_level — Function
frechet_palette_levelExtract the approximate polygon by specifying a level of the approximation.
FrechetDist.frechet_palette_approx — Function
frechet_palette_approxExtract an approximation to P using the palette, and a width parameter. The output polygon Q has the property that the Frechet distance between P and Q is at most w (it might be smaller).
The approximation provided is fast (i.e., running time proportional to the number of vertices of Q), but the approximation might be of low quality.
FrechetDist.PolygonHierarchy — Type
PolygonHierarchyA hierarchy of simplifications of a curve at decreasing widths, under frechet_measure. It is BasicCompGeometry.PntSeqHierarchy.SimplificationHierarchy; build one with ph_init and query it with ph_approx.
FrechetDist.ph_init — Function
ph_init( P; lock = ReentrantLock() )A polygon hierarchy of P. The lock guards the hierarchy when it is shared between threads. (ph_init( P, lock ) is accepted as well.) P must have static points: the hierarchy (BasicCompGeometry.PntSeqHierarchy) stores PntSeqs.
FrechetDist.ph_approx — Function
ph_approx( ph, w, n_max = 25, resolution = 4.0 )An approximation of the hierarchy's curve with Frechet error at most about w, returned as (curve, width). The hierarchy caches the simplifications it computes, so the result can depend on the calls made before. The returned curve is a copy: changing it does not affect the hierarchy.
FrechetDist.frechet_measure — Constant
frechet_measureThe measure of a polygon hierarchy under the Frechet distance: the width of a subcurve is approximated greedily, simplification is the greedy Frechet simplification, and the quality of a simplification is certified by computing a monotone matching to it. Palettes use the midpoint splitting rule.