Point on a Bezier curve

Started by
4 comments, last by apatriarca 15 years, 8 months ago
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
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.
All the functions are in the form B(t) = ....
I'm looking for the invert function t = B(x,y) or something like this.
Maybe with an inverse function of every basis function.
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.
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.

This topic is closed to new replies.

Advertisement