# Number of control points for B-spline curve

I am trying to use B spline curve fitting. The order of B-spline curve is 4. When I have many control points, it works well. However if the number of control points is small such as two, my program will crash. I realize that the number of control points is related to number of knots and the order.

Can anyone help me clarify the relationship or give some links on it?

The formula is:

$m = n + p + 1$

• $m$ number of knots.
• $n$ number of control points.
• $p$ degree.

You can check the nurbs book chapter 2 for a complete set of definitions. The Shumaker's book is a more readable reference.

There is a paragraph on interpolation also on Tom Lyche and Knut Mørgens's lecture notes. Here you shall find that all the entries in your matrix are positive, so the linear algebra should be ok. Donno what about the rest of your code.

• I am reading the NURBS book. From the link,it gives the same formula:cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/…. I hope to know the process that gets the formula. Oct 21 '14 at 8:41
• It derives from the definition of B-Spline. If you want to proof it you shall probably use the definition and "count", but I never did that. Did you check Tom Lyche's notes? There is a paragraph on interpolation that might help you. Oct 21 '14 at 8:48
• From the link:cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/… It says "Since each control point needs a basis function and the number of basis functions satisfies m = n + p + 1. ". From the definition of the B-spline curve, it is weighted average of input points. The number of the number of basis functions should equal the number of input points. Oct 22 '14 at 8:53
• The definition I am referring to, is in paragraph 2.2 of the nurbs book, equation 2.5. When I say "count" it means that you need to find a smart way to recover the formula $m=n+p+1$ from the recursive definition in the book. The web page you are pointing at misses this definition, which is the most important in this case. Oct 22 '14 at 16:04