0

I have a Cubic Bézier curve. But I have a problem when I need only one point. I have only value from the X-axis and want to find a value that coresponds to Y-axis to that point. Or find the t step, from it I can easely calculate the Y-axis.

Any clue how to do it? Or is there any formula to do this?

Vlg
  • 3
  • 1

2 Answers2

2

Any solution will have to deal with the fact that there may be multiple solutions if the curve is not X monotone. Consider the cubic bezier (0,0),(2,0),(-1,1),(1,1):

As you can see, there are 4 parameter values (and Y coordinates) at which X==1/2.

This means that if you use subdivision (which is probably your simplest solution), then you need to be careful that your initial bounding t values only surround the point you want.

You can also guess what this implies about the order of an algebraic solution.

Community
  • 1
  • 1
MPG
  • 835
  • 4
  • 10
1

A parametric curve extends to any dimension by adding coefficients for those dimensions. Are you sure you've got things straight? It seems like you are using the x-axis as the curve parameter t. The t parameter controls the computations of X- and Y-coordinates by having two cubic equations. Take a look at Wikipedia which provides some pretty neat explanations for the 2D case.

Edit:

Solve as a general third-degree polynomial. Beware that it might have 3 solutions, though.

Cecil Has a Name
  • 4,962
  • 1
  • 29
  • 31
  • Yes I know that t parameter controls the computations of X- and Y-coordinates. I have the value from X-axis and need the corespondig value from the Y-axis but unfortunately I don't know the t. – Vlg Dec 13 '09 at 15:47
  • Use a bisect algorithm to approximate *t*, as heuristic use the distance from the known x-value to the currently computed x value based on current guess of *t*. – Cecil Has a Name Dec 13 '09 at 15:57
  • I thought there's a better solution. But this will have to do the trick ;) thanks bro. – Vlg Dec 13 '09 at 16:06
  • I'm currently looking into a better, matrix-based method. I'll let you know. – Cecil Has a Name Dec 13 '09 at 18:19