I have a random matrix RandomReal[{1, 2}, {20, 20}]
, whose elements represent the heights of an array of tiles. The cross sections of each tile are square and identical, viz, 10 x 10. How can I draw such a 3D structure? In addition, I need to put several layers on each tile, and each layer has the thickness of 0.5. In this case, how can I draw the whole structure or its cross section? Will partial transparency help?
Here is my code:
lambda= 500;
n1 = 1.5; n2 = 1.3;
h1 = lambda/4/n1; h2 = lambda/4/n2;
NQWS = 5;
Wx = 300; Dy = 300;
NX = 20; NY = 20;
h = lambda + RandomReal[{0, 2 lambda}, {NX, NY}];
corner1 =
Flatten[Table[{i*Wx, j*Dy, 0}, {i, 0, NX - 1}, {j, 0, NY - 1}], 1];
corner2 =
Flatten[Table[{i*Wx, j*Dy, h[[i, j]]}, {i, 1, NX}, {j, 1, NY}], 1];
h1corner1 =
Flatten[Table[{i*Wx, j*Dy,
h[[i + 1, j + 1]] + k*(h1 + h2) + h1}, {i, 0, NX - 1}, {j, 0,
NY - 1}, {k, 0, NQWS - 1}], 2];
h1corner2 =
Flatten[Table[{i*Wx, j*Dy, h[[i, j]] + k*(h1 + h2)}, {i, 1, NX}, {j,
1, NY}, {k, 1, NQWS}], 2];
h2corner1 =
Flatten[Table[{i*Wx, j*Dy, h[[i + 1, j + 1]] + k*(h1 + h2)}, {i, 0,
NX - 1}, {j, 0, NY - 1}, {k, 0, NQWS - 1}], 2];
h2corner2 =
Flatten[Table[{i*Wx, j*Dy, h[[i, j]] + k*(h1 + h2) + h1}, {i, 1,
NX}, {j, 1, NY}, {k, 1, NQWS}], 2];
Graphics3D[{EdgeForm[None], Blue,
Table[Cuboid[corner1[[i]], corner2[[i]]], {i, 1, NX*NX}],
Opacity[0.8], Gray,
Table[Cuboid[h1corner1[[i]], h1corner2[[i]]], {i, 1, NX*NX*NQWS}],
Opacity[0.1], Red,
Table[Cuboid[h2corner1[[i]], h2corner2[[i]]], {i, 1, NX*NX*NQWS}]},
Boxed -> False, Lighting -> "Neutral"]
and the following picture is the output structure:
Well, I hope to get one like this:
If I just take the top view in my picture, I cannot tell the difference between the tiles of different heights. Any comments?