I have been learining the NURBS theory by the classical textbook "The NURBS Book" this year. In the chapter 9, the author introduced the method of non-rational B-spline curve interpolation with a open curve.

I have implemented this global B-spline curve interpolation algorithm with the Wolfram Mathematica. About the details, please see here or here

In addition, I know how to generate a closes B-spline curve by the control points. Please see my answer for closes B-spline curve

Now let me give a simple example with Mathematica, I add the option SplineClosed -> True in the BSplineCurve.

searchSpan[knots_, u0_] :=
 With[{max = Max[knots]},
  If[u0 == max, Position[knots, max][[1, 1]] - 2,
   Ordering[UnitStep[u0 - knots], 1][[1]] - 2]

Options[BSplineInterpolation] = {SplineDegree -> Automatic};

BSplineInterpolation[pts : {{_, _} ..}, opts : OptionsPattern[]] /;
 MatrixQ[pts, NumericQ] :=
 Module[{n, md, sd, paras, knots, coeffMat, ctrlpts},
  n = Length@pts - 1;
  sd = OptionValue[SplineDegree] /. Automatic -> 3 /. 
    deg_ :> n /; deg > n;
  paras =
   FoldList[Plus, 0, Normalize[(Norm /@ Differences[pts]), Total]] // N;
  (*calculate the knots*)
  knots =
   Join[ConstantArray[0, sd + 1],
     1/sd (Plus @@ (paras[[# + 1 ;; # + sd]]) & /@ Range[1, n - sd]),
     ConstantArray[1, sd + 1]] // N;
  (*calculate the coefficients of matrix*)
  coeffMat = Function[{u0},
     With[{i = searchSpan[knots, u0]},
      Join[ConstantArray[0, i - sd],
       BSplineBasis[{sd, knots}, #, u0] & /@ Range[i - sd, i],
       ConstantArray[0, n - i]]]] /@ paras;
  (*solve the control points of B-Spline curve*)
  ctrlpts = LinearSolve[coeffMat, pts];
  (*visualize the result*)
     SplineClosed -> True, SplineDegree -> sd, SplineKnots -> knots],
    Red, PointSize[Medium], Point[pts]}]


pts = 
 {{-1.5, -2}, {-3, -1}, {-2.7, 0.5}, {-1.75, 1.3}, {0.8, -1.5}, 
  {1.5, 0.4}, {0, 2}, {3, 2}};

enter image description here

Obviously, this curve is not continuous and it doesn't pass all the interpolation points.

another trial(Namely, deleteing the option SplineKnots -> knots)

enter image description here


I have searched the paper about closed curve interpoaltion by the Google Scholar, however, I didn't discovered any helpful reference.

  • How to achieve a continuous closed B-spline curve?
  • $\begingroup$ I have the same issue. Do you find any solution? $\endgroup$
    – xu rongyan
    Commented Apr 25, 2021 at 5:41

2 Answers 2


The classic book in B-Splines is de Boor, C. (1978). A Practical Guide to Splines. New York: Springer-Verlag, but I spent many weeks on it and was not able to make his algorithms work. The algorithm in Phillips, G. M., & Taylor, P. J. (1996). Splines and Other Approximations Chapter 6 of Theory and Applications of Numerical Analysis (2nd ed., pp. 131-159). London, San Diago: Academic Press, works well and is easy to understand.


It looks as though your first example is working, except for the edge-case of connecting the first and last points. An easy solution, if it works, would be to repeat the first point in pts at the end.

I might check back later, if that doesn't work it might take a while to solve.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.