6
$\begingroup$

How do I convert a segment of parabola to a cubic Bezier curve?

The parabola segment is given as a polynomial with two x values for the edges.

My target is to convert a quadratic piecewise polynomial to a Bezier path (a set of concatenated Bezier curves).

$\endgroup$
5
  • $\begingroup$ The title does not reflect the question. $\endgroup$
    – lhf
    Mar 20, 2013 at 19:36
  • $\begingroup$ Fixed that. Thanks. $\endgroup$
    – Yoav
    Mar 20, 2013 at 20:17
  • $\begingroup$ See en.wikipedia.org/wiki/Bézier_curve#Degree_elevation $\endgroup$
    – lhf
    Mar 20, 2013 at 20:58
  • $\begingroup$ See also ams.org/samplings/feature-column/fcarc-bezier $\endgroup$
    – lhf
    Mar 20, 2013 at 22:13
  • $\begingroup$ Just minor correction - I had submitted an edit but it was rejected for not being "substantive," and I don't have the rep to comment. To calculate the first control point the formula should be: $C=(\frac{x_1+x_2}{2},f(x_1)+f'(x_1)\cdot \frac{x_2-x_1}{2})$ Note the minor difference in computing the point's Y component, without which the formula results in an incorrect control point for segments of the parabola where $x1 \neq 0$. The conversion to a cubic Bezier works fine. $\endgroup$
    – Roland
    Nov 19, 2013 at 19:03

2 Answers 2

8
$\begingroup$

You can do this in two steps, first convert the parabola segment to a quadratic Bezier curve (with a single control point), then convert it to a cubic Bezier curve (with two control points).

Let $f(x)=Ax^2+Bx+C$ be the parabola and let $x_1$ and $x_2$ be the edges of the segment on which the parabola is defined.

Then $P_1=(x_1,f(x_1))$ and $P_2=(x_2,f(x_2))$ are the Bezier curve start and end points and $C=(\frac{x_1+x_2}{2},f(x_1)+f'(x_1)\cdot \frac{x_2-x_1}{2})$ is the control point for the quadratic Bezier curve.

Now you can convert this quadratic Bezier curve to a cubic Bezier curve by define the two control points as: $C_1=\frac{2}{3}C+\frac{1}{3}P_1$ and $C_2=\frac{2}{3}C+\frac{1}{3}P_2$.

$\endgroup$
3
  • 1
    $\begingroup$ How would you go about proving your formula for C if you don't mind me asking? $\endgroup$ Jan 6, 2015 at 13:43
  • $\begingroup$ Why would you convert it to a cubic Bezier curve. It seems to me the Quadratic curve is fine, and would execute faster. $\endgroup$ Jan 15 at 9:48
  • $\begingroup$ In some computer graphics use-cases it's easier for users to control a Bézier curve. $\endgroup$
    – Yoav
    Jan 15 at 14:33
5
$\begingroup$

Let $f(x)=ax^2+bx+c$ be the parabola and let $[x_1, x_2]$ be the interval of the segment that you want to convert to cubic Bezier curve. The first step is to convert that segment into a quadratic Bezier curve as follows:

1) The start point is $P_1=(x_1,f(x_1))$ and the end point $P_2=(x_2,f(x_2))$.
2) The control point $C$ should be the intersection point of the tangent lines at $P_1$ and $P_2$. These two tangent lines can be found as

$y=(2ax_1+b)(x-x_1)+y_1$, and
$y=(2ax_2+b)(x-x_2)+y_2$

Solving for the intersection point of above two line equations result in $C=(C_x,C_y)$ as

$C_x=\frac{x_1+x_2}{2}$
$C_y=\frac{x_2-x_1}{2}(2ax_1+b)+f(x_1)$

Once you have the quadratic Bezier curve, the cubic Bezier curve control points can be found as $C_1=\frac13P_1+\frac23C$ and $C_2=\frac23C+\frac13P_2$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .