Catmull-Rom splines

The Catmull-Rom splines is a method that approximate a set of points (named control points) with a smooth polynomial function that is piecewise-defined. One of the properties of the Catmull-Rom spline is that the curve will pass through all of the control points.

Equations

Two points on each side of the desired portion are required. In other words, points \( P_{i-1} \) and \( P_{i+2} \) are needed to calculate the spline between points \(P_i\) and \(P_{i+1}\).

Illustration of the Catmull-Rom splines control points

Given points \(P_{i-1}\), \(P_{i}\), \(P_{i+1}\) and \(P_{i+2}\), the coordinates of a point \(P\) located between \(P_i\) and \(P_{i+1}\) are calculated as:

$$ P = \frac{1}{2} . \left[ \begin{matrix} 1 & t & t^2 & t^3 \end{matrix} \right]. \left[ \begin{matrix} 0 & 2 & 0 & 0 \\ -1 & 0 & 1 & 0 \\ 2 & -5 & 4 & -1 \\ -1 & 3 & -3 & 1 \end{matrix} \right]. \left[ \begin{matrix} P_{i-1} & P_{i} & P_{i+1} & P_{i+2} \end{matrix} \right]^\top $$

General case: tension

The previous equation is a particular case of the general geometry matrix given by the following equation:

$$ P = \left[ \begin{matrix} 1 & t & t^2 & t^3 \end{matrix} \right]. \left[ \begin{matrix} 0 & 1 & 0 & 0 \\ -\tau & 0 & \tau & 0 \\ 2.\tau & \tau-3 & 3-2\tau & -\tau \\ -\tau & 2-\tau & \tau-2 & \tau \end{matrix} \right]. \left[ \begin{matrix} P_{i-1} & P_{i} & P_{i+1} & P_{i+2} \end{matrix} \right]^\top $$

The parameter \(\tau\) modify the tension of the curve. The following figure illustrates the influence of the parameter \(\tau\) on the curve. Note that \(\tau=\frac{1}{2}\) is commonly used (as in the particular case presented previously).

Effect of tension on Catmull-Rom splines

Derivative

As the spline is \(C^1\) continuous it is possible to compute the derivative for any value of \(t\). Moreover, as the definition of the spline is a polynomial, it is quite trivial to compute the derivative at a given point:

$$ P = \left[ \begin{matrix} 0 & 1 & 2.t & 3.t^2 \end{matrix} \right]. \left[ \begin{matrix} 0 & 1 & 0 & 0 \\ -\tau & 0 & \tau & 0 \\ 2.\tau & \tau-3 & 3-2\tau & -\tau \\ -\tau & 2-\tau & \tau-2 & \tau \end{matrix} \right]. \left[ \begin{matrix} P_{i-1} & P_{i} & P_{i+1} & P_{i+2} \end{matrix} \right]^\top $$

Illustration of the derivative of the Catmull-Rom spline

Properties

Examples

Here a simple example of Catmull-Rom spline (and its derivative) created with Matlab:

Simple example of Catmull-Rom spline with MATLAB Derivative of the example of Catmull-Rom spline with MATLAB

Closed-loop trajectory (with its derivative):

Closed-loop example of Catmull-Rom spline with MATLAB Derivative of the closed-loop example of Catmull-Rom spline with MATLAB

Example of 3D Catmull-Rom spline:

Example of 3D trajectory created with Catmull-Rom

Download


Last update : 03/14/2021