B-Spline Basis Function Calculator
Compute B-spline basis function values from a knot vector, degree, and parameter value using the Cox-de Boor recursion formula. The tool returns the active basis values, verifies partition of unity, and plots the full basis family across the valid parameter domain.
Expert Guide to B-Spline Basis Function Calculation
B-spline basis function calculation is one of the core operations behind modern geometric modeling, isogeometric analysis, computer graphics, path planning, and CAD surface design. When people talk about a B-spline curve, they often focus on the control points, but the real mathematical engine is the basis system. Each basis function defines how strongly a control point influences the final curve at a parameter value u. If you understand how to calculate these basis functions, you understand how the entire spline behaves.
A B-spline basis is determined by two ingredients: the spline degree p and a nondecreasing knot vector U = {u0, u1, …, um}. From those inputs, we derive a set of locally supported basis functions N(i,p)(u). Local support is the property that makes B-splines so powerful in practice. Moving one control point only affects a limited region of the curve rather than the entire shape. That is why B-splines are preferred over global polynomial interpolation in many production systems.
What a B-spline basis function actually does
Suppose you have control points P0 through Pn. A B-spline curve is usually written in the form C(u) = Σ N(i,p)(u) Pi. For any chosen parameter value u, each basis function produces a weight. Those weights are then applied to the control points. The resulting weighted sum gives a point on the curve. The basis functions are nonnegative and, over the valid interior domain, they sum to 1. This property is called partition of unity. It is mathematically important because it keeps the curve inside the convex hull of active control points and gives stable interpolation behavior in many numerical settings.
The valid parameter range for a degree p B-spline is commonly [U[p], U[n+1]]. Inside that interval, only p + 1 basis functions are nonzero at a generic parameter value with simple knots. This is another major computational advantage. The curve can be evaluated efficiently because most basis functions are exactly zero at any given location.
The Cox-de Boor recursion formula
The standard method for B-spline basis function calculation is the Cox-de Boor recursion. It starts with degree 0 basis functions, which are piecewise constants:
- N(i,0)(u) = 1 if U[i] ≤ u < U[i+1]
- N(i,0)(u) = 0 otherwise
Higher degree functions are then built recursively:
N(i,p)(u) = ((u – U[i]) / (U[i+p] – U[i])) N(i,p-1)(u) + ((U[i+p+1] – u) / (U[i+p+1] – U[i+1])) N(i+1,p-1)(u)
If either denominator is zero because of repeated knots, that fraction is defined as zero for numerical safety. This detail is essential in real software, because repeated knots are normal. They are used to clamp a curve, reduce continuity, or create interpolation-like end behavior.
Why the knot vector matters so much
The knot vector controls where and how basis functions rise, overlap, and decay. Uniform knot vectors produce regularly spaced basis shapes. Nonuniform vectors allow extra resolution in specific parameter regions. Repeated interior knots reduce smoothness. Repeated end knots are used to clamp the curve so that it starts and ends at the first and last control points.
For example, a clamped cubic knot vector might look like 0,0,0,0,1,2,3,3,3,3. The repeated 0 and 3 values anchor the ends. Between those ends, the basis functions overlap in a smooth cubic manner. At a simple interior knot, a degree p spline has continuity C(p-1). So a cubic spline with simple interior knots is C2 continuous. If an interior knot has multiplicity 2, continuity drops to C1. If multiplicity is 3, continuity drops to C0.
| Degree p | Polynomial order | Continuity at a simple interior knot | Number of active basis functions at a generic u | Support across knot spans |
|---|---|---|---|---|
| 0 | Piecewise constant | C-1 discontinuous between spans | 1 | 1 span |
| 1 | Piecewise linear | C0 | 2 | 2 spans |
| 2 | Piecewise quadratic | C1 | 3 | 3 spans |
| 3 | Piecewise cubic | C2 | 4 | 4 spans |
| 4 | Piecewise quartic | C3 | 5 | 5 spans |
How to calculate basis functions step by step
- Choose a degree p and a nondecreasing knot vector.
- Compute the number of basis functions using n + 1 = m – p, where m is the last knot index.
- Pick a parameter value u in the valid domain [U[p], U[n+1]].
- Evaluate all degree 0 basis functions using interval membership.
- Use the recursion formula to build degree 1, then degree 2, up to degree p.
- Read off the final values N(0,p)(u) through N(n,p)(u).
- Verify that the values are nonnegative and sum to 1, allowing for tiny floating point error.
In software, this recursive structure can be implemented either directly or with a dynamic programming table. For a calculator like the one above, the dynamic table approach is practical, clear, and numerically stable enough for common educational and engineering use.
Worked intuition using a cubic clamped example
Take the knot vector 0,0,0,0,1,2,3,3,3,3 with degree 3. This gives six cubic basis functions because the total knot count is 10 and n + 1 = 10 – 3 – 1 = 6. At a value such as u = 1.5, only four of those six basis functions are active. Their values might look something like a smooth blend of local weights, for example 0.03125, 0.46875, 0.46875, and 0.03125 in a symmetric region, depending on the exact span. The key point is that the spline does not use every control point at every u. It only uses the locally relevant ones.
This local blending creates smooth curves that are easy to edit. If a designer changes one control point, only the part of the curve supported by the corresponding basis function changes. That is a huge reason B-splines became standard in CAD, animation, and finite element style geometry pipelines.
Numerical facts that matter in production
B-spline basis function evaluation is not just elegant theory. It has concrete numerical consequences. Basis functions are compactly supported, nonnegative, and generally better conditioned than high degree global polynomial bases on wide intervals. Engineers and graphics programmers care because these properties improve stability, preserve locality, and reduce visible artifacts when editing shapes.
| Property | B-spline basis behavior | Practical statistic or fact |
|---|---|---|
| Partition of unity | The active basis values sum to 1 over the valid parameter domain. | At a generic u with simple knots, exactly p + 1 basis functions are active and their sum is 1. |
| Continuity | At an interior knot of multiplicity r, continuity becomes C(p-r). | For cubic p = 3, continuity is C2 for simple knots, C1 for double knots, and C0 for triple knots. |
| Support size | Each basis function spans only p + 1 knot intervals. | A cubic basis is nonzero on 4 knot spans and exactly zero outside that local window. |
| Endpoint clamping | Repeating the first and last knot p + 1 times forces endpoint interpolation. | A clamped cubic needs 4 repeats at each end. |
Common mistakes when calculating B-spline basis values
- Using an invalid knot vector. The sequence must be nondecreasing. Even one out-of-order value breaks the basis definition.
- Choosing u outside the valid domain. Some formulas return all zeros outside [U[p], U[n+1]], which can confuse new users.
- Forgetting the right-endpoint rule. At the final knot, implementations usually treat the last basis as active so the endpoint is included.
- Ignoring zero denominators. Repeated knots make some recursive terms undefined unless you explicitly set zero-over-zero contributions to zero.
- Mixing degree and order. Degree 3 means cubic. The polynomial order is degree + 1, so order 4.
Where B-spline basis functions are used
B-spline basis function calculation appears in far more areas than introductory graphics textbooks suggest. CAD and CAM systems use B-splines and NURBS for curves and surfaces. Computer animation uses them for motion paths and smooth interpolation. Geospatial modeling uses spline surfaces for terrain and data approximation. Numerical analysts use spline spaces in collocation, interpolation, smoothing, and isogeometric methods. Medical imaging and signal processing also rely on spline kernels because they provide smooth local approximation with strong theoretical guarantees.
Why a calculator is useful
A dedicated calculator helps students, developers, and engineers inspect the basis functions directly instead of only seeing the final curve. This matters because many design decisions happen at the basis level. You may want to confirm that your knot vector is clamped, see which basis is active at a given parameter, verify that continuity changes after knot insertion, or visually inspect whether your basis values still sum to 1. A basis calculator lets you validate each of those behaviors before using the weights in a larger geometry or simulation pipeline.
Trusted references for deeper study
If you want mathematically rigorous definitions and extended derivations, these sources are excellent starting points:
- NIST Digital Library of Mathematical Functions
- Michigan Technological University spline notes
- Carnegie Mellon University graphics course materials on spline foundations
Final takeaway
B-spline basis function calculation is the heart of spline evaluation. Once you know the degree, the knot vector, and the parameter value, the Cox-de Boor recursion gives you the exact weights needed to blend control points. Those weights are local, nonnegative, and sum to 1. This combination of locality, smoothness, and stability is why B-splines remain a foundational tool across design, simulation, and computational geometry. Use the calculator above to experiment with degree changes, repeated knots, and different parameter values, and you will quickly develop intuition for how spline spaces behave.