English 中文(简体)
添加多功能的文字
原标题:Add text to faces of polyhedron

是否有可能将任何文本添加到一个聚合物的面貌上,如这一人工提取的图象所示(奇数办法与否):

“labelled

很容易贴上vert的标签:

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

“labelled

(even though some of the text is placed in front of the shape for vertices that are hidden. That s probably soluble.)

但是,当我试图对面做同样的事情时,没有任何工作。 <代码>PolyhedronData[“Dodecahedron”,“Faces” 回归图表Complex,而不是坐标。

我对一个容易的解决办法/选择视而不见?

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!

最佳回答

这里采取ky强的做法:

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

Demoing a SmallRhombicosidodecahedron>:

“entergraph

问题回答
a = PolyhedronData["Dodecahedron", "Faces"] /.    GraphicsComplex -> List;
c = 1;
Show[{Graphics3D[
   Text[c++, #] & /@ (Mean /@ (a[[1, #]] & /@ a[[2, 1]]))], 
    PolyhedronData["Dodecahedron"]}, Boxed -> False]

<><>Edit>/strong>

也许更好:

Show[{Graphics3D[
         MapIndexed[Text[#2, #1] &, 
             Mean /@ (PolyhedronData["Dodecahedron", "VertexCoordinates"][[#]] & /@ 
                      PolyhedronData["Dodecahedron", "FaceIndices"])]], 
         PolyhedronData["Dodecahedron"]}, Boxed -> False]

<><>Edit>/strong>

text = Style[#, 128] & /@ Range[12]
Graphics3D@
 Riffle[Texture /@ text, 
       (Append[#1, {VertexTextureCoordinates -> 
          With[{n = Length[First[#1]]}, Table[1/2 {Cos[2 Pi i/n], Sin[2 Pi i/n]}+ 
                                           {1/2, 1/2}, {i, 0, n - 1}]]}] &) /@ 
   Flatten[Normal[PolyhedronData["Dodecahedron", "Faces"]]]]

“entergraph





相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签