# Labeled Cube

Posted 4 months ago
291 Views
|
0 Replies
|
1 Total Likes
|
 How to label faces of a cube with numbers 1 to 6? First, I'll turn text outlines into polygons. SymbolToPolygon[symbol_, dimension_: "3D"] := Module[{pol, poly, index, pos, minmax, diffs, poly2D}, pol = (Cases[ImportString[ExportString[symbol, "PDF"], "PDF"], _FilledCurve, \[Infinity]][[1, 2]]); poly = pol[[1]]; index = 2; While[index <= Length[pol], pos = Position[poly, Nearest[poly, pol[[index, 1]]][[1]]][[1, 1]] ; poly = Join[Take[poly, pos], Reverse[pol[[index]]], Drop[poly, pos - 1]]; index++]; minmax = MinMax /@ Transpose[poly]; diffs = #[[2]] - #[[1]] & /@ minmax; poly2D = (# - Mean /@ minmax)/Max[diffs] & /@ poly; If[dimension === "2D", Polygon[poly2D], Polygon[Append[#, 1] & /@ poly2D]]] After that, rotations and the cube tab={{0,{0,1,0}},{Pi/2,{0,1,0}},{Pi/2,{1,0,0}},{-Pi/2,{1,0,0}},{-Pi/2,{0,1,0}},{Pi,{0,1,0}} }; Graphics3D[Table[Polygon[SymbolToPolygon[ToString[n]][[1]].RotationMatrix[tab[[n,1]], tab[[n,2]]]],{n,1,6}]]  Can anyone improve on that?