Cubic Spline MbCubicSpline3D

The MbCubicSpline3D class is declared in the cur_cubic_spline3d.h file.

The cubic spline is a derived curve of MbPolyCurve3D. The curve is defined by an array of control points SArray<MbCartPoint3D> pointList, an array of the second derivatives of the curve at the control points SArray<MbVector3D> vectorList, an array of the curve parameter values at the control points tList, the maximum index value of the parameter array splinesCount, and the flag of curve periodicity closed. The curve also contains some additional data that is optional and is used to speed up the curve methods.

For the cubic spline, at the parameter value tList[i], i = 0, 1, …, splinesCount, the curve passes through the control point pointList[i] and has the second derivative vectorList[i] at this point. The curve is constructed so that when moving from pointList[i]to pointList[i + 1], the second derivative of the radius vector of the curve changes linearly from vectorList[i] to vectorList[i + 1].

When computing the radius vector of a point on the composite curve, first, by the curve parameter value t the index i of the active segment is determined from the condition tList[i] ≤ t ≤ tList[i + 1]. The radius vector of the curve is then computed from pointList[i], pointList[i + 1], vectorList[i], vectorList[i + 1] of the found segment for the local parameter w, which is determined by tList[i] and tList[i + 1].

In the PointOn( double & t, MbCartPoint3D & r) method, the radius vector r of the curve is defined by the vector function

\[r(t) = (1 - w)\mathbf{pointList}[i] + w\mathbf{pointList}[i + 1] + \left( (-2w + 3w^{2} - w^{3})\mathbf{vectorList}[i] + (-w + w^{3})\mathbf{vectorList}[i + 1] \right)\frac{(\mathit{tList}[i + 1] - \mathit{tList}[i])^{2}}{6},\]

where

\[w = \frac{t - \mathit{tList}[i]}{\mathit{tList}[i + 1] - \mathit{tList}[i]},\]

and tList[i] ≤ t ≤ tList[i + 1].

A cubic spline constructed through the same control points as the Hermite composite curve is shown in the figure:

../../../../_images/O.4.9.1.png

The curve parameter t takes values on the interval tmin ≤ t ≤ tmax, where tmin = tList[0], tmax = tList[splinesCount]. The curve can be periodic.

The shape of the curve depends on the arrangement of the control points and on the tList array of parameter values at the control points. When the curve is constructed only from the control points, the curve parameter values at the control points tList[i], i = 0, 1, …, splinesCount, vary proportionally to the distance between the points, and the second derivatives vectorList[i], i = 1, 2, …, splinesCount – 1 are computed by solving a system of equations.