How to | Create Graphics with Spline Primitives

The Wolfram Language provides fully integrated spline graphics primitives, such as Bézier curves, B-spline curves, and B-spline surfaces. The spline primitives support a full range of user controls, such as arbitrary degree and a rational form of splines. The spline primitives provide an easy way to create complex graphics.

BezierCurve draws a composite Bézier curve that is defined by the given control points. By default, a cubic Bézier curve is used:

Use BSplineCurve with Graphics to create a cubic B-spline curve consisting of seven control points:

In general, spline curves do not go through the control points. However, they do go through the endpoints:


The SplineDegree option controls the underlying polynomial degrees of the spline curves. Usually, the higher the degree, the smoother the resulting curve.

Here, six different spline curves are created from the same set of control points by using Table to iterate BSplineCurve with SplineDegree changing from 1 to 6:


The SplineKnots option provides detailed control over the shape of a B-spline curve. Without specifying values for SplineKnots, the Wolfram Language gives the default knot sequence in such a way that the resulting curve is smooth overall and the endpoints are interpolated:

This is the same curve, but with the default knot values explicitly shown. The first and the last repeating knots make the curve go through the endpoints, where is the spline degree. The rest of the knots are uniformly distributed:

By repeating the knot value 1/2 in the middle, you can decrease the smoothness of the curve:


When the SplineClosed option is set to True, the Wolfram Language will create a smoothly closed B-spline curve:


The SplineWeights option can be used to assign weights to each point. The curve will be pulled toward the points with larger weights:

With no explicit setting for SplineWeights, the Wolfram Language assigns equal weights to each point:

Notice that the curve is pulled towards the middle point, which is given a weight of 5 with SplineWeights:

Mathematically, non-uniform weights create rational B-spline functions, also known as NURBS. NURBS can represent shapes that regular B-splines cannot. For instance, use BSplineCurve to create an exact circle by setting SplineWeights to the values in w and SplineKnots to the values in k:


3D spline curves can be created by using 3D points:

By wrapping curves with Tube, you can create tubed spline curves in 3D. Here the tube radii are 0.2:

A tube with various radii can be created by associating a list of radii with the control points:


BSplineSurface creates a tensor product B-spline surface defined by a matrix of 3D points:

All the options for BSplineCurve work in the same way. However, for surfaces, you can specify them in each parametric direction separately. For example, the following SplineDegree setting creates a B-spline surface with degree 1 in one direction, and degree 3 in another:

Like the B-spline curves, a rational surface, or NURBS surface, can be created by using SplineWeights. Many computer-aided design applications use NURBS to represent industrial surfaces. The following example generates a right-angle cylindrical tube: