CS184 Lecture 20 summary

Cubic Splines

Last time, we considered the problem of passing a cubic curve

x(u) = au3 + bu2 + cu + d

Through two points with specified tangents.

The vector of initial values (x(1), x(0), x'(1), x'(0)) is a linear function of the vector (a, b, c, d) of polynomial coefficients, and this linear function can be given by a 4x4 matrix M. By inverting M, we can write (a, b, c, d) as a linear function of the vector (x(1), x(0), x'(1), x'(0)).

We can also think of the rows of the matrix M-1 as defining a new polynomial basis. That basis gives the polynomial equation directly in terms of the constraints:

x(u) = (2u3 - 3u2 + 1) x(0)
       + (-2u3 + 3u2) x(1)
       + (u3 - 2u2 + u) x'(0)
       + ( u3 - u2) x'(1)

The old basis was just the power basis, where the basis polynomials are powers of u. The new basis consists of polynomials which  are

H0(u) = (2u3 - 3u2 + 1)
H1(u) = (-2u3 + 3u2)
H2(u) = (u3 - 2u2 + u)
H3(u) = (u3 - u2)

This is called a Hermite basis.

Hermite Interpolation for a 3D curve

The above derivation is really in 1D. For a 3D curve, we would specify the endpoint conditions at 3D points, i.e. we would specify:

(x(0), y(0), z(0))
(x(1), y(1), z(1))
(x'(0), y'(0), z'(0))
(x'(1), y'(1), z'(1))

And use the derivation above to compute three cubic curves, x(u), y(u) and z(u). We normally dont care what the magnitude of the tangent vector is at a point, but this method requires us to specify it.

Once we have created a series of Hermite curves between control points, the overall curve will have C1 continuity.

Cardinal Splines

Specifying the tangents at all the intermediate points for Hermite interpolation is a bit of nuisance. We normally want a curve that smoothly passes through all the points, and computing tangents as well is unnecessary. Cardinal splines derive the tangent direction automatically from neighboring points. They also include a parameter t called the tension which is used to specify the tangent magnitude.

To specify a cardinal spline between two control points pk and pk+1, you need the two neighboring points pk-1 and pk+2. The boundary conditions are given as:

p(0) = pk
p(1) = pk+1
p'(0) = 1/2 (1 - t) (pk+1 - pk-1)
p'(1) = 1/2 (1 - t) (pk+2 - pk)

in other words, the endpoint tangent directions are computed from the chords joining the adjacent control points. The tangent magnitude is proportional to (1 - t), where t is the tension parameter. Larger values of t lead to "tighter" curves, which look like they have been stretched over the control points. Smaller values of t lead to curves that wander through the control points in a more relaxed way.

Natural Cubic Splines

Often you dont want to specify the derivatives at all intermediate pointsalong a curve, you simply want them to be the same for the curve on both sides of a via point. If you add the condition that derivatives agree, you get equations like

x1(1) = x2(0) = p1
x1'(1) = x2'(0)
x1''(1) = x2''(0)

That is, 4 equations for each intermediate point. At the two endpoints, if you specify the point location and the first derivative, you get exactly 4n-4 equations, which is enough to specify the parameters of n-1 cubic curves to interpolate all the points. Solving this system yields a natural cubic spline to interpolate the points with C2 continuity.

Its disadvantage is the the entire curve shape depends on all of the via point positions. Changing any one of them changes the entire curve.

Bezier Curves

Bezier curves are a class of approximating splines. They are defined using control points, but do not necessarily pass through all the control points. Instead the control points act as "handles" to define the shape of the curve. The general form of a Bezier curve is

P(u) = Sk pk Bk,n(u)

Where pk is the kth control point, and Bk,n(u) is a Bernstein polynomial:

Bk,n(u) = C(n, k)uk (1 - u)n-k

where C(n, k) is a binomial coefficient.

From the formulae, notice that you need n+1 control points to define a Bezier curve of degree n. Also notice that only one of the Bernstein polynomials is non-zero at u = 0 (namely B0,n(u) which has value 1 at u=0) and only one of them is non-zero at u = 1 (namely Bn,n(u) = 1 at u=1). Because of these conditions, the Bezier curve passes exactly through the first and last control points. But everywhere else, it is a blend of the control points.

Notice also that all the Bernstein polynomials are non-negative in the range u = 0,...,1. And that

Sk Bk,n(u) = (1 + (1-u))n (by the binomial theorem) = 1

That is, every point along a Bezier curve is a convex combination of the control points. Therefore the whole curve lies inside the convex hull of the control points.