Sign in to follow this  
MrSparkle27

Point on a Bezier curve

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this