6
$\begingroup$

I am trying to draw this picture

enter image description here

I tried

CSGRegion["Union", {Cylinder[{{-50, 0, 0}, {50, 0, 0}}, 20], Cylinder[{{0, -50, 0}, {0, 50, 0}}, 20]}] 

enter image description here

$\endgroup$
1
  • $\begingroup$ The question is not off-topic, but I don't see enough effort from your trial, so (-1). $\endgroup$ Commented Apr 19 at 9:48

1 Answer 1

16
$\begingroup$
reg1 = CSGRegion[ "Difference", {Cylinder[{{-50, 0, 0}, {50, 0, 0}}, 20], Cylinder[{{-50, 0, 0}, {50, 0, 0}}, 15]}]; reg2 = CSGRegion[ "Difference", {Cylinder[{{0, -50, 0}, {0, 50, 0}}, 20], Cylinder[{{0, -50, 0}, {0, 50, 0}}, 15]}]; reg=CSGRegion["Intersection", {Style[reg1, Red], Style[reg2, Red]}] 

enter image description here

  • It seems that CSGRegion doesn't support opacity, we have to discretize the region.
Graphics3D[{FaceForm[Directive@{Yellow, Opacity[.2]}], EdgeForm[], BoundaryDiscretizeGraphics[reg1, AccuracyGoal -> 2], BoundaryDiscretizeGraphics[reg2, AccuracyGoal -> 2], reg}, Boxed -> False] 

enter image description here

  • Or OpenCascadeLink
Clear["Global`*"]; Needs["OpenCascadeLink`"]; shape1 = OpenCascadeShape[Cylinder[{{-50, 0, 0}, {50, 0, 0}}, 20]]; shape2 = OpenCascadeShape[Cylinder[{{-50, 0, 0}, {50, 0, 0}}, 15]]; shape3 = OpenCascadeShape[Cylinder[{{0, -50, 0}, {0, 50, 0}}, 20]]; shape4 = OpenCascadeShape[Cylinder[{{0, -50, 0}, {0, 50, 0}}, 15]]; shell12 = OpenCascadeShapeSurfaceMeshToBoundaryMesh[ OpenCascadeShapeDifference[shape1, shape2], "ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.1}]; shell34 = OpenCascadeShapeSurfaceMeshToBoundaryMesh[ OpenCascadeShapeDifference[shape3, shape4], "ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.1}]; bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[ OpenCascadeShapeIntersection[ OpenCascadeShapeDifference[shape1, shape2], OpenCascadeShapeDifference[shape3, shape4]], "ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.02}]; Graphics3D[{FaceForm[Directive@{Red, Opacity[.8]}], EdgeForm[], BoundaryMeshRegion@bmesh, FaceForm[Directive@{Yellow, Opacity[.1]}], EdgeForm[], BoundaryMeshRegion@shell12, BoundaryMeshRegion@shell34, EdgeForm[]}, Boxed -> False] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.