Morphing
A morphing is an encoding of a "matching" between two curves. It is the output of the various Frechet distance computation functions. The package uses the geometric types of BasicCompGeometry (Point, Segment, PntSeq).
Types
FrechetDist.Morphing — Type
MorphingEncoding of a morphing (i.e., matching) between two polygonal curves.
P and Q are the curves the morphing was computed for (for frechet_c_compute and frechet_c_approx, their refinements). They are shared with the inputs, not copied: copy them before modifying them. pes and qes list the matched event points on P and Q, and leash is the largest distance between matched points. Fields that an algorithm does not compute stay at their defaults (ratio, lower_bound, monotone_err, sol_value).
FrechetDist.EventPoint — Type
EventPoint{N,T,PT}One end of a step of a Morphing: a location on a curve. p is the point; i is the vertex (type == PT_VERTEX) or the first vertex of the edge (type == PT_ON_EDGE); t is the position along that edge, from 0 at vertex i to 1 at vertex i + 1; penalty is the vertex offset charged to the event by computations with offsets (frechet_ve_r_compute_ext), 0 otherwise. EventPoint(p, i, type, t) sets the penalty to 0.
FrechetDist.FPointType — Type
FPointTypeThe kind of an EventPoint: PT_VERTEX (at a vertex of the curve) or PT_ON_EDGE (inside an edge).
Functions
FrechetDist.Morphing_monotonize — Function
Morphing_monotonize(m)Turns a morphing into a monotone morphing, by simply not going back, staying in place if necessary. monotone_err of the result is how far a point had to be held back.
The result may share memory with m: if m is already monotone, it is returned itself, not a copy; otherwise the result refers to the same curves m.P and m.Q. Use deepcopy before changing either.
FrechetDist.Morphing_empty — Function
Morphing_emptyReturns an empty morphing (i.e., a constructor).
FrechetDist.Morphing_verify_valid — Function
Morphing_verify_valid( m )Throws an ArgumentError unless m is structurally valid: pes and qes have the same length; each runs from the first to the last vertex of its curve; every event has a coefficient in [0, 1], no NaN, an index within its curve, and a location that agrees with its index and coefficient. Monotonicity is not required (see Morphing_is_monotone).
FrechetDist.Morphing_combine — Function
Morphing_combine( u, v )Takes two morphings u, v (i.e., two parameterizations) and combines them into a single morphing v(u(⋅)): first u, then v.
For example, if u: γ → δ and v: δ → ξ, then the returned morphing is v(u(⋅)): γ → ξ, from u.P to v.Q. The middle curves u.Q and v.P must have the same length (they are normally the same curve).
FrechetDist.Morphing_extract_prm — Function
Morphing_extract_prm
A parameterization is a polygonal curve that starts at (0,0) and
ends at (m,n). The polygonal curve has either positive slope edges,
or vertical or horizontal edges. It can be thought of as a
piecewise linear function from [0,m] to [0,n]. Here m and n are the
lengths of the two given polygons of P and Q, respectively.FrechetDist.Morphing_as_polygons — Function
Morphing_as_polygonsTurns the morphing matching into a "true" matching, by creating two polygons whose edges are directly matched. The output polygons P and Q will definitely have repeated points.
FrechetDist.Morphing_extract_vertex_radii — Function
Morphing_extract_vertex_radii
Computes for each polygon vertex, the length of the longest edge
in the matching attached to it. It is a cheap upper bound on the
local Frechet distance for each vertex (and implicitly the
attached edge).FrechetDist.Morphing_extract_offsets — Function
Morphing_extract_offsetsFrechetDist.Morphing_monotone_leash — Function
Morphing_monotone_leash( m )The leash of Morphing_monotonize(m), computed without building the monotone morphing; m.leash when m is already monotone.
FrechetDist.Morphing_get_max_edges_err — Function
Morphing_get_max_edges_err( m )The pair of edges matched by m where the matching is loosest. For each step on edges P[i] P[i+1] and Q[j] Q[j+1], the error is the largest distance between their endpoints minus the distance between the two segments. Returns (i, j, err) for the largest error, or (-1, -1, 0.0) when no step has a positive one.
Morphings as functions of time
FrechetDist.Morphing_as_polygons_w_times — Function
Morphing_as_polygons_w_times( m )The morphing as two polygons with one vertex per step (Morphing_as_polygons), and a time in [0, 1] for each step: the distance the two points have travelled together so far, divided by the total. Returns (P, Q, t). A step where neither point moves takes no time, so times can repeat. If nothing moves at all, the times are spread evenly.
FrechetDist.Morphing_as_function_w_times — Function
Morphing_as_function_w_times( m )Like Morphing_as_polygons_w_times, but the times follow the arc length of P alone. Returns (P, Q, t): the morphing as two polygons with one vertex per step, and a time in [0, 1] for each vertex, the distance travelled along P so far divided by the total. Steps where P does not move take no time, so times can repeat; a constant P gets all times 0.
FrechetDist.polygons_get_loc_at_time — Function
polygons_get_loc_at_time( P, Q, times, t )The two locations at time t of a morphing given as polygons with one vertex per step and their times (as from Morphing_as_polygons_w_times): interpolates between the two vertices whose times bracket t. Returns (p, q). Times outside [0, 1] give the first or the last pair.
FrechetDist.Morphing_sample_uniformly — Function
Morphing_sample_uniformly( m, n )Samples the morphing at n >= 2 evenly spaced times in [0, 1] (the times of Morphing_as_polygons_w_times). Returns an n × 2N matrix: row k holds the point on P (columns 1:N) and the matching point on Q (columns N+1:2N).
FrechetDist.morphing_profile — Function
morphing_profile( m, n )The leash length along the morphing, at n samples. Returns (X, Y): X runs evenly from 0 to the total distance L that the two points travel (the lengths of the two polygons of Morphing_as_polygons), and Y[k] is the leash length once the points have travelled X[k] together: at the time (k-1)/(n-1) (= X[k] / L) of Morphing_as_polygons_w_times.