4
$\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
    There's no reason a cubic polynomial should have the right shape just because it looks similar. Are you okay with an approximation? How good does it need to be, and in what sense?2010-10-16
  • 0
    I need the curve's extremity values and derivatives to be exact, and the polynomial to be a reasonably close match (perceptively speaking. This is for camera paths.). After investigation, 3rd degree really is not enough, because the 4 constraints (y and dy, both sides) already resolves the 4 parameters, and Bezier curves are more tweakable than that. I'll see what I can do with 4rth degree polynomial.2010-10-16
  • 0
    I must be missing something (or maybe two things). First, if the curve is a quadratic Bezier curve, then it is certainly a (degenerate) cubic Bezier curve. Secondly, how can a quadratic Bezier curve have "two bumps" ?? A quadratic Bezier curve is a parabola !2013-01-08
  • 0
    @bubba : my 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
    Wow, what heck is *that*?2011-03-15
  • 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
1

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.