6
$\begingroup$
P0={0,0,0};P1={1,0,0};P2={0,1,0};P3={0,0,1};P4={1,1,1};P5={-1,-1,-1};

R[1]=ConvexHullMesh[{P0,P1,P2,P3},Frame->True,PlotRange -> Automatic,MeshCellStyle -> {{2,All}-> Opacity[.4, Red],{1,All}->Black,{0,All}->Blue}];

R[4]=ConvexHullMesh[{P0,P1,P3,P4},Frame->True,PlotRange -> Automatic,MeshCellStyle -> {{2,All}-> Opacity[.4, Red],{1,All}->Black,{0,All}->Blue}];

faces1 = MeshPrimitives[R[1], "Polygons"];
faces4 = MeshPrimitives[R[4], "Polygons"];

colors1 = Opacity[0.4, #]& /@ { Green, Blue, Yellow,Red} ;
colors3 = Opacity[0.4, #]& /@ { Red,Yellow, Green,Purple} ;

Graphics3D[{Transpose@{colors1 , faces1},Transpose@{colors3 , faces4}},  
 PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}, Axes -> True, 
 ImageSize -> Large, AxesOrigin -> {0, 0, 0}, 
 LabelStyle -> {12, Bold, Black}, 
 AxesStyle -> Thick, Boxed -> True,AxesLabel->{x,y,z},Epilog -> {Inset[Style["Inter", 20, Bold], {.2, .8}]} ]

I have the following code which shows the intersection of two convexhull. Although they are intersecting but the cuts in the planes at the points of intersection is not so visible and sharp. Is it possible to improve this by shading or lighting or any other method possible in mathematica? I tried to change opacity and colour combinations of the individual hull but it didn't help much. Thank you.

$\endgroup$

2 Answers 2

4
$\begingroup$
intersectionfaces =  MeshPrimitives[RegionIntersection[R[1], R[4]], "Polygons"];

Graphics3D[{Transpose@{colors1, faces1}, Transpose@{colors3, faces4}, 
  EdgeForm[{Thick, Black}], FaceForm[], intersectionfaces}, 
 PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}, Axes -> True, 
 ImageSize -> Large, AxesOrigin -> {0, 0, 0}, 
 LabelStyle -> {12, Bold, Black}, AxesStyle -> Thick, Boxed -> True, 
 AxesLabel -> {x, y, z}, 
 Epilog -> {Inset[Style["Inter", 20, Bold], {.2, .8}]}]

enter image description here

$\endgroup$
5
$\begingroup$

Possible solution

P0 = {0, 0, 0}; P1 = {1, 0, 0}; P2 = {0, 1, 0}; P3 = {0, 0, 
  1}; P4 = {1, 1, 1}; P5 = {-1, -1, -1};

R[1] = ConvexHullMesh[{P0, P1, P2, P3}, Frame -> True, 
   PlotRange -> Automatic, 
   MeshCellStyle -> {{2, All} -> Opacity[.4, Red], {1, All} -> 
      Black, {0, All} -> Blue}];

R[4] = ConvexHullMesh[{P0, P1, P3, P4}, Frame -> True, 
   PlotRange -> Automatic, 
   MeshCellStyle -> {{2, All} -> Opacity[.4, Red], {1, All} -> 
      Black, {0, All} -> Blue}];

faces1 = MeshPrimitives[R[1], "Polygons"];
faces4 = MeshPrimitives[R[4], "Polygons"];

colors1 = Opacity[0.4, #] & /@ {Green, Blue, Yellow, Red};
colors3 = Opacity[0.4, #] & /@ {Red, Yellow, Green, Purple};

g1 = Graphics3D[{Transpose@{colors1, faces1}, 
   Transpose@{colors3, faces4}}, 
  PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}, Axes -> True, 
  ImageSize -> Large, AxesOrigin -> {0, 0, 0}, 
  LabelStyle -> {12, Bold, Black}, AxesStyle -> Thick, Boxed -> True, 
  AxesLabel -> {x, y, z}, 
  Epilog -> {Inset[Style["Inter", 20, Bold], {.2, .8}]}];
rd = RegionIntersection[R[4], R[1]];

g2 = RegionPlot3D[rd];
Show[g1, g2]

Figure 1

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