5
$\begingroup$

Bug introduced in 8.0.4 or earlier, persisting through 13.2 or later


I'm trying to rotate 4 piecewise functions around the X-axis using RevolutionPlot3D. The 4 functions I have are:

bottom[x_] := Piecewise[{{{2 + x - x^2/6}, 0 <= x < 3}}, Indeterminate]
side[x_] := Piecewise[{{7/2, 3 <= x < 15}}, Indeterminate]
top[x_] := Piecewise[{{{37/2 - x}, 15 <= x < 17}}, Indeterminate]
neck[x_] := Piecewise[{{3/2, 17 <= x <= 20}}, Indeterminate]

If I try to rotate all of these around the X-axis using RevolutionPlot3D, I get errors:

RevolutionPlot3D[{{bottom[x]}, {side[x]}, {top[x]}, {neck[x]}}, {x, 0, 20},
                 AxesLabel -> {"x", "y", "z"}, RevolutionAxis -> {1, 0, 0}]

This gives me

Dot::rect: Nonrectangular tensor encountered.

errors.

This has worked previously with other functions. I tried only the straight lines one for debugging; that is, side and neck:

RevolutionPlot3D[{{side[x]}, {neck[x]}}, {x, 0, 20}, 
 AxesLabel -> {"x", "y", "z"}, RevolutionAxis -> {1, 0, 0}]

But this actually crashes the Mathematica kernel. Any ideas how I get Mathematica to show a revolution plot around the X-axis of these 4 functions?

$\endgroup$
11
  • $\begingroup$ What version does this occur on? $\endgroup$
    – rcollyer
    Commented Oct 3, 2012 at 12:31
  • $\begingroup$ @rcollyer I see the issue in 8.0.4 $\endgroup$ Commented Oct 3, 2012 at 12:35
  • $\begingroup$ Why not merge your four functions as a single Piecewise[] object: Piecewise[{{2 + x - x^2/6, 0 <= x < 3}, {7/2, 3 <= x < 15}, {37/2 - x, 15 <= x < 17}, {3/2, 17 <= x <= 20}}, Indeterminate]? $\endgroup$ Commented Oct 3, 2012 at 12:38
  • $\begingroup$ That actually worked! The reason I didn't do that to begin with was that I was working with each function separately. $\endgroup$ Commented Oct 3, 2012 at 12:42
  • 2
    $\begingroup$ I filed the crash as a bug to be looked at. Thanks. $\endgroup$
    – user21
    Commented Oct 3, 2012 at 15:00

1 Answer 1

9
$\begingroup$

If I merge your four components into a single Piecewise[] object, things work out:

RevolutionPlot3D[
 Piecewise[{{2 + x - x^2/6, 0 <= x < 3},
            {7/2, 3 <= x < 15},
            {37/2 - x, 15 <= x < 17},
            {3/2, 17 <= x <= 20}}], {x, 0, 20},
           AxesLabel -> {"x", "y", "z"}, Mesh -> None, RevolutionAxis -> {1, 0, 0}]

bottle with gaps

though there are unsightly gaps in your bottle, which can be rectified by adding Exclusions -> None to the options:

bottle without gaps

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.