Then he dropped two in at once, and leant over the bridge to see which of them would come out first; and one of them did; but as they were both the same size, he didn’t know if it was the one which he wanted to win, or the other one. — A. A. Milne
It’s useful to have a way of measuring how different two sticks (or fir cones) are in size, shape, and their position in a river. Yes, we have the Hausdorff distance between sets, but it does not take into account the orientation of sticks. And it performs poorly when the sticks are broken: the Hausdorff distance between these blue and red curves does not capture the disparity of their shapes:
Indeed, is relatively small here, because from any point of red curve one can easily jump to some point of the blue curve, and the other way around. However, this kind of measurement completely ignores the fact that curves are meant to be traveled along in a continuous, monotone way.
There is a concept of distance that is better suited for comparing curves: the Fréchet distance . Wikipedia gives this (folklore) description:
Imagine a dog walking along one curve and the dog’s owner walking along the other curve, connected by a leash. Both walk continuously along their respective curve from the prescribed start point to the prescribed end point of the curve. Both may vary their speed, and even stop, at arbitrary positions and for arbitrarily long. However, neither can backtrack. The Fréchet distance between the two curves is the length of the shortest leash that is sufficient for traversing both curves in this manner.
To get started, let’s compute this distance for two oriented line segments and . The length of the leash must be at least in order to begin the walk, and at least to finish. So,
In fact, equality holds here. In order to bound from above, we just need one parametrization of the segments. Take the parametrization proportional to length:
Then is the quadratic polynomial of . Without doing any computations, we can say the coefficient of is nonnegative, because cannot be negative for any . Hence, this polynomial is a convex function of , which implies that its maximum on the interval is attained at an endpoints. And the endpoints we already considered. (By the way, this proof works in every CAT(0) metric space.)
In general, the Fréchet distance is not realized by constant-speed parametrization. Consider these two curves, each with a long detour:
It would be impractical for the dog and the owner to go on the detour at the same time. One should go first while the other waits for his/her/its turn. In particular, we see symmetry breaking here: even for two perfectly symmetric curves, the Fréchet-optimal parametrizations would not be symmetric to each other.
It is not obvious from the definition of whether it is a metric; as usual, it’s the triangle inequality that is suspect. However, indeed satisfies the triangle inequality. To prove this, we should probably formalize the definition of . Given two continuous maps from into (or any metric space), define
where and range over all nondecreasing functions from onto itself. Actually, we can require and to be strictly increasing (it only takes a small perturbation), which in dog/owner terms means they are not allowed to stop, but can mosey along as slowly as they want. Then we don’t need both and , since
So, given we can pick such that is within of ; then pick such that is within of . Then
and the triangle inequality follows.