# An Introduction to B-Spline Curves

### Key Takeaways

• Basis splines, or B-splines, are a type of spline function often used for curve fitting.

• The main definition for a B-spline equation is as a piecewise polynomial.

• Areas as diverse as CFD simulations, computer graphics, statistics, and machine learning make use of B-splines for polynomial curve fitting. These B-spline curves are described by a set of piecewise polynomial equations

If you’ve ever used curve fitting tools in your favorite mathematical analysis software, you’ve probably seen an option for spline fitting, or B-spline fitting, more specifically. A basis spline, or B-spline, is a piecewise polynomial function with specific properties that determine the polynomial degree/order. The idea behind using a B-spline curve is to determine a unique polynomial representation of a set of data, whether that data be structural points in 3D space or a set of data on a graph.

Depending on the amount of data available and the chosen order/degree of the polynomial representation, B-splines can produce very accurate approximations to data. Thus, they may be useful in situations where a functional transformation does not reduce a set of data to a linear trend (e.g., machine learning and statistics) or when a curved representation of a set of discrete data is desired (e.g., computer graphics and 3D printing). In this article, we give an overview of B-spline curves and their useful properties in some example applications.

## B-Spline Curve Definition

Formally, a B-spline curve is defined as a piecewise polynomial curve with minimum support. The piecewise nature of a B-spline curve means that its representative equation is a linear combination of B-splines of particular degrees. All B-spline curves are constructed by defining the following elements:

• Polynomial degree - The user has freedom to determine the polynomial degree that will be used to interpolate their data to a B-spline curve model. A higher polynomial degree generally gives more accurate results, although there is a risk of overfitting between data points when the data is sparse.
• Knots - These are points along a B-spline curve where the curve sections meet and connect. All B-splines have at least two knots, which will define the end points of the B-spline curve.
• Control points - The control points are like the data used for interpolation; they will determine the shape of the resulting B-spline curve and the curve may not intersect with these points.
• Basis functions - These are the polynomial functions to be summed in an iterative fashion in each curve section. The knots define where a new basis function “activates” and begins contributing to the overall curvature of the B-spline curve.

For a curve with knots located at t and indexed by i, and a discrete set of data located at x, the polynomial section defined in section k is determined using an iterative relation: These B-spline curves are described by a set of piecewise polynomial equations

Each of the basis functions B(x) are a Bezier curve of degree D, which is chosen by the analyst. The above iterative curve generation technique is simple enough to be calculated from sets of tabulated data at each value of x. Some scripting languages (Python, R, etc.) will include libraries that can calculate the form of the basis functions in each curve section.

## Extension to Multivariate B-Spline Curves

B-splines are readily extended into multivariate settings, where a single dependent variable is tabulated as a function of multiple independent variables:

## Y = f (X1,X2,...,XN)

The above definitions for B-spline curves are then rewritten as vectors and tensors to create a 3D parametric B-spline representation of multivariate data. This is the type of approach used in multivariate statistics and machine learning, and such an approach can be implemented in R, MATLAB, Mathematica, and other analysis software.

For something like computer graphics or CFD simulations, the multivariate function to be regressed is simply a relation between a set of points. In other words, we would have tabulated data for one dimension (e.g., z-axis height) versus tabulated data in the two orthogonal dimensions (the x-y plane). This gives a 2D function to be interpolated using B-splines as a function of only two other variables. Visually, the B-spline curves would appear as contours along the idealized surface, and combining this with color and texture representations would create a realistic looking representation of a real object. Example with B-spline curves fit to a 3D surface

Finally, to construct an animation, the B-spline curves representing the input data are determined at each moment in time, and the evolution of the curve between time points will appear smooth if the temporal resolution is sufficiently high. This approach does not need to be custom-coded when working with mechanical or CFD simulations involving complex surfaces; higher order meshing algorithms are used to construct meshes based on B-spline curves, which are then used in standard numerical techniques involving the Navier-Stokes equations.

When you need to construct high-quality meshes using B-spline curves, take advantage of the automated meshing features in Pointwise from Cadence. Modern numerical approaches used in aerodynamics simulations, turbulent and laminar flow simulations, reduced fluid flow models, and much more can be implemented in Cadence’s CFD simulation tools.