B-Spline Basis Calculator
Enter knots and parameters.

B-Splines in a Nutshell

B-splines are flexible building blocks for curves and surfaces in computer graphics, computer-aided design, and numerical analysis. Given a nondecreasing sequence of knots t_0, t_1, ..., and an integer degree k, the B-spline basis functions Ni,kt are defined recursively. Each basis function is nonzero only on a finite interval determined by the knots, yielding local control of the shape. When combined with control points, they produce smooth curves such as the familiar NURBS used by designers and animators.

Cox–de Boor Recursion

The zeroth-degree basis functions are simply box functions. For k=0, we set

Ni,0t=1, if t>=ti&t<ti+1,0otherwise

Higher-degree bases follow the elegant recursion

Ni,kt = t-ti ti+k-ti Ni,k-1t + ti+k+1-t ti+k+1-ti+1 Ni+1,k-1t

Although the formula may appear daunting, it simply means each B-spline basis at degree k blends two lower-degree bases, weighted by how close t lies to adjacent knots. The result is a smooth function that is piecewise polynomial, with smoothness determined by repeated knots. This local influence is why B-splines are favored for modeling complex shapes while keeping computational costs manageable.

Applications and Flexibility

B-splines unify the ideas of Bezier curves and piecewise polynomial approximation. By adjusting knot placement, we can refine the curve locally without disturbing distant segments. Higher degrees yield more continuous derivatives, while repeated knots reduce continuity to create corners when desired. Practical implementations often use non-uniform rational B-splines (NURBS) that attach weights to control points, providing even more freedom. The fundamental basis functions computed here are the backbone of these advanced techniques.

In animation, B-splines drive camera paths and character motion. In finite element analysis, they serve as shape functions for isogeometric methods. Because the basis is numerically stable and has compact support, large systems of equations remain sparse. This combination of smoothness and locality is unique among curve representations.

Using the Calculator

To experiment with B-splines, supply a comma-separated knot vector, choose the degree, and set a parameter value t. The knot sequence should begin and end with multiplicities of k+1 to enforce interpolation at the ends. After clicking evaluate, the script prints an array of basis values N0,k, N1,k, and so on. You can then multiply these by control point coordinates to compute a curve or surface.

Implementation Details

The calculator relies on the classic Cox–de Boor recursion. The knots are parsed into an array, and a simple JavaScript function recursively evaluates the basis for each index. Although recursion is elegant, it can be inefficient for high degree or many evaluation points; production systems precompute values using dynamic programming. Still, for educational exploration this method provides clarity.

Mathematically, B-splines inherit many appealing properties. They sum to one across the domain, ensuring that weighted combinations form affine blends of control points. Their derivatives are again B-splines of one degree lower, shifted by the knot vector. Such structure leads to simple formulas for curvature and allows hierarchical refinement schemes that insert new knots without altering the shape.

Experimenting with different degrees reveals how continuity increases. Quadratic and cubic B-splines provide C^{1} and C^{2} continuity respectively between knot spans, meaning first and second derivatives match. Designers often prefer cubic curves because they balance flexibility and smoothness. Yet linear B-splines act as piecewise linear interpolation, highlighting the connection to simple polylines.

Broader Connections

Beyond geometric modeling, B-splines appear in statistics as basis functions for smoothing splines. Here, a penalty on the integral of squared second derivatives yields a curve that balances fidelity to data with smoothness. Wavelet constructions also use B-splines as scaling functions, bridging polynomial approximation with multiresolution analysis. In signal processing, this link provides efficient algorithms for filtering and compression.

Because B-splines generalize to multiple dimensions via tensor products, they underpin surface patches and volumetric representations. Their local support enables algorithms for collision detection, volume rendering, and terrain modeling. Engineers rely on these functions to design aircraft fuselages, car bodies, and architectural structures. Learning the basis is a gateway to a vast array of practical applications.

When exploring the calculator, note how the basis values shift as t moves through each knot interval. Repeated knots cause sharp transitions, while uniform spacing yields evenly distributed lobes. Visualizing these changes deepens intuition about curve design and knot insertion strategies. Because each basis function influences only a small region, complex shapes arise from simple combinations of just a few segments at a time.

Limitations and Extensions

This calculator keeps the implementation lightweight. It assumes a single, univariate B-spline and does not incorporate weights for NURBS or advanced features such as end conditions for closed curves. Nevertheless, the core idea is the same regardless of dimensionality or weighting. As you become comfortable with the basis functions here, consider extending the tool to generate full curves by inputting control points and computing linear combinations.

B-splines capture the essence of modern geometric modeling: local control, smoothness, and efficient computation. Whether you work in animation, engineering, or data science, understanding the basis functions is a stepping stone to mastering splines and their vast array of uses.

Related Calculators

Cross-Correlation Calculator - Compare Two Sequences

Compute the discrete cross-correlation between two sequences at all lags.

cross-correlation calculator signal comparison

Continued Fraction Calculator - Expand Numbers

Generate the continued fraction representation of any real number.

continued fraction calculator number theory

Householder Transformation Calculator - Reflect Vectors

Build the Householder reflection matrix for a given vector and see its effect.

householder transformation calculator reflection matrix