# Point on a Bezier curve

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

## 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 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 on other sites
All the functions are in the form B(t) = ....
I'm looking for the invert function t = B(x,y) or something like this.

##### Share on other sites
Maybe with an inverse function of every basis function.

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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634044
• Total Posts
3015215
×