2
$\begingroup$

Currently I can print out this using Graphics3d: Graph Here's the code:

a = (-5 \[Pi])/2;
b = (5 \[Pi])/2;
dx = (b - a)/50;
f[x_] := 2 Cos[x];
startpos[1, k_] := a + (k - 1) dx;
startpos[2, k_] := a + k*dx;
startpos[3, k_] := a + (2 k - 1)/2 dx;

model = Graphics3D[{Table[
Cuboid[{{a + (l - 1) dx, 0, 0}, {a + l*dx, +.01, 
   f[startpos[3, l]] + .01}}], {l, 1, 50, 1}]}];

Show[model]

I want to rotate it around the y-axis. I already tried using RevolutionPlot3d, but I'm not sure how to set it up exactly. Here's my failed attempt:

model = RevolutionPlot3D[{Table[
 Cuboid[{{a + (l - 1) dx, 0, 0}, {a + l*dx, +.01, 
    f[startpos[3, l]] + .01}}], {l, 1, 50, 1}]}, {x, a, b}, 
RevolutionAxis -> "Y", AspectRatio -> Automatic, Mesh -> None, 
BoundaryStyle -> Black, PlotStyle -> Thickness[.1]] ;
Show[model]
$\endgroup$
2
$\begingroup$

I would switch approach to something like:

Show[
     RevolutionPlot3D[2 Cos[Floor[x, (Pi/10)]], {x, 0, 9 Pi/2 + .2}, 
                      Exclusions -> None, PlotPoints -> 100, MeshStyle -> Thick],
     RevolutionPlot3D[0, {x, 0, 9 Pi/2}, Exclusions -> None, 
                                         PlotPoints -> 50, MeshStyle -> Thick]
     ,
     ImageSize -> 800]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Your first version acutely reminded me of a Guglhupf (yum)! Please roll back to the delicious seasonal function. $\endgroup$ – Yves Klett Dec 12 '14 at 15:11
  • 1
    $\begingroup$ @YvesKlett Wow, that name sounds like a joke :) But yum indeed ;) $\endgroup$ – Kuba Dec 13 '14 at 21:30
1
$\begingroup$

Firstly, no need to use Show, simply remove the ; from the end of your Graphics3D expressions.

Secondly, try evaluating:

Graphics3D[
 Table[Cuboid[{{a + (l - 1) dx, 0, 0}, {a + l*dx, +.01, 
     f[startpos[3, l]] + .01}}], {l, 1, 50, 1}], 
 AxesLabel -> {x, y, z}, Axes -> True, BoxRatios -> 1, Ticks -> None, 
 AxesOrigin -> {0, 0, 0}, Boxed -> False, 
 AxesStyle -> Directive[Orange, 12]]

Orientation plot

Are you sure you want to rotate it about the y-axis? Isn't it going to be a mess?

I suspect you mean the x-axis, in which case basically you want to replace Cuboid[{{x0,0,0},{x1,y1,z1}}] -> Cylinder[{{x0,0,0},{x1,0,0}},Abs[z1]]. (And forget about RevolutionPlot3D which creates surfaces of revolution rather than revolving graphics primitives.)

model = Graphics3D[
  Table[Cylinder[{{a + (l - 1) dx, 0, 0}, {a + l*dx, 0, 0}}, 
    Abs[f[startpos[3, l]]]], {l, 1, 50}]]

Rotated plot

| improve this answer | |
$\endgroup$
  • $\begingroup$ OP said y but I think he meant z. But not x. Maybe you are right, I don't know... :) $\endgroup$ – Kuba Dec 12 '14 at 10:43
  • $\begingroup$ @Kuba You're bound to be correct, that's the more difficult axis! $\endgroup$ – MikeLimaOscar Dec 12 '14 at 11:40

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.