\begin{equation*}
\boldsymbol{\dot{x}}_i = \frac{
(\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{equation*}
Parameters
TCB splines are all about inserting the parameters \(T\), \(C\) and \(B\) into this equation.
Tension
see equation 4 in [KB84]
\begin{equation*}
\boldsymbol{\dot{x}}_i = (1 - T_i) \frac{
(\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{equation*}
Continuity
Up to now, the goal was to have a continuous first derivative at the control points, i.e. the incoming and outgoing tangent vectors were identical:
\begin{equation*}
\boldsymbol{\dot{x}}_i = \boldsymbol{\dot{x}}_i^{(-)} = \boldsymbol{\dot{x}}_i^{(+)}
\end{equation*}
This also happens to be the requirement for a spline to be \(C^1\) continuous.
The “continuity” parameter allows us to break this continuity if we so desire, leading to different incoming and outgoing tangent vectors (see equations 5 and 6 in [KB84]):
\begin{align*}
\boldsymbol{\dot{x}}_i^{(-)} &= \frac{
(1 - C_i) (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(1 + C_i) (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}\\
\boldsymbol{\dot{x}}_i^{(+)} &= \frac{
(1 + C_i) (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(1 - C_i) (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{align*}
Bias
see equation 7 in [KB84]
\begin{equation*}
\boldsymbol{\dot{x}}_i = \frac{
(1 + B_i) (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(1 - B_i) (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{equation*}
All Three Combined
see equations 8 and 9 in [KB84]
\begin{align*}
\boldsymbol{\dot{x}}_i^{(+)} &= \frac{
(1 - T_i) (1 + C_i) (1 + B_i) (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(1 - T_i) (1 - C_i) (1 - B_i) (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}\\
\boldsymbol{\dot{x}}_i^{(-)} &= \frac{
(1 - T_i) (1 - C_i) (1 + B_i) (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
(1 - T_i) (1 + C_i) (1 - B_i) (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{align*}
Note: There is an error in equation (6.11) of [Mil] (all subscripts of \(x\) are wrong, most likely copy-pasted from the preceding equation).
To simplify the result we will get later, we introduce the following shorthands (as suggested in [Mil]):
\begin{align*}
a_i &= (1 - T_i) (1 + C_i) (1 + B_i)\\
b_i &= (1 - T_i) (1 - C_i) (1 - B_i)\\
c_i &= (1 - T_i) (1 - C_i) (1 + B_i)\\
d_i &= (1 - T_i) (1 + C_i) (1 - B_i)
\end{align*}
This leads to the simplified equations
\begin{align*}
\boldsymbol{\dot{x}}_i^{(+)} &= \frac{
a_i (\boldsymbol{x}_i - \boldsymbol{x}_{i-1}) +
b_i (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}\\
\boldsymbol{\dot{x}}_i^{(-)} &= \frac{
c_i (\boldsymbol{x}_i - \boldsymbol{x}_{i-i}) +
d_i (\boldsymbol{x}_{i+1} - \boldsymbol{x}_i)
}{2}
\end{align*}
Calculation
helper.py
Same control values as Catmull-Rom …
$\displaystyle \left[\begin{matrix}\boldsymbol{x}_{3}\\\boldsymbol{x}_{4}\\\boldsymbol{x}_{5}\\\boldsymbol{x}_{6}\end{matrix}\right]$
… but three additional parameters per vertex. In our calculation, the parameters belonging to \(\boldsymbol{x}_4\) and \(\boldsymbol{x}_5\) are relevant:
$\displaystyle a_{4} = \left(1 - T_{4}\right) \left(B_{4} + 1\right) \left(C_{4} + 1\right)$
$\displaystyle b_{4} = \left(1 - B_{4}\right) \left(1 - C_{4}\right) \left(1 - T_{4}\right)$
$\displaystyle c_{5} = \left(1 - C_{5}\right) \left(1 - T_{5}\right) \left(B_{5} + 1\right)$
$\displaystyle d_{5} = \left(1 - B_{5}\right) \left(1 - T_{5}\right) \left(C_{5} + 1\right)$
$\displaystyle \boldsymbol{\dot{x}}^{(+)}_{4} = \frac{a_{4} \left(- \boldsymbol{x}_{3} + \boldsymbol{x}_{4}\right)}{2} + \frac{b_{4} \left(- \boldsymbol{x}_{4} + \boldsymbol{x}_{5}\right)}{2}$
$\displaystyle \boldsymbol{\dot{x}}^{(-)}_{5} = \frac{c_{5} \left(- \boldsymbol{x}_{4} + \boldsymbol{x}_{5}\right)}{2} + \frac{d_{5} \left(- \boldsymbol{x}_{5} + \boldsymbol{x}_{6}\right)}{2}$
$\displaystyle \boldsymbol{\dot{x}}^{(+)}_{4} = \frac{\left(1 - B_{4}\right) \left(1 - C_{4}\right) \left(1 - T_{4}\right) \left(- \boldsymbol{x}_{4} + \boldsymbol{x}_{5}\right)}{2} + \frac{\left(1 - T_{4}\right) \left(B_{4} + 1\right) \left(C_{4} + 1\right) \left(- \boldsymbol{x}_{3} + \boldsymbol{x}_{4}\right)}{2}$
$\displaystyle \boldsymbol{\dot{x}}^{(-)}_{5} = \frac{\left(1 - B_{5}\right) \left(1 - T_{5}\right) \left(C_{5} + 1\right) \left(- \boldsymbol{x}_{5} + \boldsymbol{x}_{6}\right)}{2} + \frac{\left(1 - C_{5}\right) \left(1 - T_{5}\right) \left(B_{5} + 1\right) \left(- \boldsymbol{x}_{4} + \boldsymbol{x}_{5}\right)}{2}$
Same as with Catmull-Rom, try to find a transformation from cardinal control values to Hermite control values. This can be used to get the full basis matrix.
$\displaystyle \left[\begin{matrix}\boldsymbol{x}_{4}\\\boldsymbol{x}_{5}\\\boldsymbol{\dot{x}}^{(+)}_{4}\\\boldsymbol{\dot{x}}^{(-)}_{5}\end{matrix}\right]$
From the notebook about uniform Hermite splines:
$\displaystyle {M_\text{H}} = \left[\begin{matrix}2 & -2 & 1 & 1\\-3 & 3 & -2 & -1\\0 & 0 & 1 & 0\\1 & 0 & 0 & 0\end{matrix}\right]$
$\displaystyle {M_{\text{KB},4}} = {M_\text{H}} {M_{\text{KB$,4\to$H}}}$
$\displaystyle \left[\begin{matrix}\boldsymbol{x}_{4}\\\boldsymbol{x}_{5}\\\boldsymbol{\dot{x}}^{(+)}_{4}\\\boldsymbol{\dot{x}}^{(-)}_{5}\end{matrix}\right] = {M_{\text{KB$,4\to$H}}} \left[\begin{matrix}\boldsymbol{x}_{3}\\\boldsymbol{x}_{4}\\\boldsymbol{x}_{5}\\\boldsymbol{x}_{6}\end{matrix}\right]$
If we substitute the above definitions of \(\boldsymbol{\dot{x}}_4\) and \(\boldsymbol{\dot{x}}_5\), we can directly read off the matrix elements:
$\displaystyle {M_{\text{KB$,4\to$H}}} = \frac{1}{2} \left[\begin{matrix}0 & 2 & 0 & 0\\0 & 0 & 2 & 0\\- a_{4} & a_{4} - b_{4} & b_{4} & 0\\0 & - c_{5} & c_{5} - d_{5} & d_{5}\end{matrix}\right]$
$\displaystyle {M_{\text{KB},4}} = \frac{1}{2} \left[\begin{matrix}- a_{4} & a_{4} - b_{4} - c_{5} + 4 & b_{4} + c_{5} - d_{5} - 4 & d_{5}\\2 a_{4} & - 2 a_{4} + 2 b_{4} + c_{5} - 6 & - 2 b_{4} - c_{5} + d_{5} + 6 & - d_{5}\\- a_{4} & a_{4} - b_{4} & b_{4} & 0\\0 & 2 & 0 & 0\end{matrix}\right]$
And for completeness’ sake, its inverse:
$\displaystyle {M_{\text{KB},4}}^{-1} = \left[\begin{matrix}\frac{b_{4}}{a_{4}} & \frac{b_{4}}{a_{4}} & \frac{b_{4} - 2}{a_{4}} & 1\\0 & 0 & 0 & 1\\1 & 1 & 1 & 1\\\frac{- c_{5} + d_{5} + 6}{d_{5}} & \frac{- c_{5} + d_{5} + 4}{d_{5}} & \frac{- c_{5} + d_{5} + 2}{d_{5}} & 1\end{matrix}\right]$
$\displaystyle {b_{\text{KB},4}}^{T} = \frac{1}{2} \left[\begin{matrix}a_{4} t \left(- t^{2} + 2 t - 1\right)\\t^{3} \left(a_{4} - b_{4} - c_{5} + 4\right) + t^{2} \left(- 2 a_{4} + 2 b_{4} + c_{5} - 6\right) + t \left(a_{4} - b_{4}\right) + 2\\t \left(b_{4} + t^{2} \left(b_{4} + c_{5} - d_{5} - 4\right) + t \left(- 2 b_{4} - c_{5} + d_{5} + 6\right)\right)\\d_{5} t^{2} \left(t - 1\right)\end{matrix}\right]$
To be able to plot the basis functions, let’s substitute \(a_4\), \(b_4\), \(c_5\) and \(d_5\) back in (which isn’t pretty):
$\displaystyle {b_{\text{KB},4}}^{T} = \frac{1}{2} \left[\begin{matrix}t \left(B_{4} + 1\right) \left(C_{4} + 1\right) \left(T_{4} - 1\right) \left(t^{2} - 2 t + 1\right)\\t^{3} \left(\left(B_{4} - 1\right) \left(C_{4} - 1\right) \left(T_{4} - 1\right) - \left(B_{4} + 1\right) \left(C_{4} + 1\right) \left(T_{4} - 1\right) - \left(B_{5} + 1\right) \left(C_{5} - 1\right) \left(T_{5} - 1\right) + 4\right) + t^{2} \left(- 2 \left(B_{4} - 1\right) \left(C_{4} - 1\right) \left(T_{4} - 1\right) + 2 \left(B_{4} + 1\right) \left(C_{4} + 1\right) \left(T_{4} - 1\right) + \left(B_{5} + 1\right) \left(C_{5} - 1\right) \left(T_{5} - 1\right) - 6\right) + t \left(T_{4} - 1\right) \left(\left(B_{4} - 1\right) \left(C_{4} - 1\right) - \left(B_{4} + 1\right) \left(C_{4} + 1\right)\right) + 2\\- t \left(t^{2} \left(\left(B_{4} - 1\right) \left(C_{4} - 1\right) \left(T_{4} - 1\right) + \left(B_{5} - 1\right) \left(C_{5} + 1\right) \left(T_{5} - 1\right) - \left(B_{5} + 1\right) \left(C_{5} - 1\right) \left(T_{5} - 1\right) + 4\right) - t \left(2 \left(B_{4} - 1\right) \left(C_{4} - 1\right) \left(T_{4} - 1\right) + \left(B_{5} - 1\right) \left(C_{5} + 1\right) \left(T_{5} - 1\right) - \left(B_{5} + 1\right) \left(C_{5} - 1\right) \left(T_{5} - 1\right) + 6\right) + \left(B_{4} - 1\right) \left(C_{4} - 1\right) \left(T_{4} - 1\right)\right)\\t^{2} \left(B_{5} - 1\right) \left(C_{5} + 1\right) \left(T_{5} - 1\right) \left(t - 1\right)\end{matrix}\right]$
TODO: plot some example curves