## Name:

Due September 30th, in class

This worksheet is intended as a short 30 min exercise to be done in groups of 2-3 people.

## Catmull-ROM splines

Consider a cubic Catmull-ROM spline with data points at

• $p_0 = (0, 0)^T$

• $p_1 = (1, 1)^T$

• $p_2 = (2, 0)^T$

1) Draw the data points

2) How many segments does the spline have?

3) To ensure C1 continuity, what equations should we use to compute four control points for each interior segment of the spline? What about the endpoints?

4) Compute the control points for segment 0 (the first segment). Draw the control points above.

5) Compute the control points for segment 1 (the second segment). Draw the control points above.

6) Suppose each data point is uniformly spaced such that p0 is at time 0, p1 is at time 1, and p2 is at time 2. What is the value of the curve at p(1.5)?

## Hermite splines

Recall that for Hermite splines, each segment is interpolated using the two endpoints $p_1$ and $p_2$ along with the slopes at each point.

We will derive the process for computing slopes which give us C2 continuity at each input key.

Our goal is to have

$f_i^{''}(1) = f_{i+1}^{''}(0)$

>Our approach is to derive expressions for $f^{''}(0)$ and $f^{''}(1)$ then use these expressions to setup a system of linear equations to solve for $p_i^{'}$

Recall that the equation for interpolating with a Hermite spline is

$f(t) = p_i H_0^3(t) + p_i^{'} H_1^3(t) + p_{i+1}^{'} H_2^3(t) + p_{i+1} H_3^3(t)$

where

\begin{align*} H_0^3(t) &= 1 - 3 t^2 + 2 t^3 \\ H_1^3(t) &= t - 2 t^2 + t^3 \\ H_2^3(t) &= -t^2 + t^3 \\ H_3^3(t) &= 3 t^2 - 2 t^3 \end{align*}
• What is $f^{''}(t)$?

• What is $f_{i+1}^{''}(0)$?

• What is $f_i^{''}(1)$ ?

• We want $f_i^{''}(1) = f_{i+1}^{''}(0)$. Substitute the expressions from the previous two questions into this equation.

• In the previous question, which variables are unknowns and which are known?

• Rearrange the terms from question 4 so that the unknown variables are on the right hand side and the known variables are on the left hand side. This equation tells us the relationship between the input keys and the slopes at each key.

• Suppose we have a Hermite spline with 5 points

```p0 = (0,0,0)
p1 = (1,2,0)
p2 = (3,3,0)
p3 = (6,3,0)
p4 = (8,0,0)```

Plug in these points into your equation for question 6. You can define three equations that we can use to solve for the slopes.

• Put the equations from the previous question in matrix form P = A P'.

$P = \left[ \begin{array}{c} f_{key}(p_0,p_2)\\ f_{key}(p_1,p_3)\\ f_{key}(p_2,p_4) \end{array} \right] A = \left[ \begin{array}{ccccc} a_{11} & a_{12} & a_{13} & 0 & 0\\ 0 & a_{22} & a_{23} & a_{24} & 0\\ 0 & 0 & a_{33} & a_{34} & a_{35} \end{array} \right] P' = \left[ \begin{array}{c} p^{'}_0\\ p^{'}_1\\ p^{'}_2\\ p^{'}_3\\ p^{'}_4 \end{array} \right]$

A is a 3x5 matrix, P' is a 5x3 matrix of the slopes and P is a 3x3 matrix of vectors. What are the values for each row of P? What are the values of each $a_{ij}$?

How can we augment the above matrix to support clamped endpoint conditions?

How can we augment the above matrix to support natural endpoint conditions?