7
$\begingroup$

The following code helps me draw a polyhedron. I would like to color each triangular face in red and make the edges of the polyhedron thicker. I've looked at the post, but I'm still not sure how to do it.

   Show[Graphics3D[{Opacity[0.3], FaceForm[Blue], 
       PolyhedronData["SmallRhombicuboctahedron", "Faces"]}], 
     Boxed -> False]

enter image description here

$\endgroup$

5 Answers 5

6
$\begingroup$

Step for step:

polygons = PolyhedronData["SmallRhombicuboctahedron", "Polygons"];

cor = PolygonCoordinates /@ polygons;

Find positions of triangular faces:

pos = Flatten @ Position[Length /@ cor, 3]

{19, 20, 21, 22, 23, 24, 25, 26}

Color them:

polygons[[pos]] = {Red, polygons[[pos]]};

Graphics3D[{Opacity[0.5], FaceForm[
   RGBColor[0, 0, 1]], EdgeForm[{Thickness[Large], GrayLevel[0]}], polygons}]

enter image description here

$\endgroup$
5
$\begingroup$

Edit

faces = PolyhedronData["SmallRhombicuboctahedron", "Faces"];

faces /. 
  Polygon[pts_] :> 
   Insert [Polygon /@ GatherBy[pts, Length[#] == 3 &], Red, 
    2] // Graphics3D

enter image description here

Original

We change the strucure of the data of the PolyhedronData["SmallRhombicuboctahedron", "Faces"] to get faces1 and faces2

faces = PolyhedronData["SmallRhombicuboctahedron", "Faces"];
faces1 = 
 faces /. Polygon[pts_] :> Polygon[Select[pts, Length@# == 3 &]];
faces2 = 
  faces /. Polygon[pts_] :> Polygon[Select[pts, Length@# > 3 &]];
Show[Graphics3D[faces2], Graphics3D[{Red, faces1}], Boxed -> False]

enter image description here

$\endgroup$
4
$\begingroup$
t = PolyhedronData["SmallRhombicuboctahedron", "Faces"];
polys = First@Normal@t;
cols = Scan[
      If[Length@MeshPrimitives[#, 1] == 3, Sow@Red, 
        Sow@Lighter@Blue] &, polys] // Reap // Last // First;
edges = Scan[
      If[Length@MeshPrimitives[#, 1] == 3, Sow@Thick, Sow@Thin] &, 
      polys] // Reap // Last // First;
Graphics3D[{
  MapThread[{FaceForm[Opacity[0.7, #1]], EdgeForm[#2], #3} &, {cols, 
    edges, polys}]
  }
 , Boxed -> False
 ]

enter image description here

$\endgroup$
4
$\begingroup$
styles = FaceForm[Opacity[.5, #]] & /@ {Green, Orange};

PolyhedronData["SmallRhombicuboctahedron", "Graphics3D"] /. 
 p_Polygon :> Map[{styles[[5 - Length @ #]], Polygon @ #} &] @ First @ p

enter image description here

$\endgroup$
3
$\begingroup$
Show[Graphics3D[{Opacity[0.3], FaceForm[Red], 
   EdgeForm[Directive[Thick, Green]], 
   PolyhedronData["SmallRhombicuboctahedron", "Faces"]}], 
 Boxed -> False]

enter image description here

$\endgroup$
0

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.