   How to evaluate a Bezier Curve used as mapping function
  Blender uses for example for animations bezier curves. This is though not a normal curve but a mapping function type curve so the shape is limited so the curve is usable to uniquely map an X value to an Y value. Now I implemented a bezier curve like this which is mostly a common bezier curve just that I make sure the required constraints are met. My problem now is though how to evaluate the curve.A bezier curve Bi(t) yields for the i-th segment the (x,y) value for the given position t along the curve. For the mapping though we are not interested in evaluating Bi(t) but actually y=Bi(x). For a given X value there is exactly one t value and vice versa. So the task at hand is to calculate the t value which corresponds to the given X value. Now this boils down to solving the following equation:0 = a*(t**3) + b*(t**2) + c*t + dwhereas the constants a, b, c, and d are:a = p1.x - 3*p2.x + 3*p3.x - p4.xb = 3*p2.x - 6*p3.x + 3*p4.xc = 3*p3.x - 3*p4.xd = p4.x - xwhereas p1, p2, p3 and p4 are the segment end points (p1,p4) and the respective handles (p2,p3) and x the input value with p1.x <= x <= p4.x . From a math article on the website I figured out that this 3rd degree equation can be solved using the following ( using a substitution x=y-b/(3a) ):p = (3*a*c - b**2)/(3*(a**2))q = (2*(b**3))/(27*(a**3)) - (b*c)/(3*(a**2)) + d/awith the discriminantD = (q/2)**2 + (p/3)**3which is positive or 0 due to the restrictions on the curve due to usage as a mapping function (limited in the sense as there can be at max one real solution and 2 imaginary ones). This gives thenu = 3rd-root( -q/2 + 2nd-root(D) )v = 3rd-root( -q/2 - 2nd-root(D) )y = u + vand therefore (after back-substitution)t = y - b/(3*a)Now this does not seem to work at all. Furthermore this contains a square roots and cubic roots.Now what interests me is:- Would this procedure above actually return the correct t to obtain B(t) for a given x?- If not, what did I do wrong?- Is there a better way to evaluate a bezier curve used as mapping function?   