2
$\begingroup$
P0={0,0};
P1={1,0}; 
P2={-1,0}; 
P3={0,1};
P4={1,-1};
P5={-1,-1}; 
Framed[Show[Region[ConvexHullMesh[{P0,P1,P3},MeshCellStyle -> {2 -> Opacity[0.5, Red]}],PlotRange->{{-1.1,1.1},{-1.1,1.1}},Axes->True,LabelStyle ->{14,Bold}, ImageSize->Medium],Region[ConvexHullMesh[{P0,P3,P4},MeshCellStyle -> {2 -> Opacity[0.5,Red]}], ImageSize->Medium],Graphics[Text[Style["Cone 1",20,Bold],{0.7,1}]]]]

I have this code where I show in a single plot the intersection of two convex hull. Now I know it is possible to change the color of individual hull's by changing the MeshCellStyle command. But is it also possible to change the color of the intersecting region without major changes in the code? This will help my reader to better recognize the intersection region when I plot many convex hull in a single plot. Thank you

$\endgroup$

1 Answer 1

3
$\begingroup$
chm1 = ConvexHullMesh[{P0, P1, P3}];
chm2 = ConvexHullMesh[{P0, P3, P4}];

You can use RegionIntersection to get the intersection:

intersection = RegionIntersection[chm1, chm2];

and RegionPlot all three regions with different colors using the option PlotStyle:

Framed[RegionPlot[{chm1, chm2, intersection}, 
  PlotStyle -> {Opacity[.5, Red], Opacity[.5, Blue], Opacity[1, Yellow]}, 
  PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
  Axes -> True, Frame -> False, LabelStyle -> {14, Bold}, 
  ImageSize -> Medium, 
  Epilog -> Text[Style["Cone 1", 20, Bold], {0.7, 1}]]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a lot. Very intelligent answer. $\endgroup$
    – Epsilon
    Commented Apr 19, 2020 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.