1
$\begingroup$

I am trying to plot the B-Spline curve of degree 2 based on the B-Spline basis functions and curve's codes posted here How to speed up the plotting of B-spline curve? (Look at Trial 1 & Test 1). By definition, the interval should be {5, 8} that is from {5, 7} and {7, 8} for d = 2 and I would like to plot the curve. The details of my question are as follows:

knots = {2,4,5,7,8,10,11}

pts = {{1, 2}, {3, 5}, {6, 2}, {9, 4}};

I tried using the code given in the link but no graph appear. Anyone knows why?

knots = {2,4,5,7,8,10,11}
pts = {{1, 2}, {3, 5}, {6, 2}, {9, 4}}; 

 BSplinePlot1[pts : {{_, _} ..}, knots_, opts : OptionsPattern[Plot]] :=
 Module[{p = Length@First@Split[knots] - 1, a, b},
  {a, b} = {First[knots], Last[knots]};
  ParametricPlot[
  Evaluate@
  Simplify@
    Total@ 
     MapIndexed[
      NBSpline[First@#2 - 1, p, knots, u] #1 &, pts], {u, a, b}, opts]
]

BSplinePlot1[pts, knots, ImageSize -> 600]
$\endgroup$
7
  • $\begingroup$ In the way you are presenting the code, NBSpline is left undefined. Do you have its definition in your notebook? $\endgroup$
    – bmf
    Commented Mar 22, 2022 at 18:05
  • $\begingroup$ @bmf , I took the code for 'NBSpline' from the link attached above but it doesn't work. (mathematica.stackexchange.com/questions/71778/…) $\endgroup$
    – user8568
    Commented Mar 22, 2022 at 18:13
  • $\begingroup$ Ok, thanks. I just wanted to make sure that all of the code was included. $\endgroup$
    – bmf
    Commented Mar 22, 2022 at 18:16
  • $\begingroup$ @bmf, Thank you for your quick respond. Let me know if you got the curve :) $\endgroup$
    – user8568
    Commented Mar 22, 2022 at 18:21
  • $\begingroup$ I have not made it to work yet. Some trial and error indicate that knots is causing some trouble. What I mean is that if you try knots = {0, 0, 0, 1/8, 2/8, 3/8, 1}; instead of your values you get a plot. Not sure why as I am not familiar with the code. And I am not sure if this is a helpful comment to be honest. I hope it is... $\endgroup$
    – bmf
    Commented Mar 22, 2022 at 18:26

0

Your Answer

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

Browse other questions tagged or ask your own question.