MbCubicSplineFunction Cubic Spline Function

The MbCubicSplineFunction class is declared in the cur_cubic_spline_function.h file.

The cubic spline function MbCubicSplineFunction is defined by the set of control points valueList, the set of second derivatives of the function at the control points secondList, the set of parameter values of the function at the control points tList, and the flag of periodicity of the function closed. The function also has some additional data that are optional and are used to speed up the work of the function methods.

For the parameter value tList[i], i = 0, 1, …, splinesCount, where splinesCount = tList.MaxIndex(), the cubic spline function passes through the control point valueList[i] and has the second derivative secondList[i] at this point.

When evaluating the function, first, by the value of the curve parameter t, the index i of the working segment is determined from the condition tList[i] ≤ t ≤ tList[i + 1]. Then the function is evaluated for the found working segment using its local parameter w, which is defined by tList[i] and tList[i + 1].

In the double Value( double & t ) method, the following function is used

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

where

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

is the local parameter of the working segment tList[i] ≤ t ≤ tList[i + 1].

The cubic spline function is shown in Fig. 1:

../../../../_images/O.6.5.1.png

Fig. 1

The domain of the function parameter lies within tmin ≤ t ≤ tmax, where tmin = tList[0], tmax = tList[splinesCount]. The function can be periodic.

The shape of the function depends on the positions of the control points and on the tList set of parameter values at the control points. When the function is constructed by control points, the derivatives secondList[i] are computed under the assumption of linear variation of the second derivatives between the control points.