B-Spline Curve Calculator (De Boor-Cox Recursion)
An expert tool to calculate, visualize, and understand B-Spline curves based on control points, degree, and a knot vector using the De Boor-Cox algorithm.
| Recursion Level (r) | Points |
|---|---|
| No calculation yet. | |
What is a B-Spline Curve?
A B-Spline, or Basis Spline, is a mathematical function used to create smooth, complex curves in computer graphics, computer-aided design (CAD), and other fields of engineering. Unlike simpler curves like Bézier curves, B-Splines offer more localized control; moving a single control point only affects a portion of the curve, which makes them incredibly flexible for design work. This calculator uses the powerful De Boor-Cox recursion algorithm to evaluate points on the curve.
A B-Spline is defined by three key components: a set of Control Points that form a polygon guiding the curve’s shape, a Degree that determines the smoothness and polynomial nature of the curve segments, and a Knot Vector, which is a sequence of non-decreasing numbers that controls where and how the control points affect the curve.
The De Boor-Cox Recursion Formula
The De Boor-Cox algorithm is a numerically stable and efficient method to find a point on a B-spline curve for a given parameter u. It’s a generalization of the de Casteljau’s algorithm used for Bézier curves. The algorithm recursively generates new intermediate control points until the final point on the curve is found.
The recursive formula is as follows:
dj,r(u) = (1 - α) * dj-1,r-1(u) + α * dj,r-1(u)
where α = (u - tj) / (tj+p-r+1 - tj).
Variables Table
| Variable | Meaning | Unit / Type | Typical Range |
|---|---|---|---|
| Pi | Control Points | Coordinates (x, y) | Any valid coordinate space |
| p | Degree | Integer | 1 (linear), 2 (quadratic), 3 (cubic) |
| t | Knot Vector | Sequence of numbers | Non-decreasing (e.g., 0, 0, 1, 2, 2) |
| n | Number of Control Points – 1 | Integer | p to ∞ |
| m+1 | Number of knots | Integer | Must equal n + p + 2 |
| u | Evaluation Parameter | Number | tp to tn+1 |
Practical Examples
Example 1: A Simple Quadratic Curve (p=2)
Let’s create a simple quadratic curve that starts and ends at the first and last control points (a “clamped” curve).
- Inputs:
- Control Points: `(100, 200), (250, 50), (400, 200)` (n=2)
- Degree (p): `2`
- Knot Vector: `0, 0, 0, 1, 1, 1` (m+1 = n+p+2 = 2+2+2 = 6 knots)
- Interpretation: The knot vector has multiplicities of p+1 at the ends, which forces the curve to touch the endpoints. The evaluation parameter
uwill be valid between 0 and 1. - Result at u=0.5: The calculator would process this to find the point C(0.5), which would be `(250, 112.5)`.
Example 2: A Uniform Cubic Curve (p=3)
This example shows a cubic curve where the knots are evenly spaced.
- Inputs:
- Control Points: `(50, 50), (150, 250), (350, 250), (450, 50)` (n=3)
- Degree (p): `3`
- Knot Vector: `0, 1, 2, 3, 4, 5, 6, 7` (m+1 = n+p+2 = 3+3+2 = 8 knots)
- Interpretation: This is a “uniform” B-spline. The curve will not necessarily pass through any of the control points. The valid range for
uis between t3=3 and t4=4. - Result at u=3.5: The calculator would find the point C(3.5), located at the peak of the curve’s arch, `(250, 209.375)`.
How to Use This B-Spline Curve Calculator
- Enter Control Points: Type the X and Y coordinates of your control points in the textarea, with each point on a new line (e.g., `100, 150`). You need at least one more control point than the degree (`n+1 > p`).
- Set the Degree (p): Choose the polynomial degree. Higher degrees create smoother but computationally more intensive curves. Degree 3 (cubic) is a common choice.
- Define the Knot Vector: Enter a comma-separated list of non-decreasing numbers. The number of knots must be exactly equal to the number of control points plus the degree plus one (`m = n + p + 1`, or `m+1` knots total). For a curve that starts and ends at the first and last control points (clamped), repeat the first and last knot `p+1` times.
- Select the Evaluation Parameter (u): Use the slider to choose a point `u` along the curve you want to evaluate. The valid range for `u` is between the knot `t[p]` and `t[n+1]`.
- Calculate and Interpret: Click “Calculate & Draw Curve”. The canvas will show the resulting curve, the control polygon, and the specific point calculated at `u`. The table below the chart shows the intermediate points generated by De Boor’s algorithm, giving insight into how the final point is constructed.
Key Factors That Affect B-Spline Curves
- Control Point Position: The primary way to shape the curve. The curve is “pulled” towards its control points.
- Curve Degree (p): A higher degree results in a smoother, more continuous curve. A degree of 1 creates a simple polyline.
- Number of Control Points (n+1): More control points allow for more complex and detailed shapes.
- Knot Vector Values: The values in the knot vector determine the influence of each control point over a given segment of the curve.
- Knot Multiplicity: Repeating a knot value decreases the level of continuity at that point. A knot with multiplicity `k` means the curve is Cp-k continuous there. Repeating a knot `p` times creates a sharp corner.
- Clamped vs. Unclamped Knots: Using a clamped knot vector (repeating end knots p+1 times) forces the curve to start and end at the first and last control points, which is often desirable. Bézier curves are a special case of B-splines with clamped knots.
Frequently Asked Questions (FAQ)
A Bézier curve is actually a special case of a B-spline. The main differences are that B-splines can have a degree independent of the number of control points and offer local control. Changing one control point in a Bézier curve affects the entire curve. To learn more, see our Spline Interpolation Deep Dive.
It means the number of knots you entered doesn’t match the required formula: `number of knots = number of control points + degree + 1`. For example, with 5 control points and degree 3, you need `5 + 3 + 1 = 9` knots.
B-splines are approximating splines, not interpolating. They follow the general shape of the control polygon but don’t necessarily pass through the points unless you force them to by increasing knot multiplicity. A clamped curve will always touch the two endpoints.
A uniform B-spline has knots that are evenly spaced (e.g., 0, 1, 2, 3, 4). A non-uniform B-spline can have any non-decreasing knot values. Non-uniform splines are more flexible and are the basis for NURBS (Non-Uniform Rational B-Splines). Learn about what NURBS are here.
To create a closed curve, your control point list must “wrap around” (the last few points should be the same as the first few), and you must use a periodic (unclamped) knot vector.
The curve is only defined for `u` values between `t[p]` and `t[n+1]`, where `p` is the degree and `n+1` is the number of control points. The calculator automatically sets the slider to this range.
It is a highly efficient and numerically stable method for evaluating the curve, meaning it is less prone to rounding errors in computers compared to directly solving the basis function polynomials. It’s fundamental to modern Computer-Aided Design Basics.
Yes. The calculation is unitless. The control points can represent any coordinate system: inches, meters, or abstract values. The calculator visualizes them in a pixel space for convenience.
Related Tools and Internal Resources
Explore more concepts in geometric modeling and calculation with these related resources:
- Bézier Curve Calculator: Explore the simpler predecessor to B-Splines.
- Spline Interpolation Calculator: Create splines that pass directly through a set of points.
- What is NURBS?: An article explaining the next evolution of splines, which adds weights to control points.
- Geometric Modeling Techniques: A guide to the fundamental concepts used in CAD and 3D graphics.