MrSparkle27 142 Report post Posted July 29, 2008 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 0 Share this post Link to post Share on other sites
ryt 294 Report post Posted July 29, 2008 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. 0 Share this post Link to post Share on other sites
MrSparkle27 142 Report post Posted July 29, 2008 All the functions are in the form B(t) = ....I'm looking for the invert function t = B(x,y) or something like this. 0 Share this post Link to post Share on other sites
ryt 294 Report post Posted July 29, 2008 Maybe with an inverse function of every basis function. 0 Share this post Link to post Share on other sites
RobTheBloke 2553 Report post Posted July 31, 2008 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. 0 Share this post Link to post Share on other sites
apatriarca 2365 Report post Posted August 1, 2008 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. 0 Share this post Link to post Share on other sites