5
$\begingroup$

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$
  • $\begingroup$ What version does this occur on? $\endgroup$ – rcollyer Oct 3 '12 at 12:31
  • $\begingroup$ @rcollyer I see the issue in 8.0.4 $\endgroup$ – PlatoManiac Oct 3 '12 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$ – J. M. is away Oct 3 '12 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$ – jakobbotsch Oct 3 '12 at 12:42
  • 2
    $\begingroup$ I filed the crash as a bug to be looked at. Thanks. $\endgroup$ – user21 Oct 3 '12 at 15:00
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, privacy policy and cookie policy

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