Notes for Monday November 2 class -- Hermite and Catmull-Rom splines

Hermite splines

The Bezier spline assumed that you know the point at the beginning and end of each spline segment, as well as two intermediate influencer points.

If instead you want to start with positions P0 and P1 at both the beginning and end of the spline segment, as well as velocity R0 and R1 at both the beginning and end of the spline segment, then you have a Hermite spline.

The problem to solve remains the same: Convert the four numbers you have along each coordinate into the four cubic polynomial coefficients (a,b,c,d) that will allow you to compute at3+bt2+ct+d.

To do this we need four cubic primitive functions that allow us selective control over different parts of the curve:

function value
at t=0
value
at t=1
velocity
at t=0
velocity
at t=1
2t3-3t2+1 1000
-2t3+3t2 0100
t3-2t2+t 0010
t3-t2 0001
We can use the above functions to describe the value along the spline for any given t:
(2t3-3t2+1) P0 + (-2t3+3t2) P1 + (t3-2t2+t) R0 + (t3-t2) R1
To get the four cubic polynomial coefficients (a,b,c,d) for x,y or z we can rewrite the above as a matrix-vector multiplication:
ax
bx
cx
dx
2 -2 1 1
-3 3 -2 -1
0 0 1 0
1 0 0 0
Px at t=0
Px at t=1
Rx at t=0
Rx at t=1
Now to find each coordinate value x,y or z at a given t, along that spline segment we can just evaluate a cubic polynomial:
x = axt3 + bxt2 + cxt + dx

y = ayt3 + byt2 + cyt + dy

z = azt3 + bzt2 + czt + dz

 

Catmull-Rom splines

If you want a spline that simply goes through a given set of points, you can use the Catmull-Rom spline.

Given a set of points P0, ... Pn-1, we can compute the smooth Catmull-Rom spline segment between Pi and Pi+1 as follows:

ax
bx
cx
dx
-1/2  1  -1/2   0  
3/2 -5/2  0    1  
-3/2  2  1/2   0  
1/2 -1/2  0    0  
Pi-1
Pi
Pi+1
Pi+2

For the first or last segment, Pi-1 or Pi+2, respectively, can just be set to the first point P0 or the last point Pn-1.

To create a looping spline:

  • For the first segment, when i==0: replace Pi-1 by Pn-1
  • For the last segment, when i==n-2: replace Pi+2 by P0

Then, as usual, to find each coordinate value x,y or z at a given t along that spline segment we can just evaluate a cubic polynomial:

x = axt3 + bxt2 + cxt + dx

y = ayt3 + byt2 + cyt + dy

z = azt3 + bzt2 + czt + dz

 

At the end of class we watched some video clips containing CGI effects