# How to evaluate BSplineFunction

I have the following code to plot value of a bspline curve but it doesn't evaluate when I specify weights and knots and I'm not sure what's going wrong, the weights and knots vectors have the correct length (and if I change them I get an error) but for f I end up with a function that doesn't evaluate.

knots = {0,1,2,3,4,5,6,7,8};
points = {{0,0},{1/2,1},{1,1/4},{3/2,1},{2,0}};
weights = {1,1,1,1,1};
degree= 3;
f = BSplineFunction[points,SplineDegree->degree, SplineKnots->knots,SplineWeights->weights]
g = BSplineFunction[points,SplineDegree->degree]
g
f


Here's a screenshot of my output using Mathematica 10.3 on Windows: • It seems to not like your knots. knots={0, 0, 0, 0, 1, 2, 2, 2, 2} works. I note however the corresponding BSplineCurve works fine with your knots. – george2079 Mar 22 '16 at 20:08
• Ahh, it's annoying :) Maybe it's a bug? – mkm Mar 22 '16 at 20:53
• No, the knots can not be just any sequence with the right length. It must fulfill specific conditions. Try for instance knots = {0, 0, 0, 0, .5, 1, 1, 1, 1}; – Sjoerd C. de Vries Mar 22 '16 at 21:28
• Usually an admissible B-spline has the extreme knots repeated according to the degree of the spline. In the case of @george's knot sequence, you have a multiplicity of 4 in the first and last knots, corresponding to a cubic B-spline. – J. M.'s torpor Mar 22 '16 at 22:33
• If memory serves the multiplicity is only required if you want the curve to pass through the end control points. Note BSplineCurve works without the multiplicity, (and does not hit the end points). – george2079 Mar 22 '16 at 23:05

For the B-spline curve:

$$\overset{\rightharpoonup }{C}(u)=\sum _{i=0}^n N_{i,p}(u) \overset{\rightharpoonup }{P}_i \text{ }\qquad (a\leq u\leq b)$$

where, $P_i$ is the control point, the $N_ {i, p} (u)$ are the $p$th - degree B-spline basis functions defined on the non-periodic (and non-uniform) knot vector:

$\{\underbrace {a,\cdots ,a}_{p+1},u_{p+1},\cdots u_{m-p-1},\underbrace {b,\cdots,b}_{p+1}\}$

Here, $m=n+p+1$ and the domain of curve is $[u_p,u_{n}]$

knots = {0,1,2,3,4,5,6,7,8};
points = {{0,0},{1/2,1},{1,1/4},{3/2,1},{2,0}};
weights = {1,1,1,1,1};
degree= 3;

f = BSplineFunction[points, SplineDegree -> degree,
SplineKnots -> knots, SplineWeights -> weights]


So the spline function domain is $[3,5]$, you can verify it via the below code:

GraphicsColumn[
{ParametricPlot[f[u], {u, 3, 5}],
Graphics[
{BSplineCurve[points, SplineDegree -> degree,
SplineKnots -> knots, SplineWeights -> Automatic]}]}] Owing to the built-in BSplineFunction[] using the default domain $[0,1]$ to generate the spline icon, so f will lost the spline icon like this: Normalize the knots to $[0,1]$,

BSplineFunction[
points, SplineDegree -> degree,
SplineKnots -> {-(3/2), -1, -(1/2), 0, 1/2, 1, 3/2, 2, 5/2},
SplineWeights -> Automatic] • Thanks, this works for me. Also, I think you mean that the domain of the curve is $[u_p, u_{n+1}]$. See this link for example, the Piegl and Tiller book isn't as explicit on that point – mkm Mar 28 '16 at 11:01
• @mkm No, Piegl discussed that domain on page 152 in chapter 12: Data exchange of The NURBS Book. – xyz Mar 28 '16 at 15:22