Shapes & spaces

Continuous Frechet distance calculator for two polygonal curves

Compare two oriented polygonal paths while allowing each traversal to pause and change speed.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compare two oriented polygonal paths while allowing each traversal to pause and change speed. Compute a continuous free-space decision and a numerical distance bracket.

THE FORMULAd_F(P,Q)=inf over continuous nondecreasing surjections alpha,beta of max_t ||P(alpha(t))-Q(beta(t))||.

A worked example

P=(0,0),(1,0),(2,0); Q=(0,1),(1,2),(2,1). The distance is 2: Q must pass its peak two units above P, and matching equal horizontal coordinates attains this bound.

Good to know

Two oriented planar polylines of 2–24 vertices; repeated consecutive vertices removed. Quadratic boundary free-space intervals, reachable-interval propagation, decision oracle and bisection to requested absolute tolerance; return numerical lower/upper search bracket plus reachable free-space witness. Tangency-aware comparisons; unresolved tolerance cases reported. No vertex-only surrogate, unordered Hausdorff metric or closed-curve cyclic optimization.

Enter paths in traversal order

Each row describes a planar vertex, and adjacent rows are joined by straight segments. The order is part of the mathematical input: reversing only one path generally changes its distance to the other. Use common coordinate units, such as meters on a projected map. Latitude and longitude are not interchangeable with Euclidean coordinates because their numerical distance does not give a uniform ground distance.

Repeated consecutive vertices describe pauses rather than new geometric segments and can be removed before computation. An interior vertex that bends the path cannot be discarded merely because another vertex lies nearby. Sampling a curved physical route into a polyline creates a modeling approximation separate from the numerical search tolerance used for the polygonal calculation.

Continuous geometry and parameter reachability2P: y = 0Q: peak y = 2Position on PPosition on Qmonotone route
Scroll across to see the full diagram.
The paths need a leash of length two; a monotone free-space route describes a feasible matching.

Compare this with the Discrete Frechet distance calculator for two ordered polylines. Existing source maths-expansion-geometry.ts frechet() uses vertex-pair dynamic programming only and explicitly excludes continuous distance. Compute monotone reachability through continuous segment-pair free-space cells; resegmentation must leave the result invariant.

Understand the leash interpretation

Both travelers begin at their respective first vertices and finish at their respective last vertices. They can move at different speeds and pause, but neither can move backward. At any instant their separation is the leash length; the objective minimizes the largest required length across every possible admissible schedule. The answer is a bottleneck quantity rather than an average discrepancy.

The endpoint distances immediately provide lower bounds. A path that contains an excursion away from the other curve can force a larger interior bound even when the endpoints match well. Two traces occupying almost the same region can still have a substantial distance when they visit landmarks in incompatible orders, which explains why an unordered proximity measure answers a different question.

Build the continuous free space

For a proposed leash length, make one parameter axis for each curve. Every pair of segments defines a rectangular parameter cell. Points in that cell are free when the corresponding interpolated positions lie within the leash length. Its free region is convex because the squared Euclidean separation is a convex quadratic in the two segment parameters.

Solve the quadratic inequalities on cell edges to obtain closed free intervals, including tangent contacts. The decision then propagates reachable interval suffixes across cells in increasing parameter order. Merely marking a cell free loses information about where it can be entered and exited. A valid route through parameter space must increase both coordinates and reach the final corner from the initial corner.

Check the prefilled example

The straight path P runs along y=0 from x=0 to x=2. Curve Q climbs from height one to height two and descends to height one. When Q reaches its middle vertex, every position of P is at least two units away, so every schedule needs a leash of length at least two. This establishes a geometric lower bound independently of the algorithm.

Now let both travelers share the same horizontal coordinate throughout. Their separation equals the height of Q, which never exceeds two. This gives a complete continuous schedule with maximum separation two and proves optimality. The final numerical lower and upper bracket should enclose 2, and their difference should satisfy the requested absolute tolerance when the search terminates successfully.

Read the free-space illustration

The polyline panel shows geometry in the original coordinate plane. The parameter panel shows something different: a position on P horizontally and a position on Q vertically. A bend in the drawn monotone route means that one traveler changes speed relative to the other; a horizontal or vertical portion means that one traveler waits. It is not another physical path.

Free-space boundaries depend on the tested leash length. At a smaller threshold the relevant regions can disconnect or fail to admit a monotone passage even when they appear close visually. Static artwork illustrates the default construction only. The reported witness, threshold and numerical bracket should be read together when assessing an edited input rather than inferring a solution from the example picture.

Separate numerical and model limitations

The implementation accepts two through twenty-four vertices per path after consecutive duplicates are removed. Bisection repeatedly invokes the continuous decision procedure until it obtains the requested bracket or reaches its work limit. An unresolved contact near floating-point precision must remain unresolved; a tiny discriminant should not silently turn a tangency into a large free interval.

Distance scales with coordinate units, so a tolerance of one millionth of a meter is different from one millionth of a kilometer. Translate very large coordinates near the origin before comparison when possible. This reduces cancellation without changing the mathematical result. A numerical bracket concerns the entered polylines and does not certify accuracy of GPS measurements or of the original continuous trajectories.

Choose the comparison that matches the question

Use this calculation when order and motion along complete segments matter, including route matching and ordered trajectory comparison. A vertex-only dynamic program computes discrete Frechet distance and may miss favorable matchings in segment interiors. Adding vertices can change that surrogate even though the geometric polyline remains identical. Continuous free-space propagation avoids that particular dependence on sampling density.

An unordered nearest-point comparison is appropriate when only occupied locations matter, and a time-aligned error is appropriate when physical timestamps must be preserved. Neither allows exactly the same family of schedules. Closed loops require a further choice of cyclic starting point; this page preserves the supplied endpoints and does not optimize over cyclic rotations or silently reverse either curve.

A few questions, answered

Does this compare only vertices?

No. Every straight segment is traversed continuously, and matches can occur in segment interiors.

May a traveler wait?

Yes. Nondecreasing traversal permits pauses, while backward movement is forbidden.

Why return a bracket?

The decision procedure is searched numerically. A lower and upper bound expose the achieved absolute resolution.

Does reversing a path matter?

Reversing one path can change the answer because endpoint pairing and landmark order change.

Find your calculator

Start typing to explore the library.