Cubic Hermite spline

From testwiki
Revision as of 01:20, 19 April 2024 by imported>InfoManiac297 (Catmull–Rom spline)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Short description Template:Not to be confused

In numerical analysis, a cubic Hermite spline or cubic Hermite interpolator is a spline where each piece is a third-degree polynomial specified in Hermite form, that is, by its values and first derivatives at the end points of the corresponding domain interval.[1]

Cubic Hermite splines are typically used for interpolation of numeric data specified at given argument values x1,x2,,xn, to obtain a continuous function. The data should consist of the desired function value and derivative at each xk. (If only the values are provided, the derivatives must be estimated from them.) The Hermite formula is applied to each interval (xk,xk+1) separately. The resulting spline will be continuous and will have continuous first derivative.

Cubic polynomial splines can be specified in other ways, the Bezier cubic being the most common. However, these two methods provide the same set of splines, and data can be easily converted between the Bézier and Hermite forms; so the names are often used as if they were synonymous.

Cubic polynomial splines are extensively used in computer graphics and geometric modeling to obtain curves or motion trajectories that pass through specified points of the plane or three-dimensional space. In these applications, each coordinate of the plane or space is separately interpolated by a cubic spline function of a separate parameter t. Cubic polynomial splines are also used extensively in structural analysis applications, such as Euler–Bernoulli beam theory. Cubic polynomial splines have also been applied to mortality analysis[2] and mortality forecasting.[3]

Cubic splines can be extended to functions of two or more parameters, in several ways. Bicubic splines (Bicubic interpolation) are often used to interpolate data on a regular rectangular grid, such as pixel values in a digital image or altitude data on a terrain. Bicubic surface patches, defined by three bicubic splines, are an essential tool in computer graphics.

Cubic splines are often called csplines, especially in computer graphics. Hermite splines are named after Charles Hermite.

Interpolation on a single interval

Unit interval [0, 1]

The four Hermite basis functions. The interpolant in each subinterval is a linear combination of these four functions.

On the unit interval [0,1], given a starting point 𝒑0 at t=0 and an ending point 𝒑1 at t=1 with starting tangent 𝒎0 at t=0 and ending tangent 𝒎1 at t=1, the polynomial can be defined by 𝒑(t)=(2t33t2+1)𝒑0+(t32t2+t)𝒎0+(2t3+3t2)𝒑1+(t3t2)𝒎1, where t ∈ [0, 1].

Interpolation on an arbitrary interval

Interpolating x in an arbitrary interval (xk,xk+1) is done by mapping the latter to [0,1] through an affine (degree-1) change of variable. The formula is 𝒑(x)=h00(t)𝒑k+h10(t)(xk+1xk)𝒎k+h01(t)𝒑k+1+h11(t)(xk+1xk)𝒎k+1, where t=(xxk)/(xk+1xk), and h refers to the basis functions, defined below. Note that the tangent values have been scaled by xk+1xk compared to the equation on the unit interval.

Uniqueness

The formula specified above provides the unique third-degree polynomial path between the two points with the given tangents.

Proof. Let P,Q be two third-degree polynomials satisfying the given boundary conditions. Define R=QP, then:

R(0)=Q(0)P(0)=0,
R(1)=Q(1)P(1)=0.

Since both Q and P are third-degree polynomials, R is at most a third-degree polynomial. So R must be of the form R(x)=ax(x1)(xr). Calculating the derivative gives R(x)=ax(x1)+ax(xr)+a(x1)(xr).

We know furthermore that

R(0)=Q(0)P(0)=0,

Template:NumBlk

R(1)=Q(1)P(1)=0,

Template:NumBlk

Putting (Template:EquationNote) and (Template:EquationNote) together, we deduce that a=0, and therefore R=0, thus P=Q.

Representations

We can write the interpolation polynomial as 𝒑(t)=h00(t)𝒑0+h10(t)(xk+1xk)𝒎0+h01(t)𝒑1+h11(t)(xk+1xk)𝒎1 where h00, h10, h01, h11 are Hermite basis functions. These can be written in different ways, each way revealing different properties:

expanded factorized Bernstein
h00(t) 2t33t2+1 (1+2t)(1t)2 B0(t)+B1(t)
h10(t) t32t2+t t(1t)2 13B1(t)
h01(t) 2t3+3t2 t2(32t) B3(t)+B2(t)
h11(t) t3t2 t2(t1) 13B2(t)

The "expanded" column shows the representation used in the definition above. The "factorized" column shows immediately that h10 and h11 are zero at the boundaries. You can further conclude that h01 and h11 have a zero of multiplicity 2 at 0, and h00 and h10 have such a zero at 1, thus they have slope 0 at those boundaries. The "Bernstein" column shows the decomposition of the Hermite basis functions into Bernstein polynomials of order 3: Bk(t)=(3k)tk(1t)3k.

Using this connection you can express cubic Hermite interpolation in terms of cubic Bézier curves with respect to the four values 𝒑0,𝒑0+13𝒎0,𝒑113𝒎1,𝒑1 and do Hermite interpolation using the de Casteljau algorithm. It shows that in a cubic Bézier patch the two control points in the middle determine the tangents of the interpolation curve at the respective outer points.

We can also write the polynomial in standard form as 𝒑(t)=(2𝒑0+𝒎02𝒑1+𝒎1)t3+(3𝒑0+3𝒑12𝒎0𝒎1)t2+𝒎0t+𝒑0 where the control points and tangents are coefficients. This permits efficient evaluation of the polynomial at various values of t since the constant coefficients can be computed once and reused.

Interpolating a data set

A data set, (xk,𝒑k) for k=1,,n, can be interpolated by applying the above procedure on each interval, where the tangents are chosen in a sensible manner, meaning that the tangents for intervals sharing endpoints are equal. The interpolated curve then consists of piecewise cubic Hermite splines and is globally continuously differentiable in (x1,xn).

The choice of tangents is not unique, and there are several options available.

Finite difference

Example with finite-difference tangents

The simplest choice is the three-point difference, not requiring constant interval lengths:

𝒎k=12(𝒑k+1𝒑kxk+1xk+𝒑k𝒑k1xkxk1)

for internal points k=2,,n1, and one-sided difference at the endpoints of the data set.

Cardinal spline

Cardinal spline example in 2D. The line represents the curve, and the squares represent the control points 𝒑k. Notice that the curve does not reach the first and last points; these points do, however, affect the shape of the curve. The tension parameter used is 0.1

A cardinal spline, sometimes called a canonical spline,[4] is obtained[5] if

𝒎k=(1c)𝒑k+1𝒑k1xk+1xk1

is used to calculate the tangents. The parameter Template:Mvar is a tension parameter that must be in the interval Template:Math. In some sense, this can be interpreted as the "length" of the tangent. Choosing Template:Math yields all zero tangents, and choosing Template:Math yields a Catmull–Rom spline in the uniform parameterization case.

Catmull–Rom spline

Template:Cubic interpolation visualisation.svg Template:Seealso

For tangents chosen to be

𝒎k=𝒑k+1𝒑k12

a Catmull–Rom spline is obtained, being a special case of a cardinal spline. This assumes uniform parameter spacing.

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.[6] 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[7] solve this problem, but use a slightly different calculation.[8] In computer graphics, Catmull–Rom splines are frequently used to get smooth interpolated motion between key frames. For example, most camera path animations generated from discrete key-frames are handled using Catmull–Rom splines. They are popular mainly for being relatively easy to compute, guaranteeing that each key frame position will be hit exactly, and also guaranteeing that the tangents of the generated curve are continuous over multiple segments.

Kochanek–Bartels spline

Template:Main A Kochanek–Bartels spline is a further generalization on how to choose the tangents given the data points 𝒑k1, 𝒑k and 𝒑k+1, with three parameters possible: tension, bias and a continuity parameter.

Monotone cubic interpolation

Template:Main If a cubic Hermite spline of any of the above listed types is used for interpolation of a monotonic data set, the interpolated function will not necessarily be monotonic, but monotonicity can be preserved by adjusting the tangents.

Interpolation on the unit interval with matched derivatives at endpoints

Consider a single coordinate of the points 𝒑n1,𝒑n,𝒑n+1 and 𝒑n+2 as the values that a function f(x) takes at integer ordinates x = n − 1, n, n + 1 and n + 2,

pn=f(n)n.

In addition, assume that the tangents at the endpoints are defined as the centered differences of the adjacent points: mn=f(n+1)f(n1)2=pn+1pn12n.

To evaluate the interpolated f(x) for a real x, first separate x into the integer portion n and fractional portion u:

x=n+u,
n=x=floor(x),
u=xn=xx,
0u<1,

where x denotes the floor function, which returns the largest integer no larger than x.

Then the Catmull–Rom spline is[9] f(x)=f(n+u)=CINTu(pn1,pn,pn+1,pn+2)=[1uu2u3][010012012015221212323212][pn1pnpn+1pn+2]=12[u3+2u2u3u35u2+23u3+4u2+uu3u2]T[pn1pnpn+1pn+2]=12[u((2u)u1)u2(3u5)+2u((43u)u+1)u2(u1)]T[pn1pnpn+1pn+2]=12((u2(2u)u)pn1+(u2(3u5)+2)pn+(u2(43u)+u)pn+1+u2(u1)pn+2)=12((u3+2u2u)pn1+(3u35u2+2)pn+(3u3+4u2+u)pn+1+(u3u2)pn+2)=12((pn1+3pn3pn+1+pn+2)u3+(2pn15pn+4pn+1pn+2)u2+(pn1+pn+1)u+2pn)=12(((pn1+3pn3pn+1+pn+2)u+(2pn15pn+4pn+1pn+2))u+(pn1+pn+1))u+pn, where T denotes the matrix transpose. The bottom equality is depicting the application of Horner's method.

This writing is relevant for tricubic interpolation, where one optimization requires computing CINTu sixteen times with the same u and different p.

See also

References

Template:Reflist

  1. Template:Cite book
  2. Template:Cite journal
  3. Template:Cite journal
  4. Template:Cite web
  5. Template:Cite web
  6. Template:Citation
  7. 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.
  8. 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.
  9. Two hierarchies of spline interpolations. Practical algorithms for multivariate higher order splines.