Centripetal Catmull–Rom spline

In computer graphics, the centripetal Catmull–Rom spline is a variant form of the Catmull–Rom spline, originally formulated by Edwin Catmull and Raphael Rom, which can be evaluated using a recursive algorithm proposed by Barry and Goldman. It is a type of interpolating spline (a curve that goes through its control points) defined by four control points $$\mathbf{P}_0, \mathbf{P}_1, \mathbf{P}_2, \mathbf{P}_3$$, with the curve drawn only from $$\mathbf{P}_1$$ to $$\mathbf{P}_2$$.



Definition


Let $$\mathbf{P}_i = [x_i \quad y_i]^T$$ denote a point. For a curve segment $$\mathbf{C}$$ defined by points $$\mathbf{P}_0, \mathbf{P}_1, \mathbf{P}_2, \mathbf{P}_3$$ and knot sequence $$t_0, t_1, t_2, t_3$$, the centripetal Catmull–Rom spline can be produced by:


 * $$\mathbf{C} = \frac{t_2-t}{t_2-t_1}\mathbf{B}_1+\frac{t-t_1}{t_2-t_1}\mathbf{B}_2$$

where


 * $$\mathbf{B}_1 = \frac{t_{2}-t}{t_{2}-t_0}\mathbf{A}_1+\frac{t-t_0}{t_{2}-t_0}\mathbf{A}_2$$
 * $$\mathbf{B}_2 = \frac{t_{3}-t}{t_{3}-t_1}\mathbf{A}_2+\frac{t-t_1}{t_{3}-t_1}\mathbf{A}_3$$
 * $$\mathbf{A}_1 = \frac{t_{1}-t}{t_{1}-t_0}\mathbf{P}_0+\frac{t-t_0}{t_{1}-t_0}\mathbf{P}_1$$
 * $$\mathbf{A}_2 = \frac{t_{2}-t}{t_{2}-t_1}\mathbf{P}_1+\frac{t-t_1}{t_{2}-t_1}\mathbf{P}_2$$
 * $$\mathbf{A}_3 = \frac{t_{3}-t}{t_{3}-t_2}\mathbf{P}_2+\frac{t-t_2}{t_{3}-t_2}\mathbf{P}_3$$

and


 * $$t_{i+1} = \left[\sqrt{(x_{i+1}-x_i)^2+(y_{i+1}-y_i)^2}\right]^{\alpha} + t_i$$

in which $$\alpha$$ ranges from 0 to 1 for knot parameterization, and $$i = 0,1,2,3$$ with $$t_0 = 0 $$. For centripetal Catmull–Rom spline, the value of $$\alpha$$ is $$0.5$$. When $$\alpha = 0$$, the resulting curve is the standard uniform Catmull–Rom spline; when $$\alpha = 1$$, the result is a chordal Catmull–Rom spline. Plugging $$t = t_1$$ into the spline equations $$ \mathbf{A}_1, \mathbf{A}_2, \mathbf{A}_3, \mathbf{B}_1, \mathbf{B}_2,$$ and $$ \mathbf{C}$$ shows that the value of the spline curve at $$t_1$$ is $$\mathbf{C} = \mathbf{P}_1$$. Similarly, substituting $$t = t_2$$ into the spline equations shows that $$ \mathbf{C} = \mathbf{P}_2 $$ at $$t_2$$. This is true independent of the value of $$\alpha$$ since the equation for $$t_{i+1}$$ is not needed to calculate the value of $$\mathbf{C}$$ at points $$t_1$$ and $$t_2$$. The extension to 3D points is simply achieved by considering $$\mathbf{P}_i = [x_i \quad y_i \quad z_i]^T$$a generic 3D point $$\mathbf{P}_i$$ and


 * $$t_{i+1} = \left[\sqrt{(x_{i+1}-x_i)^2+(y_{i+1}-y_i)^2+(z_{i+1}-z_i)^2}\right]^{\alpha} + t_i$$

Advantages
Centripetal Catmull–Rom spline has several desirable mathematical properties compared to the original and the other types of Catmull-Rom formulation. First, it will not form loop or self-intersection within a curve segment. Second, cusp will never occur within a curve segment. Third, it follows the control points more tightly.



Other uses
In computer vision, centripetal Catmull-Rom spline has been used to formulate an active model for segmentation. The method is termed active spline model. The model is devised on the basis of active shape model, but uses centripetal Catmull-Rom spline to join two successive points (active shape model uses simple straight line), so that the total number of points necessary to depict a shape is less. The use of centripetal Catmull-Rom spline makes the training of a shape model much simpler, and it enables a better way to edit a contour after segmentation.

Code example in Python
The following is an implementation of the Catmull–Rom spline in Python that produces the plot shown beneath.