Polyhedra

Math 282 Computational Geometry

3D Graphics Functions

Here is a function that draws a polyhedron:

draw3D[poly_]:=Graphics3D[{EdgeForm[Thick],FaceForm[Opacity[0.9]],PolyhedronData[poly,"GraphicsComplex"]},Boxed->False]

Try it out:

draw3D["Cube"]

The next function colors faces of polyhedra by their number of edges. (Code modified from https://reference.wolfram.com/language/ref/PolyhedronData.html .)

colorFaces3D[poly_]:=Module[
{color=Association[{3->Red,4->Orange,5->Yellow,6->Green,8->Blue,10->Purple}],
gc=PolyhedronData[poly,"GraphicsComplex"]},
Graphics3D[
GraphicsComplex[N[gc[[1]]],({Glow[color[Length[First[#]]]],Polygon[#]}&)/@SplitBy[Sort[gc[[2,1]]],Length]],
Sequence[Boxed->False,Lighting->None,Method->{"ShrinkWrap"->True}]
]
]

Try it out :

colorFaces3D["Cube"]

Regular Polyhedra

{draw3D["Tetrahedron"],draw3D["Octahedron"],draw3D["Icosahedron"]}

{draw3D["Cube"],draw3D["Dodecahedron"]}

Semi-Regular Polyhedra

draw3D/@{"TruncatedTetrahedron","TruncatedOctahedron","TruncatedIcosahedron","TruncatedCube","TruncatedDodecahedron"}

Manipulate[Graphics3D[{EdgeForm[Thick],FaceForm[Opacity[0.9]],TruncatedPolyhedron[Cube[],length]},Boxed->False],{length,0,0.5}]

draw3D/@ {"Cuboctahedron","SmallRhombicuboctahedron","GreatRhombicuboctahedron","Icosidodecahedron","SmallRhombicosidodecahedron","GreatRhombicosidodecahedron"}

draw3D/@{"SnubCube","SnubDodecahedron"}

PolyhedronData

?PolyhedronData

PolyhedronData["Classes"]

PolyhedronData["Prism"]

{colorFaces3D/@PolyhedronData["Archimedean"]}

{colorFaces3D/@PolyhedronData["Johnson"]}