color sides in convex Hull

I'm using this code to show the convex hull.

I want to give every sides color because I'm doing some changes in convex hull and I need to see every sides alone.

  ClearAll["Global*"]
M = x^4 + x y z + y^4 + z^4 + x^2 z^2
p = CoefficientRules[M, {x, y, z}][[All, 1]]
chull = ConvexHullMesh[p];
Show[HighlightMesh[chull, Labeled[1, "Index"]],
Graphics3D[{Red, Sphere[p, 0.05], Black,
Map[Text[#, # + {0., 0, 0.1}] &, p]}]
, Axes -> True, Boxed -> True, AxesLabel -> {x, y, z}]


Another step: Can I cut part of the convex hull (or can I just see part of convex hull) because in my work I will just focus on the part from the view from (0,0,0)

Thank you

• Not sure if it matters, but your convex hull mesh has six 2D faces. It might be easier to work with if you drop the unnecessary point {2, 0, 2}. So q = Drop[p, {2}]; newchull = ConvexHullMesh[q]; will give you a mesh with the expected four faces. Of course, you may want 6 faces. In which case, nevermind. – aardvark2012 Oct 28 '17 at 7:25
• @aardvark2012 thank you for your comment, but {2,0,2} will not count because it is on the plane. however, I need a part of the convex hull because when I have a system of equations i will face many planes on my convex hull then I need something call the main part of my work which is the part from the view from the point (0,0,0). – Ateq Alsaadi Oct 28 '17 at 7:42

Mathematica graphics always have a corresponding Graphics or Graphics3D expression. i.e. functions like Plot and ConvexHull don't generate graphics, they generate code. We can take the code and adapt it as required. The code can usually be seen using FullForm, but in this case we also need to use Show:

(gr = chull // Show) // FullForm


Note in the output of the preceding expression the following:

Annotation[
Polygon[List[List[1, 3, 4], List[3, 5, 4], List[4, 5, 2],
List[5, 3, 2], List[3, 1, 2], List[1, 4, 2]]], "Geometry"]


This is clearly the polygons in the figure. (The coordinates are integers which are translated into coordinates by GraphicsComplex, which wraps this expression.) Here is how we can change this expression to color the sides:

gr /. RuleDelayed[
Annotation[Polygon[polygons__List], "Geometry"],
Annotation[
MapIndexed[{ColorData[97, First[#2]], Polygon[#]} &, polygons]]
]


The operations that you apply to these polygons are arbitrary. You can also use it to remove planes as what you ask for.

• Thank you for your answer. I'm new in mathematica can you please write the full code of my equation. The idea that I'm working on convex hull and I want to see the view of (0,0,0) with color which exactly the one you add in your answer. – Ateq Alsaadi Oct 29 '17 at 15:11
• @AteqAlsaadi I'm sorry, but I don't know what that means. The chull` variable is from your question, so it is already based on your equation. – C. E. Oct 31 '17 at 12:12