Jump to content
  • Advertisement
Sign in to follow this  
MrSparkle27

Point on a Bezier curve

This topic is 3609 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

Hi! How can I get a point on a Bezier curve, for example when selecting a curve with the mouse, or adding a new point to the curve? In general, a point on a Bezier curve is calculated by a function f(t) with a parameter t that defines the length of the curve segment (0...1). How can I compute this parameter t by a point that is on (or near) the curve? Christian

Share this post


Link to post
Share on other sites
Advertisement
Well, u need to calculate it using basis function or a matrix form.
Try looking at http://en.wikipedia.org/wiki/Bezier_curves.
Theres already calculated for u just look for cubic bezier curve.

Share this post


Link to post
Share on other sites
It's mathematically impossible unless you have a lot of restrictions on the values of the curve's CV's. If the values in a given axis always increment (i.e. CV[0].x <= CV[1].x <= CV[2].x <= CV[3].x), then you can solve the curve for t in that axis using the cubic formula. Once you have that, you can plug t back into the y axis equation.

Unfortunately though, it doesn't work without those restrictions, so the best bet is usually a binary search stlye method, but that won't work without the same restrictions as above.

Share this post


Link to post
Share on other sites
I think you can try intersecting the curve with a small circle centered at the mouse position. You probably don't want to require the user to have the mouse exactly on the curve, so this seem to me an acceptable solution. You need to use a numerical method to solve the sixtic curve to find the intersections.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!