# How can I draw this polyhedron?

I'm high school student, and I am doing research about buildings using Mathematica. I want to plot the polyhedron shown below:

I have tried using Table, but it doesn't work. Please help me.

v = Table[
{
{-2, -2, h}
, {-2, 2, h}
, {2, 2, h}
, {2, -2, h}
, {-3, -3, h + 3}
, {-3, 3, h + 3}
, {3, 3, h + 3}
, {3, -3, h + 3}
}
, {h, 0, 1, 3}
];
i = {
{1, 2, 3, 4}
, {1, 2, 6, 5}
, {2, 3, 7, 6}
, {3, 4, 8, 7}
, {4, 1, 5, 8}
, {5, 6, 7, 8}
};

Graphics3D[GraphicsComplex[v, Polygon[i]], Axes -> True]

• Welcome to Mathematica.SE. Could you be more specific in your question? . Only good questions are likely to get great answers. Please edit your question to improve it and make more clear what you are asking. Also consider taking the tour. Aug 21, 2015 at 14:57
• Aren't you doing exactly that? Aug 21, 2015 at 15:04
• Can you clarify what you need, because you are using a Table, do you just want help to simplifiy your code?
– M.R.
Aug 21, 2015 at 15:51
• sorry. I want to regulate height using table
– 유민우
Aug 22, 2015 at 1:05
• In case this was contributing to your confusion, please note that the iteration specifier {h, 0, 1, 3} makes h run from 0 to 1 in steps of 3. So in fact h only ever takes the value 0. To run from 0 to 3 in steps of 1, use {h, 0, 3, 1} or just {h, 0, 3}. (The final value and step are given in the opposite order compared to, e.g., Matlab.) Aug 23, 2015 at 10:00

I am glad that you are using Mathematica in your high school project.

I think you forgot to mention in your question that the code you posted doesn't actually produce the image you showed; you may also want to mention where you obtained that image.

Anyway, since your figure is made up of repeating units, I generated one unit, then translated it multiple times to generate the rest of the figure. You could use the following code as an inspiration to tweak to your desires:

Graphics3D[
Table[
GeometricTransformation[
Pyramid[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, -2}}],
TranslationTransform[{0, 0, n}]
],
{n, 0, 5, 1}
],
Axes -> True
]


## UPDATE

As @J.M. mentioned in his comment, this is a pretty versatile approach. You can swap out different 3D repeating units, and the rest of the code will do the stacking for you.

In fact, a more faithful representation of what you showed in the picture can be obtained using a pyramidal frustum (i.e. a pyramid with the tip chopped off) as the repeating unit:

repeatingUnit = Hexahedron[{
(*bottom face*)
{-2, -2, 0}, {2, -2, 0}, {2, 2, 0}, {-2, 2, 0},
(*top face*)
{-3, -3, 3}, {3, -3, 3}, {3, 3, 3}, {-3, 3, 3}
}];

Graphics3D[
Table[
GeometricTransformation[
repeatingUnit,
TranslationTransform[{0, 0, n}]
],
{n, 0, 15, 3}
],
Axes -> True
]


You can explore further by considering e.g. less regular pyramids, pyramids with non-horizontal bases, etc.

• Hopefully, OP realizes that the Pyramid[] in your code is replaceable, if, say, he wants frustums instead. Aug 21, 2015 at 16:58
• @J. M. Good point. I updated the code to include that, in specific to separate the construction of an explicit repeating unit from the generation of the 3D graphic itself. Aug 21, 2015 at 17:19
• +1 for the effort put into interpreting a weird question Aug 21, 2015 at 17:32