Create line with 6th order spline

analytic geometrydifferential-geometryinterpolationMATLABspline

I am dealing with spline interpolation and what I do is basically interpolating $6$th order ($7$ control points) spline through some discrete points. Curve-based part of my algorithm is done, however, in some points, I need to interpolate $6$th order spline which must be result in line.

Is there any mathematical method to do that ?

I thought to put $3$ control points each at start and end points and $1$ control point at the middle point of these start and end points. It seems it's working but how can I be sure that it's a line ? Or is there any other method to do that ?

Best Answer

A Bézier curve with six control points is defined as

\begin{align} \mathbf{B_6}(t) &= \sum _{i=0}^{6} {6 \choose i}(1-t)^{6-i}t^{i}\,P_i \tag{1}\label{1} , \end{align}

where $P_i$, $i=0,\dots,6$ are the control points of the spline.

Because of the properties of the convex hull of the Bezier control points, to get a visual appearance of the straight line between the points $A,B$, one can just set $P_0=A$, $P_6=B$, and place the other five control points somewhere on the segment $AB$, so your choice of $P_0,P_1,P_2=A$, $P_4,P_5,P_6=B$, $P_3=\tfrac12\,(A+B)$ will do for that purpose. However, to get also the linear expression in \eqref{1}, we need to expand \eqref{1}, in order to get a representation as a polynomial of degree $6$ in the standard form \begin{align} a_6t^6+a_5t^5+a_4t^4+a_3t^3+a_2t^2+a_1t+a_0 \tag{2}\label{2} , \end{align}

where \begin{align} a_0&=P_0 ,\\ a_1&= 6\,(P_1-P_0) ,\\ a_2&=15\,(P_0-2\,P_1+P_2) ,\\ a_3&=20\,(-P_0+3\,P_1-3\,P_2+P_3) ,\\ a_4&=15\,(P_0- 4 P_1 + 6 P_2 - 4 P_3+ P_4) ,\\ a_5&= 6\,(-P_0+5\,P_1-10\,P_2+10\,P_3-5\,P_4+P_5) ,\\ a_6&=P_0-6\,P_1+15\,P_2-20\,P_3+15\,P_4-6\,P_5+P_6 . \end{align}

To get a set of control points $P_i$ such that expression \eqref{2} becomes linear in parameter $t$, we need to make all coefficients $a_2,\dots,a_6$ zero. The solution then is just

\begin{align} P_i&=\tfrac16\,(A\cdot(6-i)+B\cdot i) ,\quad i=0,\dots,6 , \end{align}

that is, all control points are evenly distributed along the segment $AB$.