Is it possible to automate the addition of any text to the faces of a polyhedron, like this manually-drawn graphic shows (the example's odd numbering scheme isn't relevant):
It was easy enough to label the vertices:
c = 1;
Show[{Graphics3D[
Text[c++, #] & /@ PolyhedronData["Dodecahedron", "VertexCoordinates"]],
PolyhedronData["Dodecahedron"]},
Boxed -> False]
(even though some of the text is placed in front of the shape for vertices that are hidden. That's probably soluble.)
But when I tried to do the same thing for faces, nothing worked. PolyhedronData["Dodecahedron", "Faces"]
returns a GraphicsComplex, rather than coordinates.
Am I overlooking an easy solution/option?
Edit: thanks for these answers, they're all brilliant. If I could combine the text placing of szabolcs' answer with the text quality of belisarius', the perfect solution is in sight!
counting the number of faces, find the Greek prefix that matches the number of faces, attach this prefix to "hedron". For example, a polyhedron with 5 faces could be called pentahedron.
Parts of a Polyhedron The dimensions of a polyhedron are classified as faces, edges, and vertices. Face: The flat surface of a polyhedron is termed as its face. Edge: The two faces meet at a line called the edge. Vertices: The point of intersection of two edges is a vertex.
6 Faces. 8 Vertices (corner points) 12 Edges.
Here's a funky approach:
(* this function just transforms the polygon onto the [0,1] 2D square *)
vtc[face_, up_:{0,0,1}] := Module[{pts, pts2, centre, r, r2, topmost},
pts = N@face;
centre = Mean[pts];
pts = (# - centre & /@ pts);
r = SingularValueDecomposition[pts][[3]];
(* these two lines ensure that the text on the outer face
of a convex polyhedron is not mirrored *)
If[Det[r] < 0, r = -r];
If[Last[centre.r] < 0, r = r.RotationMatrix[\[Pi], {1, 0, 0}]];
pts2 = Most /@ (pts.r);
topmost = Part[pts2, First@Ordering[up.# & /@ pts, -1]];
r2 = Transpose[{{#2, -#1} & @@ topmost, topmost}];
r2 /= Norm[r2];
Rescale[pts2.r2]
]
faces = First /@ First@Normal@PolyhedronData["Dodecahedron", "Faces"];
numbers =
Graphics[Text[
Style[#, Underlined, FontFamily -> "Georgia",
FontSize -> Scaled[.3]]]] & /@ Range@Length[faces];
Graphics3D[
MapThread[{Texture[#1],
Polygon[#2, VertexTextureCoordinates -> vtc[#2]]} &, {numbers,
faces}],
Boxed -> False
]
Demoing a "SmallRhombicosidodecahedron"
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With