Graphics Reference
In-Depth Information
First, we add the two fictitious control points to the table:
i
t i
P i
1 .8 ( , )
0
1
(1, 3)
1
1.2
(2, 3)
2
1.7
(3, 4)
3
2.5
(3, 6)
4
3.3
(3, 8)
Now, to evaluate the curve at a particular t -value like t = 2.6, for example,
we determine that t 3
t 4 . This means that we're in the i th segment, where
i = 3. We'll therefore need to evaluate p ( 3, 1 )( t ) ,
2.6
...
, p ( 3, 4 )( t ) .
p ( 3, 1 )( t )=
( t
t 3 )( t
t 4 ) 2
t 4 ) 2 , so
(22.15)
( t 4
t 2 )( t 3
0.8 2
p ( 3, 1 )( 2.6 )=
0.1
·
( 0.8 ) 2 .
(22.16)
1.6
·
In evaluating the other three polynomials, the expressions t
t appear
repeatedly. To write efficient code, you'd want to evaluate these just once and
reuse them often.
t i and t i + 1
22.4.2 Applications of Catmull-Rom Splines
Suppose that you're doing an animation in which you have a moving object,
and you want it at position P i at time t i for i = . . .; the Catmull-Rom spline is
a natural choice. Now suppose you've got an object that's controlled by some
parameter such as a pinwheel whose rotation is specified in degrees at several
key times—say, R ( 0 )= 45, R ( 1 )= 360, and R ( 3 )= 720—and you want to pro-
vide values for R at intermediate times. Again, the Catmull-Rom spline is a natu-
ral choice. Note, however, that if the rotations were specified by R ( 0 )= R ( 1 )= 0
and R ( 3 )= 90, then the Catmull-Rom interpolant, at t = 0.5, would be negative:
The pinwheel would start to spin backward before rushing to spin forward. While
this might give the feeling of anticipation of motion in a cartoon-like animation,
it would be inappropriate for an animation that was supposed to be physically
realistic.
22.5 Cubic B-splines
Cubic B-splines (there are also linear, quadratic, quartic, etc., B-splines, but cubics
are widely used) are similar to Catmull-Rom splines. The key differences are that
the cubic B-spline (a) is C 2 smooth, that is, both its first and second derivatives are
continuous functions, and (b) is noninterpolating, that is, it passes near the control
points, but not through them in general.
Cubic B-splines come in two flavors: uniform and nonuniform. We'll start
with the uniform B-spline. The formula for the cubic B-spline with control points
P 0 ,
...
, P n is
 
 
 
 
Search WWH ::




Custom Search