From the seminal paper by Hughes I learnt that any B-Spline curve (or surface) can be described by a linear combination of B-Spline basis and control points, i.e.
C(x) = \sum_{i=1}^n N_{i,p} B_i
where N_{i,p} denotes the i-th node of the B-Spline curve with order p, and B_i the coefficients, or the control points.
This works well if we have a pre-defined plane, and summing up the parts give the desired B-Spline curve/surface.
My question is: is there a way to express the B-Spline curve in the same manner where it is not necessarily a function (vertical line can have multiple intersections with the curve), for example how to write the B-Spline curve in the form above for the following curve?
The curve is drawn using nurbs calculator. This is basically a curve with both vertical and horizontal components, with zigzags on both of them (there exists vertical/horizontal lines intersect with the curve at two points, respectively)
Clearly for a curve that is not necessarily a function (such as the one above) it cannot be decomposed directly into the bases. I am wondering how, then, can it be expressed explicitly using the same formulation.
Both analytic and numerical expressions will be very useful. Thanks in advance!
The B-Spline curve you're seeking is a parametric curve C(t) = [X(t), Y(t), Z(t)]
, where:
X(t) = \sum_{i=1}^n N_{i,p}(t) Pi_x
Y(t) = \sum_{i=1}^n N_{i,p}(t) Pi_y
Z(t) = \sum_{i=1}^n N_{i,p}(t) Pi_z
Pi
are the control points (Pi_x
for example, is the x-coordinate of the i'th control point) and N_{i,p}(t)
is the (scalar) i'th basis function (of degree p
, which is 2 in your example).
The parameter t
goes from 0 to 1 (in your example).
The basis functions can be computed directly from the knots using the Cox-DeBoor recursion formula.
So in vector form the curve can be written as: C(t) = \sum_{i=1}^n N_{i,p}(t) Pi
.
A good introductory website, which explains this and more (and gives you, among other things, the Cox-De Boor formula) is this online course by Shene. I highly recommend you read the chapter on B-Spline curves and in particular, on B-Spline basis functions.
So, if you implement the Cox-DeBoor recursion formula, you can densely sample points on the curve (e.g., by evaluating Ni(t)
for t=[0,0.01,...,0.99,1]
) and draw it or perform other tasks on it.
A C-like implementation for computing the B-Spline basis functions can be found in Algorithm A2.2 of The NURBs Book by Piegl and Tiller.
A note on your representation: The control points in your example have four coordinates (e.g., the first is [-6.386, 4.902, 0, 1]
). The fourth coordinate is required to support rational B-Splines (NURBs), which can be thought of as an extension of B-Splines. In your context, where all the fourth coordinates are equally 1, you can ignore the fourth coordinate and consider just the first three coordinates as values of Pi_x, Pi_y, Pi_z
as I explained above.