Page 5: Cardinal Cubics and Interpolation

CS559 Spring 2023 Sample Solution

There are (at least) two problems with using Hermite segments to create a $C(1)$ curve:

  1. We need to determine what the derivatives are at the beginning and end of every segment.
  2. Thinking in terms of derivatives can be hard - we’re combining positions (that are good to think about) with vectors/directions (which are less clear, especially when we need to consider what their lengths mean).

One simple approach: we compute reasonable values for the derivatives based on the positions of the points. This approach is called a cardinal spline in graphics. It is a spline, because we are making a curve by a set of polynomial pieces, and I cannot tell you why it is called a cardinal (I cannot find anything on the history of the term).

To interpolate a chain of points $\mathbf{p_0}$, $\mathbf{p_1}$, $\mathbf{p_2}$, etc., we will create a cubic segment between each neighboring pair. To specify the cubic, we will use the Hermite form: the cubic will interpolate its endpoints, and we will compute the derivatives based on the positions of the points. Importantly, we will use the neighboring points in this process so that we compute values that make the overall curve $C(1)$.

Cardinal Form

Consider the points $\mathbf{p_0}$, $\mathbf{p_1}$, $\mathbf{p_2}$, and $\mathbf{p_3}$. To start, we focus on the segment between $\mathbf{p_1}$ and $\mathbf{p_2}$ - it will be a cubic curve. We know the beginning and end, but we need to compute the derivatives.

We will compute the derivative at a point (say $\mathbf{p_i}$) by taking the vector between the previous point ($\mathbf{p_{i-1}}$) and the next point ($\mathbf{p_{i+1}}$) and scaling it by some value $s$. To start with, we will simply make $s=1/2$ because this is the common value.

So, in the example, $\mathbf{p’_1} = \frac{1}{2} (\mathbf{p_2} - \mathbf{p_0})$. In a picture…

drawings/cardinal-1.png

We do the same thing for the ending point $\mathbf{p_2}$.

drawings/cardinal-2.png

Notice that the curve segment wiggles. The derivative at $\mathbf{p_2}$ points to the right, so the curve must enter $\mathbf{p_2}$ from the left.

One counter-intuitive thing is that for the list of 4 points, $\mathbf{p_0}$, $\mathbf{p_1}$, $\mathbf{p_2}$, and $\mathbf{p_3}$, the curve actually connects $\mathbf{p_1}$ and $\mathbf{p_2}$. The other points $\mathbf{p_0}$ and $\mathbf{p_3}$ are only used to compute the derivatives.

If we add another point $\mathbf{p_4}$, we can do the same thing for points $\mathbf{p_1}$, $\mathbf{p_2}$, $\mathbf{p_3}$, and $\mathbf{p_4}$ to draw the “next” curve segment. Notice that the derivative computation for $\mathbf{p_2}$ is the same whether the point is the beginning or the end of the segment.

drawings/cardinal-3.png

Here, we have drawn the 2 segments of the curve - they meet with C(1) continuity. I drew the segments in different colors, but we can consider them together as a combined spline that interpolates the points.

You might wonder what to do about the beginning and the end. How do we draw a curve that includes (in this example) $\mathbf{p_0}.$ Here are a few options:

  1. Don’t draw those ending segments. The spline doesn’t interpolate its endpoints.
  2. Do something special at the endpoints. Either treat the derivative as 0, or use the endpoint twice (so the derivative $\mathbf{p’_0}$ would be $\mathbf{p_1}-\mathbf{p_0}$ or $s(\mathbf{p_1}-\mathbf{p_0})$).
  3. Use it for loops where the end connects to the beginning - so there is always a next point. We’ll do this next week.

Here is an example of #2. I chose to repeat the endpoint.

drawings/cardinal-4.png

I should also note: the actual curves I am drawing have a scaling on the derivatives,

Cardinal Splines

The trick to cardinal splines is that we compute the derivatives at any point based on the previous and next point.

$$ \mathbf{p'_i} = s\bigg(\mathbf{p_{i+1}} - \mathbf{p_{i-1}}\bigg) $$

The parameter $s$ determines how big the derivatives are. For some historical reasons, it is often written in terms of another parameter $t$ (the tension) where $s=\frac{1-t}{2}$.

For the special case of $t=0$ or $s=1/2$, we call this a “Catmull-Rom” spline. This is named after Edwin Catmull (and Raphael Rom). Ed Catmull was the founder of Pixar and invented an amazing number of things in computer graphics (many of which we will learn over the course of the semester).

Cardinal splines are nice because we can use them to interpolate a set of points with $C(1)$ continuity. They are local, as any place on the curve only depends on 4 points. So, if you have a big long chain, changing something at the beginning doesn’t cause a problem at the end.

You will see more cardinal splines in the future. They are a common way to do interpolation in computer graphics.

Advanced Cardinal Splines

The important intuition for Cardinal splines: we give up some control for convenience. Comparing to Hermite curves, we get the convenience of not having to specify deriviatives and always getting C(1) continuity. But we lose the flexibility to specify what happens in between the points.

The tension parameter gives use some control of the curve - and a glimpse of what we might do to create a fancier kind of spline that keeps some of the ease of use of Cardinals, but a little more control.

Generally, a Cardinal spline uses the same tension value for the whole curve. However, we could specify a tension value for each point. By default, they can all be zero - since usually that’s what we want. But, we have the option of having more or less tension in places if we want.

Taking this a step farther… we can break the symmetry of the derivatives at each point. Rather than using the same vector for both the incoming and outgoing segments, we can compute different ones. This allows us to break C(1) continuity if we want.

A common variety of advanced cardinal spline is called a tension, continuity, bias (TCB) curve. For each point, we specify three values (tension, continuity, bias), allowing the design to control how much the curve deviates from being C(1). TCB curves (like Cardinals) are chains of Hermite segments, where the derivatives are computed from the neighboring points. The only difference is that the derivatives are computed by slighty more complex formulas that have extra parameters (continuity and bias). TCB curves (also known as Kochanek–Bartels splines) are popular for defining motions in computer animation because they give a good balance between convenience and control. You can read more about them on the Wikipedia page.

Beyond Interpolating Curves

A key problem with Catmull-Rom, or more generally cardinal splines, or even more generally any interpolation scheme, is that while interpolation tells us where the curve goes at specific points, it provides less control over what happens between those points. For example, notice how in the example image above, the curve dips below the line of points ($\mathbf{p_0}$ $\mathbf{p_1}$). Here is another example:

drawings/cardinal-outside.png

Notice that to pass through point 3, the curve has to dip below the line.

To get better control, we often prefer to use forms of curves that do not interpolate all of their control points. On the next page we will learn about a very popular form of non-interpolating curves.

Next: Bézier Curves

There are no points associated with this page.