Home > Degrafa > Degrafa Quadratic Spline Overview

Degrafa Quadratic Spline Overview

March 2, 2009

Now that income taxes are done, my limited spare time is back to Degrafa.  The current development is a quadratic spline.  Piecewise cubic polynomials tend to dominate in industry as they produce more eye-pleasing curves with fewer control points.  There is a potential use for piecewise quadratic curves in a Flash environment and that is fast animation.  Some applications require control points to designate a general shape, but the specific qualities are not relevant.  Instead of drawing a precise, static UI element, the application may be drawing something that moves fast such as hair, grass, vines, etc.   Quadratic splines are ideal for these types of organic elements.

As I have twittered about the development, a few people have mentioned that a piecewise quadratic curve can already be constructed in Degrafa using AdvancedQudraticBezier.  The first three control points are interpolated (using the interpolate() method).  Successive control points are interpolated by the join() method.  The sequence of AdvancedQuadraticBezier instances are used to build a sequence of curveTo’s in the command stack.

Yes, this works and in fact the screen shot below provides one example of how it looks.

Quadratic spline (interpolate followed by joins)

Quadratic spline (interpolate followed by joins)

The two drawbacks I see to this approach are first that the initial interpolate has no support for adjustable tension, although this feature is available for the join operation.  Second, the join was intended for static elements in which there was noticeable curvature at the join point.  There are some knot sequences in which a join does not provide as smooth a transition between knots as I would desire for a spline.

My general thoughts for the Degrafa quadratic spline include both a purely interpolative spline (i.e. the spline passes through every data point) as well as an option for having the spline pass through only the first and last data points.  Interior points would only influence the general shape of the spline.  This latter option would probably be the fastest and most suitable for high-speed animation of organic elements.  Both options would have an adjustable tension parameter.

Currently, the general spline code structure is in place and I’ve sketched the algorithm for both parts.  Actually, the algorithm for the latter option above goes back to the late 1970’s, so there is really nothing new under the sun🙂

More to come as development progresses.

%d bloggers like this: