5
$\begingroup$

I've got a 2D quadratic Bézier curve which, by construction, is a f(x) function : no loops, a single solution for each defined x.

Is there a common mean to convert this curve to a 3rd degree polynomial ? 3 should be enough since there can only be two "bumps".

Thanks!

  • 0
    @bubba : m$y$ mistake, I meant cubic.2013-01-08

2 Answers 2

1

Well, it turns out it's not really possible.

The following Processing code shows my results for a 4th order polynomial. The equations of the parameters are from Maple.

float x1 = 10; float y1 = 20; float x3 = 90; float y3 = 50; float d1 = 3; float d3 = 1; float f = 40;  float x2 = 30; float y2 = mouseY;  void draw(){ background(100);    x2 = mouseX;    y2 = mouseY;    noFill();   stroke(0, 0, 0);   bezier(x1, y1,  x1+f, y1+f*d1, x3-f, y3-f*d3,    x3,y3);    stroke(255, 102, 0);    for (float i=x1; i

I'll try with adding the derivative of x2 and adding another point in the middle (with a 5rth order polynomial) but I'm not sure it'll appropriate for my use.

  • 0
    @muntoo : It's an approximation of a Bezier curve using a 4th degree polynomial, given the starting point, the end point, another point in the middle, and two derivatives. Equations are computed by Maple. But yeah it's ugly.2011-03-15
2

I assume you want a polynomial function $y=f(x)$ that has the same shape as your original parametric cubic Bezier curve.

Well, you already have $y$ as a function of $x$, but the function is unpleasant. For a given value of $x$, there is no closed form formula for the corresponding $y$ -- you have to find $y$ numerically (by intersecting a vertical line with the given Bezier curve).

Let's denote this unpleasant function by $y=g(x)$. So, now the problem is just to approximate $g$ by a polynomial $f$. There are lots of standard ways to do this, depending on how you want to measure the approximation error and what extra conditions you want $f$ to satisfy. You say you want exact matching of end points and end tangents.

So, you choose a degree $m$ for $f$. As you say, $m$ will have to be bigger than 4. Then $f$ will have $m+1$ coefficients, which you can determine by solving a system of $m+1$ linear equations. You get 4 equations from the end-point constraints. Pick another $m-3$ points $(x_i,y_i)$ in the interior of the curve, and, for each $i$, write down the equation that expresses the requirement that $y_i = f(x_i)$. Solve the system of linear equations.

One subtlety is that the extra $m-3$ points have to be chosen fairly carefully. You can't just distribute them uniformly, or else $f$ might wiggle badly. They have to be more dense towards the ends of the curve, and less dense in the middle. The "Chebyshev nodes" are a good choice.

This process is called Hermite interpolation if you use derivative information, and Lagrange interpolation if you don't. Both are covered in Wikipedia articles.