Non-uniform cubic B-splines

A B-spline curve of degree \(k\) (order \(k+1\)) can be defined more generally as a sum of the \(m+1\) control points \(P_0,\ldots,P_m\) multiplied by the corresponding basis functions.

$$p(t)=\sum_{i=0}^m P_i B_{i,k}(t)$$

where \(B_{i,k}(t)\) is the basis function of order \(k\) for control point \(i\). Note that in the figure below, the colours of the control points match the corresponding basis functions in the plot below the curve. As \(t\) varies, the influence of e.g. the red control point on the position along the curve is determined by the basis function plotted in red. The basis functions depend on a serious of knots \(t_0,\ldots,t_{k+m}\) that for a uniform cubic B-spline can just be set to equally spaced integers. In a non-uniform B-spline these knots can take arbitrary values, and changing the knot values can modify the shape of the curve. The basis functions are defined recursively as

$$B_{i,1}(t)=\begin{cases}1 & \text{if } t_i \leq t < t_{i+1}\\ 0 & \text{otherwise}\end{cases}$$

$$B_{i,k}(t)=\frac{t-t_i}{t_{i+k-1}-t_i}B_{i,k-1}(t)+\frac{t_{i+k}-t}{t_{i+k-1}-t_i}B_{i+1,k-1}(t)$$

The curve is defined for \(t_{k-1} \leq t \leq t_{m+1}\). The knots are plotted as red circles on the x axis of the figure below, try moving the knots to see how this affects the shape of the curve.

It is not always intuitive to edit the shape of the curve by moving knots, but this can be useful to clamp the curve to the start and end control points. Repeating the same value for the first and last \(k+1\) knots forces the start and end points of the curve to pass through the first and last control points.