7
$\begingroup$

How do I draw a box with six cylindrical holes, one at the center of each face?

The code for the box:

pts = {{-0.5, -0.5, -0.5}, {-0.5, 0.5, -0.5}, {-0.5, 0.5, 
    0.5}, {-0.5, -0.5, 0.5}, {0.5, -0.5, -0.5}, {0.5, 
    0.5, -0.5}, {0.5, 0.5, 0.5}, {0.5, -0.5, 0.5}};
pts3 = ScalingTransform[{6, 6, 6}][pts];
pts4 = ScalingTransform[{7, 7, 7}][pts];
hex = {{2, 3, 4, 1}, {1, 4, 8, 5}, {4, 3, 7, 8}, {3, 2, 6, 7}, {2, 1, 
    5, 6}, {5, 8, 7, 6}};
box = BoundaryMeshRegion[Join[pts3, pts4], Polygon[hex], 
   Polygon[hex + 8], MeshCellStyle -> Opacity[0.2]]

Mathematica graphics

$\endgroup$
9
$\begingroup$
RegionPlot3D[
 RegionDifference[Cuboid[], 
  RegionUnion[Cylinder[{{0, .5, .5}, {1, .5, .5}}, 1/8],
              Cylinder[{{.5, 0, .5}, {.5, 1, .5}}, 1/8], 
              Cylinder[{{.5, .5, 0}, {.5, .5, 1}}, 1/8]]],
 PlotPoints -> 200,
 PlotStyle -> Opacity[0.7],
 Boxed -> False
 ]

or... just a bit crisper:

RegionPlot3D[
 RegionDifference[Cuboid[], 
    RegionUnion[
    Cylinder[#, 1/8] & /@ 
    {{{0, .5, .5}, {1, .5, .5}}, 
     {{.5, 0, .5}, {.5, 1, .5}}, 
     {{.5, .5, 0}, {.5, .5, 1}}}]],
 PlotPoints -> 200,
 PlotStyle -> Opacity[0.7],
 Boxed -> False]

enter image description here

$\endgroup$
11
$\begingroup$
RegionPlot3D[x^2 + y^2 > 1/16 && x^2 + z^2 > 1/16 && y^2 + z^2 > 1/16,
 {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
 Mesh -> None, Boxed -> False, Axes -> False, 
 PlotStyle -> Opacity[0.8],
 PlotPoints -> 50
 ]

or

BoundaryDiscretizeRegion[
 ImplicitRegion[
  x^2 + y^2 > 1/16 && x^2 + z^2 > 1/16 && y^2 + z^2 > 1/16,
  {{x, -1, 1}, {y, -1, 1}, {z, -1, 1}}
  ],
 MaxCellMeasure -> 0.001, BaseStyle -> Opacity[0.8]
 ]

enter image description here

$\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.