[Math] How to calculate the derivative of a Catmull-Rom spline with nonuniform parameterization

derivativesnumerical methodsrecursive algorithmsspline

Allow me to preface this by saying I am not a trained mathematician in any sense, so it's entirely possible I'm missing something rather fundamental. That said, I'm trying to take the derivative of a centripetal or chordal Catmull-Rom spline. Using the uniform equation calculating the tangents for the control points as well as the derivative is very simple. But when you want to make a spline with nonuniform $t$ values, you have to go through this:

Catmull-Rom curve formulation

Arrows indicate that you multiply by the coefficient and add to the adjacent to form the next coefficient up in the pyramid. When you get up to $C$ you have your coordinate on the curve. $P$ values are your control points and $t$ values are calculated with the following:

Parameterization

If I'm just plugging values into $t$ then I can get the curve coordinates, but I need the derivative to do some other calculations. I tried to expand the entire thing manually and take the derivative at $t_1$ and $t_2$, but it was a mess, and I think I did it completely wrong, so I ask here. Looking at the answer here, this person claims to have done it and got these very simple formulas, but the only methodology listed is "mathematica."

How can I get a usable, general derivative? Is it necessary to choose an alpha value beforehand, or can it be done easily without choosing a parameterization type?

Images in this question were borrowed from an answer here.

Best Answer

Denis Kovacs wrote about finding the derivatives here: http://denkovacs.com/2016/02/catmull-rom-spline-derivatives/. He even provides a Matlab code to compute the spline and its derivatives.

Please see his site, here I just quote the solution:

You can use the same pyramid structure to evaluate the tangent C′(t) as well:

\begin{align} A_1' &= \frac{1}{t_1 - t_0}(P_1 - P_0)\\ A_2' &= \frac{1}{t_2 - t_1}(P_2 - P_1)\\ A_3' &= \frac{1}{t_3 - t_2}(P_3 - P_2)\\ \\ B_1' &= \frac{1}{t_2 - t_0}(A_2 - A_1) + \frac{t_2 - t}{t_2 - t_0} A_1' + \frac{t - t_0}{t_2 - t_0} A_2'\\ B_2' &= \frac{1}{t_3 - t_1}(A_3 - A_2) + \frac{t_3 - t}{t_3 - t_1} A_2' + \frac{t - t_1}{t_3 - t_1} A_3'\\ \\ C' &= \frac{1}{t_2 - t_1}(B_2 - B_1) + \frac{t_2 - t}{t_2 - t_1} B_1'(t) + \frac{t - t_1}{t_2 - t_1} B_2'(t) \end{align}

P.S. A and B are the same as your L's were A is the 2nd level and B the 3rd level of the pyramid, see the wiki.

Related Question