Skip to main content
added 1 character in body
Source Link
xyz
  • 655
  • 4
  • 38
  • 117

Re: your error

BSplinePlot2[pts : {{_, _} ..}, knots_, opts : OptionsPattern[{Plot, BSplinePlot}]] := 
 Module[{p = Length@First@Split[knots] - 1, a, b}, 
  {a, b} = {First[knots], Last[knots]};
  With[{a1 = a, b1 = b}, 
   ParametricPlot[
    Total@MapIndexed[NBSpline[First@#2 - 1, p, knots, u] #1 &, pts], {u, a1, b1},
    Evaluate[Sequence @@ FilterRules[{opts}, Options[Plot]]], 
    Epilog -> If[OptionValue[ShowPoints], 
                Join[Text @@@ (Thread@{Table[ Style[Subscript["P", i], 14], {i, 0, Length@pts - 1}], 
                     # + {.4, .2} & /@ pts}), {Red,PointSize[0.015],Point[pts], Green, Line[pts]}]]]]]]]]]

pts = {{0, 0}, {0, 2}, {2, 3}, {4, 0}, {6, 3}, {8, 2}, {8, 0}};
knots = {0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1}; 
BSplinePlot2[pts, knots, PlotRange -> {{0, 10}, {0, 5}}, ShowPoints -> True]

Mathematica graphics

Re: your error

BSplinePlot2[pts : {{_, _} ..}, knots_, opts : OptionsPattern[{Plot, BSplinePlot}]] := 
 Module[{p = Length@First@Split[knots] - 1, a, b}, 
  {a, b} = {First[knots], Last[knots]};
  With[{a1 = a, b1 = b}, 
   ParametricPlot[
    Total@MapIndexed[NBSpline[First@#2 - 1, p, knots, u] #1 &, pts], {u, a1, b1},
    Evaluate[Sequence @@ FilterRules[{opts}, Options[Plot]]], 
    Epilog -> If[OptionValue[ShowPoints], 
                Join[Text @@@ (Thread@{Table[ Style[Subscript["P", i], 14], {i, 0, Length@pts - 1}], 
                     # + {.4, .2} & /@ pts}), {Red,PointSize[0.015],Point[pts], Green, Line[pts]}]]]]

pts = {{0, 0}, {0, 2}, {2, 3}, {4, 0}, {6, 3}, {8, 2}, {8, 0}};
knots = {0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1}; 
BSplinePlot2[pts, knots, PlotRange -> {{0, 10}, {0, 5}}, ShowPoints -> True]

Mathematica graphics

Re: your error

BSplinePlot2[pts : {{_, _} ..}, knots_, opts : OptionsPattern[{Plot, BSplinePlot}]] := 
 Module[{p = Length@First@Split[knots] - 1, a, b}, 
  {a, b} = {First[knots], Last[knots]};
  With[{a1 = a, b1 = b}, 
   ParametricPlot[
    Total@MapIndexed[NBSpline[First@#2 - 1, p, knots, u] #1 &, pts], {u, a1, b1},
    Evaluate[Sequence @@ FilterRules[{opts}, Options[Plot]]], 
    Epilog -> If[OptionValue[ShowPoints], 
                Join[Text @@@ (Thread@{Table[ Style[Subscript["P", i], 14], {i, 0, Length@pts - 1}], 
                     # + {.4, .2} & /@ pts}), {Red,PointSize[0.015],Point[pts], Green, Line[pts]}]]]]]

pts = {{0, 0}, {0, 2}, {2, 3}, {4, 0}, {6, 3}, {8, 2}, {8, 0}};
knots = {0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1}; 
BSplinePlot2[pts, knots, PlotRange -> {{0, 10}, {0, 5}}, ShowPoints -> True]

Mathematica graphics

Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

Re: your error

BSplinePlot2[pts : {{_, _} ..}, knots_, opts : OptionsPattern[{Plot, BSplinePlot}]] := 
 Module[{p = Length@First@Split[knots] - 1, a, b}, 
  {a, b} = {First[knots], Last[knots]};
  With[{a1 = a, b1 = b}, 
   ParametricPlot[
    Total@MapIndexed[NBSpline[First@#2 - 1, p, knots, u] #1 &, pts], {u, a1, b1},
    Evaluate[Sequence @@ FilterRules[{opts}, Options[Plot]]], 
    Epilog -> If[OptionValue[ShowPoints], 
                Join[Text @@@ (Thread@{Table[ Style[Subscript["P", i], 14], {i, 0, Length@pts - 1}], 
                     # + {.4, .2} & /@ pts}), {Red,PointSize[0.015],Point[pts], Green, Line[pts]}]]]]

pts = {{0, 0}, {0, 2}, {2, 3}, {4, 0}, {6, 3}, {8, 2}, {8, 0}};
knots = {0, 0, 0, 1/5, 2/5, 3/5, 4/5, 1, 1, 1}; 
BSplinePlot2[pts, knots, PlotRange -> {{0, 10}, {0, 5}}, ShowPoints -> True]

Mathematica graphics