[Math] Quadratic Bezier curves representation as implicit quadratic equation

algebraic-geometrygeometrylinear algebra

A quadratic bezier curve from points P1=(x1, y1) to P3=(x3, y3) with control point P2=(x2, y2) can be represented as parametric quadratic curve P(t) where t is in [0, 1].

$$P(t) = (P_1t + P_2(1 – t))t + (P_2t + P_3(1 – t))(1 – t)
= P_1t^2 + P_2(1 – t)t + P_3(1 – t)^2$$

We can extend the range of t to be all real numbers, from minus infinity to plus infinity, and then we will get a nice curve dividing the plane in two.

I read somewhere, that this infinete curve is either a straight line (if P1, P2 and P3 are colinear) or a parabola. Could you please confirm that?

Since division of plane by a parabola or a line can be expressed by quadratic equation of form:

Point P=(x, y) is 
  on one side  if F(P) > 0
  on the other if F(P) < 0
  on the curve if F(P) == 0
where F(P) = A * x^2 + B * y^2 + C * x * y + D * x + E * y + F

How can we, starting from points P1, P2, P3 calculate the numbers A, B, C,D, E, F?

I think something similar is done in this wolfram demostration http://demonstrations.wolfram.com/FocusAndDirectrixInAQuadraticBezierCurve/

Thank you

Best Answer

Kindly ask Wolfram Alpha to

Collect[Expand[Eliminate[{
  x1*t^2 + x2*t*(1-t)*2 + x3*(1-t)^2 == x,
  y1*t^2 + y2*t*(1-t)*2 + y3*(1-t)^2 == y
}, t]], {x, y}]

and it will tell you

Result

which you can reformulate to something close to

\begin{align*}F(x, y) =&\phantom{+} x^2 (y_1^2-4 y_1 y_2+2 y_1 y_3+4 y_2^2-4 y_2 y_3+y_3^2) \\ &+xy (-2 x_1 y_1+4 x_1 y_2-2 x_1 y_3+4 x_2 y_1-8 x_2 y_2+4 x_2 y_3-2 x_3 y_1+4 x_3 y_2-2 x_3 y_3) \\ &+x (2 x_1 y_1 y_3-4 x_1 y_2^2+4 x_1 y_2 y_3-2 x_1 y_3^2+4 x_2 y_1 y_2-8 x_2 y_1 y_3+4 x_2 y_2 y_3-2 x_3 y_1^2+4 x_3 y_1 y_2+2 x_3 y_1 y_3-4 x_3 y_2^2) \\ &- y^2 (-x_1^2+4 x_1 x_2-2 x_1 x_3-4 x_2^2+4 x_2 x_3-x_3^2) \\ &- y (2 x_1^2 y_3-4 x_1 x_2 y_2-4 x_1 x_2 y_3-2 x_1 x_3 y_1+8 x_1 x_3 y_2-2 x_1 x_3 y_3+4 x_2^2 y_1+4 x_2^2 y_3-4 x_2 x_3 y_1-4 x_2 x_3 y_2+2 x_3^2 y_1) \\ &+(x_1^2 y_3^2-4 x_1 x_2 y_2 y_3-2 x_1 x_3 y_1 y_3+4 x_1 x_3 y_2^2+4 x_2^2 y_1 y_3-4 x_2 x_3 y_1 y_2+x_3^2 y_1^2) \end{align*}

So the parameters of your conic will be

\begin{align*} A =& y_1^{2} - 4 \, y_1 y_2 + 2 \, y_1 y_3 + 4 \, y_2^{2} - 4 \, y_2 y_3 + y_3^{2} \\ B =& x_1^{2} - 4 \, x_1 x_2 + 2 \, x_1 x_3 + 4 \, x_2^{2} - 4 \, x_2 x_3 + x_3^{2} \\ C =& -2 \, x_1 y_1 + 4 \, x_1 y_2 - 2 \, x_1 y_3 + 4 \, x_2 y_1 - 8 \, x_2 y_2 + 4 \, x_2 y_3 - 2 \, x_3 y_1 + 4 \, x_3 y_2 - 2 \, x_3 y_3 \\ D =& 2 \, x_1 y_1 y_3 - 4 \, x_1 y_2^{2} + 4 \, x_1 y_2 y_3 - 2 \, x_1 y_3^{2} + 4 \, x_2 y_1 y_2 - 8 \, x_2 y_1 y_3 \\ &+\, 4 \, x_2 y_2 y_3 - 2 \, x_3 y_1^{2} + 4 \, x_3 y_1 y_2 + 2 \, x_3 y_1 y_3 - 4 \, x_3 y_2^{2} \\ E =& -2 \, x_1^{2} y_3 + 4 \, x_1 x_2 y_2 + 4 \, x_1 x_2 y_3 + 2 \, x_1 x_3 y_1 - 8 \, x_1 x_3 y_2 + 2 \, x_1 x_3 y_3 \\ &-\, 4 \, x_2^{2} y_1 - 4 \, x_2^{2} y_3 + 4 \, x_2 x_3 y_1 + 4 \, x_2 x_3 y_2 - 2 \, x_3^{2} y_1 \\ F =& x_1^{2} y_3^{2} - 4 \, x_1 x_2 y_2 y_3 - 2 \, x_1 x_3 y_1 y_3 + 4 \, x_1 x_3 y_2^{2} + 4 \, x_2^{2} y_1 y_3 - 4 \, x_2 x_3 y_1 y_2 + x_3^{2} y_1^{2} \end{align*}

The above was computed using sage, where I could get the output into the form I needed more easily. This should agree with the first formula, but if it does not, this here is the more reliable one. You can check that $4AB-C^2=0$ which proves that this conic is indeed a parabola.