Home > Degrafa > Degrafa Natural Cubic Spline

Degrafa Natural Cubic Spline

March 16, 2009

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.

About these ads
Categories: Degrafa
  1. JT
    March 16, 2009 at 9:14 am | #1

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

Comments are closed.
Follow

Get every new post delivered to your Inbox.

Join 1,330 other followers

%d bloggers like this: