11524

# 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.

### DETAILS

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
, ,
satisfying
(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.
Let
, .
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)
and
.
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.
Let
.
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.
Reference
[1] L. Piegl and W. Tiller, The NURBS Book, 2nd ed., Berlin: Springer-Verlag, 1997 pp. 410–413.

### PERMANENT CITATION

 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 » Download Demonstration as CDF » Download Author Code »(preview ») Files require Wolfram CDF Player or Mathematica.

#### Related Topics

 RELATED RESOURCES
 The #1 tool for creating Demonstrations and anything technical. Explore anything with the first computational knowledge engine. The web's most extensive mathematics resource. An app for every course—right in the palm of your hand. Read our views on math,science, and technology. The format that makes Demonstrations (and any information) easy to share and interact with. Programs & resources for educators, schools & students. Join the initiative for modernizing math education. Walk through homework problems one step at a time, with hints to help along the way. Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet. Knowledge-based programming for everyone.