Home > Flex, Math > Closed-Loop Catmull-Rom Spline

Closed-Loop Catmull-Rom Spline

August 19, 2007

Blogging has been slow the last couple weeks, dealing with gigs and migraines, but I found a little time to add closed-loop support to the Catmull-Rom spline. It’s a simple algorithm for adjusting the outer control points for a smooth transition through the first knot, as illustrated below.

The red marker indicates the first auxiliary control point. The green marker indicates the outermost auxiliary control point. The direction of the vector from initial knot to each control point is along the chord emanating from the first knot. The distance from first knot to both the second and next-to-last knots determines the distance along each chord to place the auxiliary control points. The first auxiliary control point is placed along the chord from the first knot to the next-to-last knot, but at a distance equal to that from the first to second knot. The process is reversed for the outermost auxiliary control point.

The graphic illustration should convince you of at least G-1 continuity. What would have to be modified for C-1? Although this approach is easy to illustrate and implement, it is not without issues. You are encouraged to download the code and experiment with different placement srategies for the outer control points.

Check out the online demo here, which includes a link to download the entire Singularity package.

Read the updated TechNote here.

Advertisements
Categories: Flex, Math
  1. b-wier
    August 19, 2007 at 4:18 pm

    cool – wish there was an AS 2 version.

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: