MarketCatmull–Rom spline
Company Profile

Catmull–Rom spline

Catmull–Rom spline is a special case of a cardinal spline. This assumes uniform parameter spacing. For tangents chosen to be

Definition (by Catmull and Rom)
Referenced paper The model of the spline is: : \mathbf{F}(t) = \sum_{j}^{}{\mathbf{p}}_{j}C_{jk}(t) where {\mathbf{p}}_{j} are defining points, C_{jk}(t) are shifted blending functions C_{0,k}(t) into interval 0 \leq t . Below are, from left, an example of blending functions C_{0,k}(t), its shifted C_{jk}(t), and a curve \mathbf{F}(t). The blending functions are following cardinal functions: : C_{0,k}(t)=\sum_{i=0}^{k} \left[ \prod_{ \begin{array}{c} j=i-k\\ j \ne 0 \end{array} }^{i} \left( \frac{t}{j}+1 \right) \right] w(t+i) Linear Lagrange interpolation is used, so k=1, resulting in: : C_{0,1}(t)=(1-t)w(t)+(1+t)w(1+t) where w(t) is a blending function obtained by shifting the basis functions of a quadratic uniform B-spline. Below are, from the left, blending functions of a quadratic uniform B-spline and the basis functions before shifting. The graphs of each term in C_{0,1}(t) are as follows: Applying this w(t) to C_{0,1}(t): : C_{0,1}(t)= \left\{ \begin{array}{ll} \frac{1}{2}t^3+\frac{5}{2}t^2+4t+2 & for \quad -2 \leq t are obtained. Shifting these to the interval 0 \leq t gives C_{j1}(t), and arrange them into matrix form gives: : \mathbf{F}(t) = \frac{1}{2} \begin{bmatrix} t^3 & t^2 & t & 1 \end{bmatrix} \begin{bmatrix} -1 & 3 & -3 & 1 \\ 2 & -5 & 4 & -1 \\ -1 & 0 & 1 & 0 \\ 0 & 2 & 0 & 0 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_j \\ {\mathbf{p}}_{j+1} \\ {\mathbf{p}}_{j+2} \\ {\mathbf{p}}_{j+3} \end{bmatrix} which coincides with the definition by a cubic Hermite spline. == Properties ==
Properties
Comparison with B-spline A Catmull–Rom spline curve is interpolation that passes through its defining points, whereas a B-spline curve is approximation that do not pass through its control points. Below are, from left, an example of blending functions, basis functions before shifting, and a curve of cubic uniform B-spline. Continuity A Catmull–Rom spline curve is C1 continuous by its definition and the following, but not C2 continuous: : {\mathbf{F}}_k'(1) = \frac{1}{2} \begin{bmatrix} 0 & -1 & 0 & 1 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_{k-1} \\ {\mathbf{p}}_k \\ {\mathbf{p}}_{k+1} \\ {\mathbf{p}}_{k+2} \end{bmatrix} = {\mathbf{F}}_{k+1}'(0) = \frac{1}{2} \begin{bmatrix} -1 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_k \\ {\mathbf{p}}_{k+1} \\ {\mathbf{p}}_{k+2} \\ {\mathbf{p}}_{k+3} \end{bmatrix} : {\mathbf{F}}_k''(1) = \begin{bmatrix} -1 & 4 & -5 & 2 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_{k-1} \\ {\mathbf{p}}_k \\ {\mathbf{p}}_{k+1} \\ {\mathbf{p}}_{k+2} \end{bmatrix} \neq {\mathbf{F}}_{k+1}''(0) = \begin{bmatrix} 2 & -5 & 4 & -1 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_k \\ {\mathbf{p}}_{k+1} \\ {\mathbf{p}}_{k+2} \\ {\mathbf{p}}_{k+3} \end{bmatrix} Self-intersection If the difference in the intervals between the defining points is large in the middle of a curve, cusps or self-intersections may occur. Below is an example of a self-intersection: Converting to Bézier curve Since the matrix form of a cubic Bézier curve is: : \mathbf{P}(t)= \begin{bmatrix} t^3 & t^2 & t & 1 \end{bmatrix} \begin{bmatrix} -1 & 3 & -3 & 1 \\ 3 & -6 & 3 & 0 \\ -3 & 3 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix} \begin{bmatrix} {\mathbf{p_{bz}}}_0 \\ {\mathbf{p_{bz}}}_1 \\ {\mathbf{p_{bz}}}_2 \\ {\mathbf{p_{bz}}}_3 \end{bmatrix} the control points of a cubic Bézier curve equivalent to the Catmull–Rom spline curve are: : \begin{bmatrix} {\mathbf{p_{bz}}}_0 \\ {\mathbf{p_{bz}}}_1 \\ {\mathbf{p_{bz}}}_2 \\ {\mathbf{p_{bz}}}_3 \end{bmatrix} = \begin{bmatrix} -1 & 3 & -3 & 1 \\ 3 & -6 & 3 & 0 \\ -3 & 3 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix} ^{-1} \frac{1}{2} \begin{bmatrix} -1 & 3 & -3 & 1 \\ 2 & -5 & 4 & -1 \\ -1 & 0 & 1 & 0 \\ 0 & 2 & 0 & 0 \end{bmatrix} \begin{bmatrix} {\mathbf{p}}_{k-1} \\ {\mathbf{p}}_k \\ {\mathbf{p}}_{k+1} \\ {\mathbf{p}}_{k+2} \end{bmatrix} = \frac{1}{6} \begin{bmatrix} 0 & 6 & 0 & 0 \\ -1 & 6 & 1 & 0 \\ 0 & 1 & 6 & -1 \\ 0 & 0 & 6 & 0 \end{bmatrix} \begin{bmatrix} \mathbf{p}_{k-1} \\ \mathbf{p}_k \\ \mathbf{p}_{k+1} \\ \mathbf{p}_{k+2} \end{bmatrix} == Extension to Surfaces (bicubic interpolation) ==
Extension to Surfaces ([[bicubic interpolation]])
By taking the cartesian cross product of two Catmull-Rom splines, one can get a bivariate surface that interpolates a grid of points.。 It is a bicubic patch expressed by the following formula: : \mathbf{F}(t,u) = \begin{bmatrix} t^3 & t^2 & t & 1 \end{bmatrix} \mathbf{M} \begin{bmatrix} {\mathbf{p}}_{11} & {\mathbf{p}}_{12} & {\mathbf{p}}_{13} & {\mathbf{p}}_{14} \\ {\mathbf{p}}_{21} & {\mathbf{p}}_{22} & {\mathbf{p}}_{23} & {\mathbf{p}}_{24} \\ {\mathbf{p}}_{31} & {\mathbf{p}}_{32} & {\mathbf{p}}_{33} & {\mathbf{p}}_{34} \\ {\mathbf{p}}_{41} & {\mathbf{p}}_{42} & {\mathbf{p}}_{43} & {\mathbf{p}}_{44} \end{bmatrix} \mathbf{M}^T \begin{bmatrix} u^3 \\ u^2 \\ u \\ 1 \end{bmatrix} where : \mathbf{M}= \frac{1}{2} \begin{bmatrix} -1 & 3 & -3 & 1 \\ 2 & -5 & 4 & -1 \\ -1 & 0 & 1 & 0 \\ 0 & 2 & 0 & 0 \end{bmatrix} The patch interpolates the middle four points. Adjoinging patches have continuity of the first derivative. == Expansion of tension parameter ==
Expansion of tension parameter
In some cases, Catmull–Rom spline is: : \boldsymbol{m}_k = \tau ( \boldsymbol{p}_{k+1} - \boldsymbol{p}_{k-1} ), where the coefficient of the tangent vector 1/2 is replaced with \tau.。 In this case, the definition formula is as follows: : \boldsymbol{p}(t) = \begin{bmatrix} t^3 & t^2 & t & 1 \end{bmatrix} \begin{bmatrix} -\tau & 2-\tau & \tau-2 & \tau \\ 2\tau & \tau-3 & 3-2\tau & -\tau \\ -\tau & 0 & \tau & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \begin{bmatrix} {\boldsymbol{p}}_{k-1} \\ {\boldsymbol{p}}_k \\ {\boldsymbol{p}}_{k+1} \\ {\boldsymbol{p}}_{k+2} \end{bmatrix} The relationship between \tau and the tension parameter of Kochanek–Bartels spline (denoted as \tau_{KB}) is as follows: : \tau = \frac{1-\tau_{KB}}{2} And the control points of the equivalent cubic Bézier curve are as follows: : \begin{bmatrix} {\mathbf{p_{bz}}}_0 \\ {\mathbf{p_{bz}}}_1 \\ {\mathbf{p_{bz}}}_2 \\ {\mathbf{p_{bz}}}_3 \end{bmatrix} = \frac{1}{3} \begin{bmatrix} 0 & 3 & 0 & 0 \\ -\tau & 3 & \tau & 0 \\ 0 & \tau & 3 & -\tau \\ 0 & 0 & 3 & 0 \end{bmatrix} \begin{bmatrix} \mathbf{p}_{k-1} \\ \mathbf{p}_k \\ \mathbf{p}_{k+1} \\ \mathbf{p}_{k+2} \end{bmatrix} == See also ==
tickerdossier.comtickerdossier.substack.com