continuous curvature of a spline
continuity of derivatives
The Wikipedia has a nice explanation about Bézier curves.
I use cubic Bézier curves, following dr. Lubos Brieda.
The curve between "knots" \( \mathbf K_i\) and \(\mathbf K_{i+1}\) with control points \(\mathbf P_{1,i}\) and \(\mathbf P_{2,i}\) is described by:
$$
\mathbf B_i(t) = (1-t)^3 \mathbf K_{i} +
3(1-t)^2t \mathbf P_{1,i} +
3(1-t)t^2 \mathbf P_{2,i} +
t^3 \mathbf K_{i+1} , \quad t\in [0,1]
$$
The first derivative is
$$
\mathbf B_i'(t) = -3(1-t)^2 \mathbf K_{i}+
3(1-4t+3t^2) \mathbf P_{1,i} +
3(2t-3t^2) \mathbf P_{2,i} +
3t^2 \mathbf K_{i+1}
$$
And the second derivative is
$$
\mathbf B_i''(t) = 6(1-t) \mathbf K_{i}+
3(-4+6t) \mathbf P_{1,i} +
3(2-6t) \mathbf P_{2,i} +
6t \mathbf K_{i+1}
$$
Dr. Lubos Brieda states that the first and second derivatives are continuous if
$$
\begin{align}
\mathbf B_{i-1}'(1) &= \mathbf B_{i}'(0) \quad &i \in \{ 1, \dots, n-1\} \\
\mathbf B_{i-1}''(1)&= \mathbf B_{i}''(0) & i \in \{ 1, \dots, n-1\}
\end{align}
$$
and derives that, in that case
$$
\begin{align}
2\mathbf{K}_i&=\mathbf{P}_{1,i}+\mathbf{P}_{2,i-1} \quad\quad\quad&(1) \\
-2\mathbf{P}_{1,i}+\mathbf{P}_{2,i}&=\mathbf{P}_{1,i-1}-2\mathbf{P}_{2,i-1} \quad\quad\quad&(2)
\end{align}
$$
He also chooses
\(\mathbf{B}”_0(0)=0\) and \(\mathbf{B}”_{n-1}(1)=0\), so
$$ \mathbf{K}_0-2\mathbf{P}_{1,0}+\mathbf{P}_{2,0}=0 \quad\quad\quad(3)$$
and
$$ \mathbf{P}_{1,n-1}-2\mathbf{P}_{2,n-1}+\mathbf{K}_n=0 \quad\quad\quad(4)$$
relation between continuity and derivatives
The derivative of a Bézier curve is extensively discussed by dr. Shene.
Dr. Shene mentions that if \( P_{2,i-1} \), \( K_{i} \) and \( P_{1,i} \) are on 1 line (= colinear), the curves still share the same tangent vector (they are \( G1 \) ).
So the curve remains \(G1\) when equation (1) is replaced by
$$ \mathbf{K}_i-\mathbf{P}_{1,i}= c_i \left(\mathbf{P}_{2,i-1} - \mathbf{K}_i \right) \quad c_i \in \mathbb R \setminus {0}\quad\quad(1b)$$
If the distance between knots becomes relatively small, the curve will seem more regular if we take
$$ c_i = { \lVert \mathbf{K}_{i}-\mathbf{K}_{i+1} \rVert \over \lVert \mathbf{K}_{i-1} - \mathbf{K}_{i} \rVert } $$
which leads to
$$ { \mathbf{K}_i-\mathbf{P}_{1,i} \over \lVert \mathbf{K}_{i}-\mathbf{K}_{i+1} \rVert} = { \mathbf{P}_{2,i-1} - \mathbf{K}_i \over \lVert \mathbf{K}_{i-1} - \mathbf{K}_{i} \rVert }$$
but will the curvature remain continuous?
curvature of a Bézier curve
The concept of curvature \( \kappa \) is well described on the Wikipedia.org as the inverse of the radius of a tangent circle.
In the case of a parametrized curve \( {\mathbf{r}}(t) = (x(t),y(t)) \) , a formula is
$$ \kappa (t) =
{ | { x'y''-y'x'' }| \over
| {x'}^2+{y'}^2 |^{3/2}}
=
{\lVert {\ddot{\mathbf{r}}} \times {\dot {\mathbf r}\rVert }\over
\lVert {\dot {\mathbf r}} \rVert^3} =
{\lVert {\ddot{\mathbf{r}}} \times \hat {\dot {\mathbf r}}\rVert \over
\lVert { {\dot {\mathbf r}}} \rVert^2 }
$$
For \( {\mathbf r} \) we can read \( \mathbf B_i \), of course. Thus
$$ \kappa_i (t) =
{{\lVert {\mathbf B_i''} \times \widehat {\mathbf B'_i}}\rVert \over
\lVert {\mathbf B'_i} \rVert^2 }
$$
For the continuity of the curvature, we must require
$$ \kappa_i (1) =\kappa_{i+1} (0) $$
This condition will be satisfied if
$$
\mathbf B_{i-1}'(1) = \mathbf B_{i}'(0) \quad\wedge\quad
\mathbf B_{i-1}''(1) = \mathbf B_{i}''(0) \quad\quad\quad i \in \{ 1, \dots, n-1\}
$$
which leads to equations (1) till (4).
Note that the condition is also satisfied if
$$
\left.
\begin{array}{rll}
c_i \mathbf B_{i-1}'(1) &= \mathbf B_{i}'(0) \\
c_i^2 \mathbf B_{i-1}''(1) &= \mathbf B_{i}''(0) \\
\end{array}
\right\}
\quad c_i \in \mathbb R \setminus {0}\quad, \quad i \in \{ 1, \dots, n-1\}
$$
These equations can be solved independently for the \(\{x_i\}_{i=0,\dots,n-1}\) and \(\{y_i\}_{i=0,\dots,n-1}\) coordinates of \(\{\mathbf B_i\}_{i=0,\dots,n-1}\), as described in the next part.
Note that this is not the case for the more general condition:
$$
\left.
\begin{array}{rll}
c_i \mathbf B_{i-1}'(1) &= \mathbf B_{i}'(0) \\
c_i^2 \lVert {\mathbf B_{i-1}''(1)} \times \widehat {\mathbf B'_i(1)}\rVert &=
\lVert {\mathbf B_{i}''(0)} \times \widehat {\mathbf B'_{i}(0)}\rVert \\
\end{array}
\right\}
\quad c_i \in \mathbb R \setminus {0}\quad, \quad i \in \{ 1, \dots, n-1\}
$$
Next