Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
What version does this occur on? –  rcollyer Oct 3 '12 at 12:31
    
@rcollyer I see the issue in 8.0.4 –  PlatoManiac Oct 3 '12 at 12:35
    
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]? –  J. M. Oct 3 '12 at 12:38
    
That actually worked! The reason I didn't do that to begin with was that I was working with each function separately. –  Janiels Oct 3 '12 at 12:42
2  
I filed the crash as a bug to be looked at. Thanks. –  user21 Oct 3 '12 at 15:00

1 Answer 1

up vote 8 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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