Skip to main content
2 of 4
Improved formatting, replaced inappropriate tags with appropriate ones
gmvh
  • 3.1k
  • 6
  • 27
  • 45

Closest point on Bezier spline

Given a two-dimensional cubic Bezier spline defined by 4 control-points as described here, is there a way to solve analytically for the parameter along the curve (ranging from 0 to 1) which yields the point closest to an arbitrary point in space?

$$ \mathbf{B}(t) = (1-t)^3 \,\mathbf{P}_0 + 3(1-t)^2 t\,\mathbf{P}_1 + 3(1-t) t^2\,\mathbf{P}_2 + t^3\,\mathbf{P}_3, ~~~~~ t \in [0,1] $$ where P0, P1, P2 and P3 are the four control-points of the curve.

I can solve it pretty reliably and quickly with a divide-and-conquer algorithm, but it makes me feel dirty...

David Rutten
  • 243
  • 1
  • 2
  • 6