next up previous
Next: Keyframe Animation Concepts Up: Spline Animator: Smooth Camera Previous: Introduction

Theory

The construction of splines through a particular set of data is fundamental to the functionality of the module. Thus we first embark on a discussion of the technique of splining with uniform cubic splines. The following exposition can be found in more detail in Bartels [1].

figure10

Consider a set of n + 1 data points tex2html_wrap_inline173 through which we wish to draw a curve tex2html_wrap_inline175 as shown in Figure 1. Let tex2html_wrap_inline177 denote the curve segment between points tex2html_wrap_inline179 and tex2html_wrap_inline181 . Then there are n curve segments which are adjoined to yield the curve tex2html_wrap_inline175 . Besides determining the actual curve segments tex2html_wrap_inline187 , we are also interested in guaranteeing certain continuity properties between adjacent curve segments. Thus we require the following definition: If the tex2html_wrap_inline189 through tex2html_wrap_inline191 derivatives are everywhere continuous for a particular curve Y, that curve is said to be tex2html_wrap_inline195 continuous.

It is obvious that we should choose the curve segments tex2html_wrap_inline187 so that the function X is guaranteed to be continuous. However, certain applications require stronger continuity properties for the curve X. In particular, suppose we would like to guarantee that the entire curve X created by adjoining each tex2html_wrap_inline187 is tex2html_wrap_inline195 continuous for some fixed d. Then if each curve segment is tex2html_wrap_inline195 continuous, it is sufficient to guarantee that the curve X is tex2html_wrap_inline195 continuous at the data points tex2html_wrap_inline179 . One technique is to use polynomials for each curve segment tex2html_wrap_inline187 . It is easy to see that polynomials of degree d+1 with appropriate coefficients will always guarantee tex2html_wrap_inline195 continuity at shared data points. For our purposes, we will insist on tex2html_wrap_inline225 continuity hence the use of cubic polynomials for each curve segment (thus the name ``cubic spline'').

Note that, implicitly, tex2html_wrap_inline227 parameterizes the curve tex2html_wrap_inline175 . In particular, we may associate a value tex2html_wrap_inline231 , with each tex2html_wrap_inline179 , so that tex2html_wrap_inline235 . By convention, we will require tex2html_wrap_inline237 and that tex2html_wrap_inline227 satisfy tex2html_wrap_inline241 . Such pairs tex2html_wrap_inline243 are called knots. We define each curve segment tex2html_wrap_inline187 as a cubic polynomial of the following form:

displaymath247

where u is a reparameterization of tex2html_wrap_inline227 so that tex2html_wrap_inline253 . For the remainder of this section we will mainly be concerned with finding the coefficents tex2html_wrap_inline255 , tex2html_wrap_inline257 , tex2html_wrap_inline259 , and tex2html_wrap_inline261 .

Since there are n curve segments, each with four coefficients, we have a total of 4n coefficients to determine. Since we require tex2html_wrap_inline225 continuity we have the following four conditions at each interior data point tex2html_wrap_inline269 :

displaymath271

displaymath273

displaymath275

displaymath277

Since we also require that

displaymath279

displaymath281

we have a total of 4(n-1) + 2= 4n - 2 conditions. Thus, we need two more conditions. A variety of choices are possible for the remaining two conditions. However, we will require that the second derivatives at the endpoints tex2html_wrap_inline285 and tex2html_wrap_inline287 both be zero, so that:

displaymath289

displaymath291

Such a spline is called a natural cubic spline.

In general, it will not be necessary to solve 4n linear equations in 4n unknowns. Thus, for the sake of easing our computational burden, we explore a few more features of the curve tex2html_wrap_inline187 . From the definition of tex2html_wrap_inline187 we have that:

displaymath301

displaymath303

displaymath305

displaymath307

where tex2html_wrap_inline309 and tex2html_wrap_inline311 are the first derivatives of tex2html_wrap_inline187 at tex2html_wrap_inline231 and tex2html_wrap_inline317 respectively. The four equations above may be solved for the coefficients of tex2html_wrap_inline187 yielding:

displaymath321

displaymath323

displaymath325

displaymath327

These observations allow us to avoid solving 4n equations directly. Instead, we only need to find the tex2html_wrap_inline309 , from which we can compute the polynomial coefficients using the equations above.

Recall that at each internal data point we have

displaymath277

or

displaymath335

Substituting (1) we obtain

displaymath339

Simplifying and moving the unknowns to the left gives

displaymath341

We have n-1 such equations corresponding to n-1 internal data points. By our condition that the second derivative at the beginning of the curve must be zero we have

displaymath347

displaymath349

displaymath351

Similarly, the same condition at the end of the curve yields

displaymath353

Combining everything together, we now have n+1 equations in n+1 unknowns (namely, tex2html_wrap_inline359 through tex2html_wrap_inline361 ). We may represent this in matrix form as:

displaymath363

We transform the above matrix to row echelon form by eliminating the first 1 in each row and scaling the diagonal. The following algorithm achieves this:

plain55

Corresponding operations are carried out on the right-hand-side vector by:

plain60

The above operations yield the matrix:

displaymath387

We may then backsubstitue for the tex2html_wrap_inline309 's:

plain71

Once we have the tex2html_wrap_inline309 's all that remains is to solve for the coefficients using the equations in (1) above.

The end result is that for n+1 data points we will generate 4n sets of coefficients corresponding to n cubic polynomials connecting the data points in a tex2html_wrap_inline225 continuous fashion. Since we have reparameterized each curve segment it will also be necessary to store each tex2html_wrap_inline231 and tex2html_wrap_inline317 corresponding to some segment tex2html_wrap_inline187 . The coefficients coupled with the parameterization values are sufficient to evaluate tex2html_wrap_inline175 for any tex2html_wrap_inline241 . Indeed, we first find the appropriate curve segment j where

displaymath423

and evaluate the tex2html_wrap_inline425 spline yielding

displaymath427

where tex2html_wrap_inline429 . We will discuss more carefully when and how our splines should be evaluated in the next section.

The fact that the splines generated above are tex2html_wrap_inline225 gives us the smooth camera motion we desire. In particular, everywhere continuous first derivatives guarantee smooth changes in position while everywhere continuous second derivatives allow for smooth changes in velocity. Unfortunately, the Animator only guarantees tex2html_wrap_inline433 camera paths, which leads to jerky camera movement, particularly when making turns.


next up previous
Next: Keyframe Animation Concepts Up: Spline Animator: Smooth Camera Previous: Introduction

Mitch Roth
Mon Aug 12 18:35:47 ADT 1996