Message Boards Message Boards


BSplineFunction not evaluating as expected in RevolutionPlot3D?

Posted 11 months ago
6 Replies
2 Total Likes


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}]
6 Replies

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]];
      pts[[i + 1]] BSplineBasis[{deg, knots}, i, #], {i, 0, 
       Length[pts] - 1}]]];
 Evaluate[myBSplineFunction[controlPoints][t]], {t, 0, 1}]
Posted 11 months 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.

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 11 months 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!

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.

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

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract