Degrafa – Introduction to Splines Part IV
Continuing from part III, a frequently asked question is ‘why cubic splines?’ If it is possible to create quadratic splines and Flash natively supports drawing quadratic Beziers, why not use a quadratic spline? The answer is unfortunately rather technical, but can be broken into two parts. The first is more flexibility. A cubic spline consists of constituent curves that are cubic polynomials, requiring four coefficients to be determined per polynomial. The extra coefficient allows a greater number of continuity conditions to be imposed (including continuity of second derivative). In the case of the Degrafa cubic Bezier spline, we can mix continuity and tension control.
The second reason relates to inflection changes between knots. Quadratic curves have constant curvature as the curvature relates to the value of the second derivative. If you have taken calculus, what is the derivative of a seconddegree polynomial? If you have not taken calculus, then just take it on faith🙂
Sometimes, curves have inflection points or changes between being concave upward to concave downward, for example, between knots. Cubic curves can easily accommodate such changes while quadratics can not.
So, in general, a cubic polynomial is more generalpurpose and more flexible. Another advantage of using cubic Bezier curves for each segment of the spline is that the cubic Bezier can be subdivided into smaller cubic curves, using the deCasteljau algorithm. This is illustrated below
and discussed in this TechNote. Any cubic Bezier can be recursively subdivided into a smaller set of cubic Bezier curves until each small curve is ‘close enough’ to a quadratic curve. A set of quadratic curves is then taken as an approximation to the original cubic curve.
So, the cubic Bezier spline can be approximated by a set of quadratic Bezier curves for each segment. The recursive subdivision process is already incorporated into the standard Degrafa cubic Bezier curve. As we saw in part II, most of the computational logic in the cubic Bezier spline pertained to tangent construction to meet geometric and derivative continuity conditions. The primary computational ‘kernel’ is a standard cubic Bezier curve.
In the original Singuarity implementation, the spline was built on top of a FastBezier class which performed a limited number of subdivisions in order to draw the spline very quickly. This was helpful back in the days of AS 2 in cases where multiple splines were redrawn every frame during a complex, dynamic animation.
For the Degrafa port, the FastBezier class was replaced with the Degrafa cubic Bezier class, allowing the spline to be drawn using the Degrafa rendering pipeline.
So, that answers the questions ‘why cubic splines’ and ‘why cubic Bezier splines in particular’ for the first spline port to Degrafa. The next post in this series will discuss the very important topic of spline parameterization.

December 8, 2008 at 6:47 amDegrafa  Introduction to Splines V « The Algorithmist