# Find Quadratic Bezier curve equation based on its control points

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?

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$.

• Thank you very much, bubba! It's what I need! Very useful! – Ilya Jul 15 '15 at 8:16
• 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.) – Ilya Jul 17 '15 at 8:54
• 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. – bubba Jul 19 '15 at 7:42
• Like this one: math.stackexchange.com/questions/530310/… – bubba Jul 20 '15 at 3:52
• 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? – Ilya Jul 20 '15 at 18:13

$$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$$
$$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$$