Global B-Spline Curve Fitting by Least Squares

This Demonstration shows global B-spline curve fitting by the least-squares method. B-splines are a generalization of Bezier curves. In a B-spline, each control point is associated with a particular basis function. The implementation is fully described in the Details.
  • Contributed by: Shutao Tang
  • (Northwestern Polytechnical University, Xi'an City, China)


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


For definitions and details of the B-spline curve and B-spline basis function, see Related Links.
Assume that and are given, where . We seek a -degree nonrational curve
, ,
(1) , ,
(2) the remaining are approximated in the least-squares sense; that is,
is a minimum with respect to the variables.
Here, and are precomputed parameter values.
, .
Then set
So is a scalar-valued function of the variables . Applying the standard technique of linear least-squares fitting to minimize, set the derivatives with respect to the points, , to zero. The of these derivatives is
which implies that
It follows that
. (1)
Equation (1) is one linear equation in the unknowns . Letting yields the system of equations in unknowns,
where is the matrix of scalars
, (2)
is the vector of points
, (3)
In order to set up equations (2) and (3), a knot vector with parameters is required.
The can be computed using the following method (with , in each case):
(1) Equally spaced
, ,
(2) Chord length
let , then
, ,
(3) Centripetal
let , then
, ,
The placement of the knots should reflect the distribution of the . If , denote by the largest integer less than or equal to . We need a total of knots; there are internal knots and internal knot spans.
Then define the internal knots by
, ,
, . (4)
Equation (4) guarantees that every knot span contains at least one , and under this condition the matrix is positive definite and well-conditioned.
[1] L. Piegl and W. Tiller, The NURBS Book, 2nd ed., Berlin: Springer-Verlag, 1997 pp. 410–413.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+