Closest-point search on a subdivision curve (source code)

= Closest-point search on a subdivision curve
{title2=$(P(t)-Q)\cdot P'(t)=0$}

At a regular differentiable interior nearest point of a <parametric curve>, the displacement from the query point is perpendicular to the <tangent vector>. A <branch and bound> search uses distances to certified enclosing <bounding volumes> as lower bounds, and evaluated limit points as upper bounds. Refine the most promising restricted pieces until the upper bound differs from the global lower bound by the chosen distance tolerance. Safeguarded <Newton root-finding iteration> accelerates local candidates, but endpoints, nonregular points, ties and other stationary branches must not be omitted.