Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to faces of polyhedron

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):

labelled faces of dodecahedron

It was easy enough to label the vertices:

c = 1;
Show[{Graphics3D[
   Text[c++, #] & /@ PolyhedronData["Dodecahedron", "VertexCoordinates"]], 
   PolyhedronData["Dodecahedron"]},
   Boxed -> False]

labelled edges of dodecahedron

(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!

like image 228
cormullion Avatar asked Nov 16 '11 15:11

cormullion


People also ask

How will you name the polyhedron?

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.

What are the parts of a polyhedron?

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.

How many edges does a polyhedron with 6 faces and 6 vertices have?

6 Faces. 8 Vertices (corner points) 12 Edges.


1 Answers

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
 ]

enter image description here

Demoing a "SmallRhombicosidodecahedron":

enter image description here

like image 97
Szabolcs Avatar answered Oct 02 '22 18:10

Szabolcs