1

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]

user8568
  • 11
  • 1
  • In the way you are presenting the code, NBSpline is left undefined. Do you have its definition in your notebook? – bmf Mar 22 '22 at 18:05
  • @bmf , I took the code for 'NBSpline' from the link attached above but it doesn't work. (https://mathematica.stackexchange.com/questions/71778/how-to-speed-up-the-plotting-of-b-spline-curve?noredirect=1&lq=1) – user8568 Mar 22 '22 at 18:13
  • Ok, thanks. I just wanted to make sure that all of the code was included. – bmf Mar 22 '22 at 18:16
  • @bmf, Thank you for your quick respond. Let me know if you got the curve :) – user8568 Mar 22 '22 at 18:21
  • 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... – bmf Mar 22 '22 at 18:26
  • @bmf, oh i see. I should change the knots then.. Thank you for willing to help! – user8568 Mar 23 '22 at 00:30
  • I am not sure why it works with different values of knots. I don't have a good understanding of the code. In any case, I'm glad I was able to offer some idea :-) – bmf Mar 23 '22 at 00:45

0 Answers0