2
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ 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? $\endgroup$
    – m_goldberg
    Jul 30, 2016 at 23:22
  • $\begingroup$ mathematica.stackexchange.com/questions/38379/… $\endgroup$
    – Young
    Jul 31, 2016 at 0:19
  • $\begingroup$ @m_goldberg Thanks for your reply. I modified the question.. please check the new change $\endgroup$
    – user41991
    Jul 31, 2016 at 0:26
  • $\begingroup$ @Young thanks but they are not using Grid $\endgroup$
    – user41991
    Jul 31, 2016 at 0:27
  • $\begingroup$ 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? $\endgroup$
    – m_goldberg
    Jul 31, 2016 at 11:43

1 Answer 1

2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.