4
$\begingroup$

So I'm having trouble doing this, and I've found a way to subtract one filled cylinder from another to create it this way, but the thing is, I want to put more objects inside the hollow cylinder, but I'm not sure how to do this without subtracting the entire inside of the cylinder, including what I want to be kept inside of it. Also, I'd be open to using the Tube 3D graphic, if there's a way to make that have some thickness. If it helps, or as a starting point, here's my code so far (that doesn't work, but shows what I'm trying to create in separate pieces):

cyl1 = Cylinder[{{0, 5, 5}, {10, 5, 5}}, 3];
cyl2 = Cylinder[{{0, 5, 5}, {10, 5, 5}}, 4];
cyl = Graphics3D[{cub2,  cub1 }] DiscretizeRegion[
RegionDifference[cyl2, cyl1]];

oth = Graphics3D[{Cuboid[{9, 4, 4}, {9.2, 6, 6}], 
Cuboid[{9, 4.8, 6}, {9.2, 5.2, 8}], {AbsoluteThickness[5], 
 Line[{{8, 4, 2.2}, {8, 4, 7.8}}], 
 Line[{{8, 6, 2.2}, {8, 6, 7.8}}], 
 Line[{{8, 3, 2.8}, {8, 3, 7.2}}], 
 Line[{{8, 7, 2.8}, {8, 7, 7.2}}], Line[{{8, 5, 2}, {8, 5, 8}}]}}];

Show[cyl, oth]
$\endgroup$
3
$\begingroup$

I think you probably meant cub1 and cub2 to be cyl1 and cyl2 respectively; also, cyl should be assigned the output of RegionDifference, and not the Graphics3D, if I understand what you mean.

Here I apply those changes to your code and remove extra parts:

cyl1 = Cylinder[{{0, 5, 5}, {10, 5, 5}}, 3];
cyl2 = Cylinder[{{0, 5, 5}, {10, 5, 5}}, 4];
cyl = DiscretizeRegion[RegionDifference[cyl2, cyl1]]

oth = Graphics3D[{
    Cuboid[{9, 4, 4}, {9.2, 6, 6}], Cuboid[{9, 4.8, 6}, {9.2, 5.2, 8}],
    AbsoluteThickness[5],
    Line[{{8, 4, 2.2}, {8, 4, 7.8}}], Line[{{8, 6, 2.2}, {8, 6, 7.8}}],
    Line[{{8, 3, 2.8}, {8, 3, 7.2}}], Line[{{8, 7, 2.8}, {8, 7, 7.2}}],
    Line[{{8, 5, 2}, {8, 5, 8}}]}
  ];

Show[cyl, oth]

Mathematica graphics

That actually looks pretty nice to me!

If this is not what you intended, however, you might want to edit your question to specify your desired output.

$\endgroup$
  • $\begingroup$ Wow thanks so much, I didn't realize you could make the discretized region into an object and then show both. This is exactly what I wanted! Thank you. $\endgroup$ – SmcWill Feb 6 '17 at 6:41
  • $\begingroup$ @SmcWill You are very welcome! $\endgroup$ – MarcoB Feb 6 '17 at 6:45
0
$\begingroup$

If you don't care to have the interior, you can just use ParametricPlot3D to generate the exterior surfaces:

washer[innerr_, outerr_, zmin_, zmax_] := {
  Table[
     ParametricPlot3D[{r Cos[t], r Sin[t], z}, {z, zmin, 
       zmax}, {t, 0, 2Pi}, Mesh -> None, 
      PlotPoints -> {2, 65}, 
      BoundaryStyle -> Automatic], {r, {innerr, outerr}}], 
    Table[ParametricPlot3D[{r Cos[t], r Sin[t], z}, {r, 
       innerr, outerr}, {t, 0, 2Pi}, Mesh -> None, 
      PlotPoints -> {2, 65}, 
      BoundaryStyle -> Automatic], {z, {zmin, zmax}}]
    }
  Show[washer[1, 2, 0, 1], PlotRange -> All, Boxed -> False, 
   Axes -> False]
$\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.