6
$\begingroup$

If the 3 control points of the quadratic Bézier curve are known, how do you calculate algebraically the equation of that curve (which is an y=f(x) function)? Let's say I have..

  • P0 (x,y) - startPoint
  • P1 (x,y) - controlPoint
  • P2 (x,y) - endPoint

and I want to get implicit equation for that, something like that:

f(x) = −0.5x^2​​ + 3.5x − 1 (for example).

I've found the fang's solution here, but he says

Although all quadric Bezier curve is part of a certain parabola, not all parabola can be represented as f(x)=ax2+bx+c. So, the first thing you need to do is check if x2=x1+x32. If this check fails, then your quadratic Bezier curve is not a segment of f(x)=ax2+bx+c.

Ok, but if check fails how can I find its equation?

Another article about cubic Bezier is http://www.moshplant.com/direct-or/bezier/math.html Is there any approach for quadratic?

$\endgroup$
5
$\begingroup$

The equation of the curve is $$ \mathbf{C}(t) = (1-t)^2 \mathbf{P}_0 + 2t(1-t)\mathbf{P}_1 + t^2\mathbf{P}_2 $$ If we let $\mathbf{P}_0 = (x_0,y_0)$, $\mathbf{P}_1 = (x_1,y_1)$, $\mathbf{P}_2 = (x_2,y_2)$, then we can write two separate equations for $x$ and $y$: $$ x(t) = (1-t)^2 x_0 + 2t(1-t)x_1 + t^2 x_2 $$ $$ y(t) = (1-t)^2 y_0 + 2t(1-t)y_1 + t^2 y_2 $$

You can rearrange and collect powers of $t$, if you want to: $$ x(t) = (x_0 - 2x_1 + x_2)t^2 + 2(x_1 - x_0)t + x_0 $$ $$ y(t) = (y_0 - 2y_1 + y_2)t^2 + 2(y_1 - y_0)t + y_0 $$ As you mentioned, it is not always possible to write the curve in the form $y=f(x)$. For example, the curve $$ x(t) = (t - \tfrac12)^2 \quad ; \quad y(t) = t - \tfrac12 $$ has equation $x = y^2$. We could write $y = \sqrt x$, but this is only half of the curve (the other half is $y = -\sqrt x$).

However, you can always write a quadratic Bezier curve in the form $g(x,y)=0$, where $g$ is some second-degree function of $x$ and $y$.

$\endgroup$
  • $\begingroup$ Thank you very much, bubba! It's what I need! Very useful! $\endgroup$ – Ilya Jul 15 '15 at 8:16
  • $\begingroup$ Is it possible to clearly jump from this general form x(t)=(x0−2x1+x2)t2+(2x1−2x2)t+x0, y(t)=(y0−2y1+y2)t2+(2y1−2y2)t+y0 to g(x,y)=0 form? (I mean in general case, if we don't know any coefficients.) $\endgroup$ – Ilya Jul 17 '15 at 8:54
  • $\begingroup$ Yes, that process is called "implicitization", and it's pretty easy for quadratic and cubic curves. You'll find answers giving you the details if you search this site or elsewhere. $\endgroup$ – bubba Jul 19 '15 at 7:42
  • $\begingroup$ Like this one: math.stackexchange.com/questions/530310/… $\endgroup$ – bubba Jul 20 '15 at 3:52
  • $\begingroup$ Thank you very much, bubba! But that process isn't so easy for me ;) Now I trying to understand these notes by Tom Sederberg Is it really so easy for quadratic curves? $\endgroup$ – Ilya Jul 20 '15 at 18:13
2
$\begingroup$

thanks for answering but I would like to do a correction in your answer.

Instead of:

$$ x(t) = (x_0 - 2x_1 + x_2)t^2 + (2x_1 - 2x_2)t + x_0 $$ $$ y(t) = (y_0 - 2y_1 + y_2)t^2 + (2y_1 - 2y_2)t + y_0 $$

It should be:

$$ x(t) = (x_0 - 2x_1 + x_2)t^2 + (2x_1 - 2x_0)t + x_0 $$ $$ y(t) = (y_0 - 2y_1 + y_2)t^2 + (2y_1 - 2y_0)t + y_0 $$

$\endgroup$
  • $\begingroup$ You're right. Thanks. I fixed my answer. $\endgroup$ – bubba May 7 '17 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.