In the last installment of this series, we left off Hermite splines asking how we should choose the derivatives at end points so that patches line up nicely, in a visually (or any other context-specific criterion) pleasing way.
Cardinal splines solve part of this problem quite elegantly. I say part of the problem because they address only the problem of the first derivative, ensuring that the curve resulting from neighboring patches are -continuous, that is, the patches line up at the same point, and are -continuous, that is, the first derivatives line up as well. We can imagine splines what are (up to) -continuous, that is, patches lining up, and up to the -th derivatives lining up as well.
So, cardinal splines just worry about the first derivative. Recall the Hermite spline equation system:
where and are the wanted derivatives at and , respectively. Cardinal splines will set
where the term will be denoted as from now on (because it is cumbersome to write). We will explain how we get these equations, and come back to in a short while.
Again, for the sake of simplicity, we assume that the are spaced by 1 exactly (so that we have , say, and , , etc., allowing us to ignore scale-related renormalizations). Let us have a look around . The variation between and is . Between and , it is . If we combine the two to have some kind of average (using ) around , we get the following equation around :
which is the first of the above equations. We get the second one exactly in the same way. We rewrite the Hermite system as:
And we solve as if a Hermite system to get .
The term, controlled by a parameter , the “tension”, controls how the derivatives at the end points are boosted or suppressed. Setting yields splines where and they are then called Catmull Rom splines (and please notice that in the linked page, the order is inverse of what we used so far: they use rather than , leading to seemingly reversed equations relative to what I presented so far). The reader may explore the effects of , but personally I find that is conceptually the simpler, and values quite different from zero are hard to interpret geometrically.
The right-hand side containing terms in may seem “non-canonical” to some, but we can move this computation into the matrix (that, until now, has been the same as with Hermite splines).
First we have to find that
We can re-write the Hermite system using the above “input transformation” matrix:
combining and the input transform matrix, say :
Which yields the desired solution.
So, what does it look like, when we actually finally compute the spline?
Let us take 4 “random points”: . Using the last solution above, we find that .
The points are shown in black; as is the spline. The derivatives are shown using arrows, one in purple (averaging the red and the blue vectors), and one in cyan (averaging the blue and the green vectors). We see that both ends of the spline line up with the arrows (which is expected) and that the spline varies rather smoothly between its two extremes.
The cardinal spline (with therefore ) seems to be doing well, but it is not (or more) continuous. How can we add more constraints to the equation system to yield splines with a higher continuity?
To be continued…