Closed-Loop Catmull-Rom Spline
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.