Jump to content
  • Advertisement
Sign in to follow this  
celloe

Closest point on cubic bézier curve

This topic is 2697 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to find the point on a cubic bézier curve closest to another external point P, in 2D space. I've read the Graphics Gems explanation on the method and other stuff but the math's way over my head. Specifically I don't really understand how finding the roots of the.. curve's polynomial (am I making sense?) gets you closer to the solution. Would somebody be able to explain this in a 14 year old's terms? (:

Share this post


Link to post
Share on other sites
Advertisement

I'm trying to find the point on a cubic bézier curve closest to another external point P, in 2D space. I've read the Graphics Gems explanation on the method and other stuff but the math's way over my head. Specifically I don't really understand how finding the roots of the.. curve's polynomial (am I making sense?) gets you closer to the solution. Would somebody be able to explain this in a 14 year old's terms? (:



Generally, let the curve be parameterized by (x(t),y(t)) and let P = (p0,p1) be the external point. The vector from the closest point on the curve to P must be normal to the curve, which means that vector is perpendicular to a tangent of the curve. Such a tangent is the derivative (x'(t),y'(t)). The vector from a curve point to P is (x(t)-p0,y(t)-p1). To be perpendicular, the dot product is zero: 0 = x'(t)*(x(t)-p0) + y'(t)*(y(t)-p1) = f(t). When (x(t),y(t)) has polynomial components, f(t) is a polynomial. So the problem reduces to finding roots of f(t). In your case, x(t) and y(t) are degree-3 polynomials, x'(t) and y'(t) are degree-2 polynomials, so f(t) is a degree-5 polynomial. There are no closed-form equations for roots of degree-5, so you must use a numerical method for root finding.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!