# Curves and Surfaces (Advanced Methods in Computer Graphics) Part 2

## Parametric Continuity

In the previous section we saw an example (Fig. 7.2) of a set of piecewise cubic curves joined together to form a single “continuous” curve. Clearly we require higher levels of continuity at the points where two curves meet, in order to get a smooth transition from one polynomial curve on to another.

A parametric curve defined using cubic polynomials as in Eq. 7.8 has the property that the first and second order derivatives exist and are continuous over the interval in which the curve is defined. Two parametric curves PA(t) = (xA(t), yA(t), zA(t)) and PB(t) = (xB(t), yB(t), zb(t)) are said to have C° continuity if they meet at a common point M (Fig. 7.3). That is, there exits valid parametric values t1, t2 such that

If the tangents to the two curves at M also coincide, then the curves have C1 continuity. The tangent direction at M is obtained by differentiating the cubic polynomials with respect to t, and substituting the parametric value for the knot M. We use the following notation for the derivatives of the x-polynomial in Eq. 7.8:

with similar notations for the y-polynomial and the z-polynomial. The vector (xA ‘(t), yA’(t), zA’(t)) gives the tangent direction on the curve A at point P(t). If t denotes time, then this vector represents the velocity of the point P as it moves along the curve A. C1 continuity implies that the velocity of P considered as a point on the curve A at the knot M is the same as its velocity when considered as a point on the curve B:

If two curves are joined with C1 continuity, the point P(t) will have at most finite acceleration as it crosses the knot M. Second order continuity denoted by C2 requires that the second derivatives of both curves at M are equal. That is,

Fig. 7.3 Examples of piecewise cubic curves with different orders of parametric and geometric continuity

The above vectors represent the curvature at M, or equivalently acceleration of the point P(t) if t denotes time. The continuity constraints discussed above are often relaxed to just smoothness constraints that define only the important shape characteristics used for constructing splines. For example, the requirement in Eq. 7.22 to have the same tangent vector for both curves at the joint can be relaxed to the condition that the tangent vectors are just parallel, with possibly unequal magnitudes. The modified constraint can be written as

for some constant ß. Two curves satisfying the above equation are said to have a geometric continuity G1 at the common point M. Note that we can always re-parameterize the curve A by substituting t = ßu in its equation, and the resultant tangent vectors at M would still be equal, satisfying the C1 continuity constraint. The geometric continuity G2 is also similarly defined by introducing a constant of proportionality in Eq. 7.23. The difference between parametric and geometric continuity is illustrated through an example in Fig. 7.3.

In column (a) of Fig. 7.3, the curves A and B meet at M with C0 continuity. The first and the second derivatives of the curves do not meet at the corresponding point. Column (b) shows the curves with C1 continuity at M where the tangent vectors are equal. Correspondingly, the first derivatives of the curves meet at a point. The curves formed using second derivatives are discontinuous. Column (c) shows the curves with G1 continuity where the tangent vectors at M are only parallel but unequal in magnitude. The first derivatives of the curves therefore do not meet at the corresponding point. In column (d), the curves meet with C2 continuity at M. In this case, the first derivatives meet at a common point with C1 continuity. The second derivatives of the curves also meet with C0 continuity. Note that the second derivatives of cubic polynomial curves are always straight lines.

## Hermite Splines

Hermite splines are cubic polynomial interpolation curves passing through two control points P1 = (x1, y1, z1) and P2 = (x2, y2, z2), with the additional requirement that the curve is tangential to the specified directions at the two end points (Fig. 7.4).

In Fig. 7.4a, the required tangent directions at the end points are denoted by m1 and m2 with components (x10, y10, z10) and (x20, y20, z20) respectively. For the interpolating curve, we use the parametric equation given in Eq. 7.8. The control point P1 corresponds to the parameter value of 0, and P2 corresponds to t = 1. The tangent vector components at t are given by

Fig. 7.4 Hermite polynomial interpolation

Similar to Eq. 7.10, we can now write an equation using position coordinates and tangent vector components:

Substituting the parameter values for the end points in the above equation, we have

The basis matrix for Hermite polynomial interpolation is the inverse of the 4 x 4 matrix in the above equation, and is given by

Pre-multiplying the above matrix by T = [1, t, t2, t3], we get the blending functionsf (t) (seeEq. 7.19):

From the above expressions, we get the parametric equation for the Hermite polynomial curve:

Fig. 7.5 Hermite interpolation spline

The tangent vectors m1 and m2 can have arbitrary magnitude if we require only G1 continuity at the end points when two curves are joined together. Increasing the magnitude causes the curve to align closer to the tangent direction. A scale parameter a > 0 for the tangents is introduced into this equation to control the shape of the cubic curve:

a is sometimes referred to as the tension parameter of the curve. An example with four different values of a is shown in Fig. 7.4b. Note that when a = 0, the above equation represents a linear interpolation between P1 and P2.

Given n points (n > 2), we can develop an interpolating spline that passes through all the points by constructing Hermite cubic curves for every consecutive pair of points. The tangent direction at each knot must be carefully specified by the user in such a way that it corresponds to the tangents to curves on both sides of the knot.

In Fig. 7.5, piecewise Hermite polynomial curves are fitted through a set of points. The points are the same as the knots of the interpolation curve shown in Fig. 7.2. The common tangent vectors are all defined as parallel to negative y-axis.

## Cardinal Splines

A cardinal spline is a smooth piecewise cubic polynomial curve that passes through every point except the first and the last in a given set of control points, maintaining first-order continuity at every point. A cardinal spline works very much like a Hermite spline with the exception that the tangent directions are not specified by the user but derived from the control points themselves.

Consider a set of four control points P0, P1, P2, P3 as shown in Fig. 7.6. The tangent at P1 is specified in the direction of the vector P2 — P0, and the tangent at P2 in the direction of the vector P3 — P1. We can now use Eq. 7.31 with m1 = P2 — P0, and m2 = P3 — P1 to generate a Hermite cubic polynomial curve between P1 and P2.

Fig. 7.6 A cardinal spline definition using four points

The scaling parameter a controls the tension of the curve. Without any reference to the tangent directions, the curve’s equation can be rewritten as a function of the control points alone as below.

Writing the coefficients of 1, t, t2, t3 of each blending function in the above equation as columns of a 4 x 4 matrix, we obtain the basis matrix for cardinal splines:

Given a set of n + 2 control pointswe can fit a cubic curve with the above basis matrix to every pair of consecutive control pointswith    tangent    vectors    defined    as

andIn    other    words we need to process overlapping blocks of

four control pointswith    only    the    middle two points used for interpolation at a time.

When a = 0.5, we get a special case of cardinal splines called Catmull-Rom splines. It directly follows from Eq. 7.33 that Catmull-Rom splines are given by the parametric equation:

Fig. 7.7 A Catmull-Rom spline through a set of control points

Figure 7.7 shows a Catmull-Rom spline generated using a set of control points. Compare this figure with the piecewise cubic spline in Fig. 7.2 where the same set of control points was used.