Waypoint lists (robot teach-in programs, CNC paths, planner output), calibration tables and resampled signals all need a smooth curve through given samples. A single high-order polynomial through many points rings between them; a piecewise-linear curve has corners that excite mechanics. A cubic spline joins one cubic per interval so that value, slope and curvature are continuous (
Several channels (the joints of a robot, the axes of a path, the columns of a table) share the same abscissae. They are fitted together: the linear system depends only on the knot spacing, so it is factored once and every channel reuses the factors. Fitting is a single linear-time pass on fixed storage; evaluation is a binary search plus a cubic, cheap and deterministic.
Knots
The cubic hits both knot values and both knot curvatures, so value is
Equating the slope at the end of interval
Each row couples a knot to its two neighbours only, so the system is tridiagonal with
| Condition | First row | Last row |
|---|---|---|
|
Clamped (end slopes |
||
| Natural |
Clamping fixes the end slopes and leaves the end second derivatives free; natural ends do the reverse. Default slopes are zero.
Every interior row has diagonal
Clamp
An abscissa exactly on an interior knot selects the interval starting there; the last knot selects the final interval. Both choices give the same result because the spline is
| Operation | Time | Space | Notes |
|---|---|---|---|
| Factorization | three bands | Once per fit, shared by all channels | |
| Fit |
|
|
|
| Evaluate | Binary search, then three Horner polynomials per channel |
Storage holds the knots, their reciprocal spans, the values and the second derivatives:
Knots
Clamped, zero end slopes. The system is $$\begin{pmatrix} 2 & 1 & 0 \ 1 & 4 & 1 \ 0 & 1 & 2 \end{pmatrix} M = \begin{pmatrix} 6 \ -12 \ 6 \end{pmatrix}$$
| Pivot |
Forward |
Back |
||
|---|---|---|---|---|
| 0 | ||||
| 1 | ||||
| 2 | unused |
So
Natural. The end rows reduce to
Random fits are checked for interpolation of every knot, for continuity of first and second derivative across each interior knot, and for the end conditions (prescribed slopes when clamped, zero curvature when natural). Continuity holds to about
-
Invalid knots. Fewer than 2 knots, more than the capacity, or spacing
$x_{k+1} - x_k \le \varepsilon \max(1, |x_k|)$ is rejected, where$\varepsilon$ is the machine epsilon of the scalar type. Near-coincident knots would make slope quotients and the second derivatives huge. - Failure leaves no fit. A rejected or unfactorable fit discards any earlier fit; evaluating before a successful fit is a precondition violation.
-
Tolerance is a floor, not a guarantee. Spacing only a few
$\varepsilon$ wide passes the test yet produces enormous slopes; keep sample spacing meaningful relative to the data. - Overshoot. A cubic spline interpolates; it does not bound the curve between knots, so limits (velocity, position) must be checked on the evaluated curve.
- Outside the domain. The abscissa is clamped, so the output is the end-knot sample, including its slope and curvature, which need not be zero. Position holds while the reported velocity does not drop to zero.
- Pick the end condition per application. Clamped when end velocities matter (start and stop at rest); natural when they do not, accepting free end slopes.
-
Degenerate cases. Two clamped knots give exactly the cubic Hermite polynomial. Two natural knots give the straight line. Collinear data with a matching clamped slope give a zero right-hand side and so
$M \equiv 0$ : the line is reproduced exactly. - Floating-point only. The reciprocal spans and the epsilon test have no meaning for integer types.
- Not-a-knot / periodic ends. Other end rows keep the tridiagonal shape (not-a-knot) or add corner entries solved by Sherman–Morrison (periodic).
-
Shape-preserving cubics. Monotone Hermite interpolation chooses slopes locally; it removes overshoot but gives up
$C^2$ for$C^1$ . - B-spline form. Same curve family with local basis functions; suited to non-interpolating fits and variable degree.
- Smoothing and least-squares splines. Trade exact interpolation for noise rejection; see polynomial fitting for the non-interpolating alternative.
- Joint-space and Cartesian trajectories through waypoints, with continuous velocity and acceleration.
- CNC and planner paths parameterized by time or arc length.
- Calibration tables and resampling of sensor signals onto a new grid.
| Algorithm | Relationship |
|---|---|
| Tridiagonal Solver | Solves the second-derivative system; its factorization is reused across channels |
| Polynomial Profile | The two-knot clamped case is the same cubic Hermite polynomial; the spline generalizes it to many knots with |
| Polynomial fitting | Least-squares fit instead of interpolation |
- de Boor, C., A Practical Guide to Splines, Springer, 1978 (rev. ed. 2001).
- Burden, R. L. & Faires, J. D., Numerical Analysis, §3.5 (cubic spline interpolation).