I ported the Singularity natural cubic spline to Degrafa over the weekend. Although it is intuitive to think of splines as drawing aides, the natural cubic spline is used primarily as an interpolant. If you believe there is a smooth (polynomial) relationship between data points representing an unknown function to be interpolated, the natural cubic spline is often a good choice. There is some theory that shows the natural cubic spline produces the smoothest curve that fits a data set (with non-overlapping intervals).

The smooth fit can often be obtained with fewer control points, compensating for the extra computation. The spline is piecewise cubic and C-2 continuous at the joins. The second derivatives are zero at the first and last knots (hence the term ‘natural’ cubic spline). The details are discussed in this TechNote.

Since the cubic spline is intended as an interpolation utility, it is located in the com.degrafa.utilities.math package. As an aside, the parameteric spline discussed in the TechNote can produce very eye-pleasing fits of arbitrary data points. Over the long term, I hope to add the ability to approximate non-Bezier splines with quadratic Beziers, allowing the parametric and Catmull-Rom splines to be included in Degrafa as drawing tools.

In the mean time, an extremely simple (non-interactive) demo is available.

View demo.

View source.

### Like this:

Like Loading...

*Related*

Pretty cool – maybe I can get Flex one day to work with Degrafa.