2

How can I create a cube showing six distinct number grids, one on each face.

I want to use Grid and Graphics3D, but don't know how to connect them together.

For example, the following code makes a cube out of a grid (Grid was called once so all the cube sides have the same type of elements):

vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; 
(*VertexTextureCoordinates*) 
coords = 
  {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, 
   {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, 
   {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, 
   {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, 
   {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, 
   {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};

n = 9;(*Matrix Dimension*)
color = {Red, Blue, Green, Yellow, Orange, Black};
Table[
  mat[k] = 
    Grid[Table[RandomInteger[{1, n^2}], {i, 1, n}, {j, 1, n}], 
      ItemStyle -> 
        Table[
          {FontSize -> 20, Bold, RandomChoice[color]}, 
          {i, 1, n}, {j, 1, n}], 
      Frame -> All], 
  {k, 1, 6}];

(*For 3D visual*)
Graphics3D[
  Table[
    {Texture[mat[k]], Polygon[coords[[k]], VertexTextureCoordinates -> vtc]}, 
    {k, 1, 6}], 
  Boxed -> False]
(*use the same coords and vtc as before*)

I would greatly appreciate it if you could help me.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
user41991
  • 21
  • 2
  • This question needs clarification. There is no built-in Mathematica function Grids. You can't mean Grid because that is a formatting function, not a graphics function. Do you mean a lattice when you write grid? Also, it there are six different grids, what distinguishes them? – m_goldberg Jul 30 '16 at 23:22
  • http://mathematica.stackexchange.com/questions/38379/how-to-map-an-image-to-get-an-illusion-of-3d – Young Jul 31 '16 at 00:19
  • @m_goldberg
    Thanks for your reply. I modified the question.. please check the new change
    – user41991 Jul 31 '16 at 00:26
  • @Young thanks but they are not using Grid – user41991 Jul 31 '16 at 00:27
  • I think I understand your question a little better now, but I still don't understand how want to vary the number grids from face to face. Do you want to use a different value of n on each face? If so, how will those values be determined? – m_goldberg Jul 31 '16 at 11:43

1 Answers1

2

Here is one idea for varying the grids.

vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords =
  {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, 
   {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, 
   {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, 
   {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, 
   {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, 
   {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};
color = {Red, Blue, Green, Brown, Orange, Black};

SeedRandom[42]; 
Table[
  mat[k] = 
    Grid[
      Table[
        Item[RandomInteger[{1, k^2}], 
          BaseStyle -> {FontSize -> 200/k, Bold, RandomChoice[color]}], 
        {i, 1, k}, {j, 1, k}],
      Frame -> All],
  {k, 1, 6}];

Graphics3D[
  Table[
    {Texture[mat[k]], Polygon[coords[[k]], VertexTextureCoordinates -> vtc]}, 
    {k, 1, 6}],
  Boxed -> False]

Here are two views of the result.

cube1

cube2

m_goldberg
  • 107,779
  • 16
  • 103
  • 257