Catmull–Rom spline

From testwiki
Jump to navigation Jump to search

Template:Short description Catmull–Rom spline is a special case of a cardinal spline. This assumes uniform spacing of the control points 𝒑k. For tangents chosen to be

𝒎k=𝒑k+1−𝒑k−12

in the definition formula of cubic Hermite spline:

𝒑(t)=(2t3−3t2+1)𝒑k+(t3−2t2+t)𝒎k+(−2t3+3t2)𝒑k+1+(t3−t2)𝒎k+1

the following formula for the Catmull–Rom spline is obtained:

𝒑(t)=12[t3t2t1][−13−312−54−1−10100200][𝒑k−1𝒑k𝒑k+1𝒑k+2]

The curve is named after Edwin Catmull and Raphael Rom. The principal advantage of this technique is that the points along the original set of points also make up the control points for the spline curve.[1]

Example of Catmull–Rom spline[2]

Two additional points are required on either end of the curve. The uniform Catmull–Rom implementation can produce loops and self-intersections. The chordal and centripetal Catmull–Rom implementations[3] solve this problem, but use a slightly different calculation.[4] In computer graphics, Catmull–Rom splines are a common way to create smooth movement between key moments.[5] For example, they’re often used to turn a series of camera keyframes into a fluid camera path.[6]

Definition (by Catmull and Rom)

Referenced paper[1] is for a class of splines passing through their defining points. Graphs and experimental results for the following blending functions are shown, with "case 3" being a Catmull–Rom spline curve. [7]

Interval Width Differentiability Type Degree of Polynomial for Cardinal Function
case 1 3 1 B-SPLINE
case 2 4 2 BEZIER
case 3 4 1 B-SPLINE 1
case 4 6 2 B-SPLINE 2

The model of the spline is:

𝐅(t)=∑j𝐩jCjk(t)

where 𝐩j are defining points, Cjk(t) are shifted blending functions C0,k(t) into interval 0≤t<1.

Below are, from left, an example of blending functions C0,k(t), its shifted Cjk(t), and a curve 𝐅(t).

The blending functions are following cardinal functions: [note 1]

C0,k(t)=∑i=0k[∏j=i−kj≠0i(tj+1)]w(t+i)

Linear Lagrange interpolation is used, so k=1, resulting in:

C0,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 C0,1(t) are as follows:

Applying this w(t) to C0,1(t):

C0,1(t)={12t3+52t2+4t+2for−2≤t<−1−32t3−52t2+1for−1≤t<032t3−52t2+1for0≤t<1−12t3+52t2−4t+2for1≤t<2

are obtained. Shifting these to the interval 0≤t<1 gives Cj1(t), and arrange them into matrix form gives:

𝐅(t)=12[t3t2t1][−13−312−54−1−10100200][𝐩j𝐩j+1𝐩j+2𝐩j+3]

which coincides with the definition by a cubic Hermite spline.

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.[8]

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:

𝐅′k(1)=12[0−101][𝐩k−1𝐩k𝐩k+1𝐩k+2]=𝐅′k+1(0)=12[−1010][𝐩k𝐩k+1𝐩k+2𝐩k+3]
𝐅″k(1)=[−14−52][𝐩k−1𝐩k𝐩k+1𝐩k+2]≠𝐅″k+1(0)=[2−54−1][𝐩k𝐩k+1𝐩k+2𝐩k+3]

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. [note 2]

Below is an example of a self-intersection:

Converting to Bézier curve

Example of converted Bézier curve (red: control points of Bézier curve)

Since the matrix form of a cubic Bézier curve is:

𝐏(t)=[t3t2t1][−13−313−630−33001000][𝐩𝐛𝐳0𝐩𝐛𝐳1𝐩𝐛𝐳2𝐩𝐛𝐳3]

the control points of a cubic Bézier curve equivalent to the Catmull–Rom spline curve are:

[𝐩𝐛𝐳0𝐩𝐛𝐳1𝐩𝐛𝐳2𝐩𝐛𝐳3]=[−13−313−630−33001000]−112[−13−312−54−1−10100200][𝐩k−1𝐩k𝐩k+1𝐩k+2]=16[0600−1610016−10060][𝐩k−1𝐩k𝐩k+1𝐩k+2]

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.[9]。

It is a bicubic patch expressed by the following formula:

𝐅(t,u)=[t3t2t1]𝐌[𝐩11𝐩12𝐩13𝐩14𝐩21𝐩22𝐩23𝐩24𝐩31𝐩32𝐩33𝐩34𝐩41𝐩42𝐩43𝐩44]𝐌T[u3u2u1]

where

𝐌=12[−13−312−54−1−10100200]

The patch interpolates the middle four points. Adjoinging patches have continuity of the first derivative.

Expansion of tension parameter

An example of visual effect of the tension parameter on interpolated motion between keyframes (white circle: keyframe, blue: τ=0.2, green: τ=0.5, red: τ=1.0)

In some cases, Catmull–Rom spline is:

𝒎k=τ(𝒑k+1−𝒑k−1),

where the coefficient of the tangent vector 1/2 is replaced with τ.[10]。

In this case, the definition formula is as follows:

𝒑(t)=[t3t2t1][−τ2−ττ−2τ2ττ−33−2τ−τ−τ0τ00100][𝒑k−1𝒑k𝒑k+1𝒑k+2]

The relationship between τ and the tension parameter of Kochanek–Bartels spline (denoted as τKB) is as follows: [11]

τ=1−τKB2
Example of converted Bézier curve (τ=1.0)

And the control points of the equivalent cubic Bézier curve are as follows:

[𝐩𝐛𝐳0𝐩𝐛𝐳1𝐩𝐛𝐳2𝐩𝐛𝐳3]=13[0300−τ3τ00τ3−τ0030][𝐩k−1𝐩k𝐩k+1𝐩k+2]

See also

Notes

Template:Reflist

References

Template:Reflist

Works cited

  1. ↑ 1.0 1.1 Template:Citation
  2. ↑ Catmull, Rom (1974), p.325 Figure 5
  3. ↑ N. Dyn, M. S. Floater, and K. Hormann. Four-point curve subdivision based on iterated chordal and centripetal parameterizations. Computer Aided Geometric Design, 26(3):279–286, 2009.
  4. ↑ P. J. Barry and R. N. Goldman. A recursive evaluation algorithm for a class of Catmull-Rom splines. SIGGRAPH Computer Graphics, 22(4):199–204, 1988.
  5. ↑ Template:Cite journal
  6. ↑ Template:Cite journal
  7. ↑ Read the Docs - Uniform Catmull–Rom Splines
  8. ↑ Catmull, Rom (1974), p.319
  9. ↑ Catmull, Rom (1974), pp.322-323
  10. ↑ Template:Cite web
  11. ↑ Template:Cite journal


Cite error: <ref> tags exist for a group named "note", but no corresponding <references group="note"/> tag was found.