Message Boards Message Boards

BSplineFunction not evaluating as expected in RevolutionPlot3D?

GROUPS:

Hello,

Why does the code (shown below) give this error?

Dot::rect: Nonrectangular tensor encountered.

And how might this code be modified to produce the desired plot?

 controlPoints = {{0., 1.48195}, {0.151384, 1.49651}, {0.330883, 1.39382}, {0.488076, 1.2461}, {0.575162, 1.06331}, {0.599079, 0.886118}, {0.547864, 
      0.698224}, {0.46997, 0.542705}, {0.386957, 0.404801}, {0.285357, 0.28673}, {0.314028, -0.0307762}, {0.202299, -0.0181826}, {0., 0.}};

RevolutionPlot3D[BSplineFunction[controlPoints][t], {t, 0, 1}]
POSTED BY: Rian Shams
Answer
1 month ago

Unfortunately BSplineFunction has many shortcomings. It does not honour exact input, it does not obey to PiecewiseExpand, it does not provide the parameterization of BSplineFunction, and now we discover that it does not play well with RevolutionPlot3D. Here is an alternative:

myBSplineFunction[pts_?MatrixQ] := 
  Module[{knots, deg}, 
   knots = Rationalize@BSplineFunction[pts][[6, 1]]; 
   deg = BSplineFunction[pts][[3, 1]];
   Apply[Function, 
    List@Sum[
      pts[[i + 1]] BSplineBasis[{deg, knots}, i, #], {i, 0, 
       Length[pts] - 1}]]];
RevolutionPlot3D[
 Evaluate[myBSplineFunction[controlPoints][t]], {t, 0, 1}]
POSTED BY: Gianluca Gorni
Answer
1 month ago

Thank you! It is unfortunate that BSlpineFunction has some of the shortcomings you address. Yours is a nice modification that preserves the structure of my original answer.

POSTED BY: Rian Shams
Answer
1 month ago

It does work, one just has to represent the components seperately - according to the examples in the documentation:

{fx, fy} = BSplineFunction /@ Transpose[controlPoints];
RevolutionPlot3D[{fx[t], fy[t]}, {t, 0, 1}]
POSTED BY: Henrik Schachner
Answer
1 month ago

Thank you. This is what I was looking for as it wasn't immediately obvious to me that the components needed to be separated out. Appreciate the help!

POSTED BY: Rian Shams
Answer
1 month ago

With ParametricPlot we don't need to separate the components:

ParametricPlot[BSplineFunction[controlPoints][t], {t, 0, 1}]

Here it is RevolutionPlot3D to be blamed more for the inconvenience.

POSTED BY: Gianluca Gorni
Answer
1 month ago

Dear Gianluca,

you are of course right! I should have written "It does work, if one represents ...". And: I like your version of BSplineFunction!

Best regards -- Henrik

POSTED BY: Henrik Schachner
Answer
1 month ago

Group Abstract Group Abstract