Geometry – Width of a Tilted Cube

geometrytrigonometry

I'm projecting a cube onto a hexagon (for RGB to HSL conversion) and I want to calculate the width of the hexagon.

Cube is, first, tilted by 45° ccw on the x axis, and then, tilted by 35.26° ccw on the y axis. Black corner is at the bottom and the white corner is at the top. Both (black and white) corners pass through the z axis.

image

I have four values at hand, but don't know what to do with them, atm. I can get the width of the hexagon with this 3D software, but I need to be able to calculate it mathematically.

Best Answer

What you are saying is that basically one of the cube 3D diagonals, connecting the what-you-call-white vertex to the opposite black vertex, is aligned with the $z$ axis and you are looking at the shadow the cube casts on the $x,y$ plane projected along light rays parallel to the $z$ axis.

Let $O$ be the origin of the coordinate system and thus it is the lowest vertex of the cube. Let the highest vertex is $O'$ which is the opposite to $O$ across the center of the cube. $OO'$ lies on the $z$ axis. Now let $A, B, C$ be the three vertices of the cube immediately attached by edges to $O$. That is $OA, OB, OC$ are the three pairwise orthogonal edges meeting at $O$. Similarly, let $A', B', C'$ be the three pairwise orthogonal edges meeting at $O'$.

Assume all the edges of the cube have length $a$. Now, the planes $ABC$ and $A'B'C'$ are orthogonal to the diagonal $OO'$ i.e. they are orthogonal to the $z$ axis and thus parallel to the $x,y$ plane. The two triangles $ABC$ and $A'B'C'$ are equilateral triangles with edgelength $a\sqrt{2}$. Therefore the orthogonal projection $A_1B_1C_1$ of $ABC$ is also a congruent equilateral triangle of edge length $a\sqrt{2}$. The same is true for the projection $A'_1B'_1C'_1$ of $A'B'C'$. The two equilateral triangles $A_1B_1C_1$ and $A'_1B'_1C'_1$ share a common center, the point $O$ and are related to each other by a rotation of angle $\pi$ (180 degrees). The shadow of the cube is the regular hexagon spanned by the points $A_1C'_1B_1A'_1C_1B'_1$ and you know the length of the segment $A_1B_1 =a \sqrt{2}$. Since triangle $A_1B_1A'_1$ is right angled and the diagonal of the hexagon $A_1A_1' = 2 B_1A'_1 = 2x$ (the latter is the edge of the hexagon). Therefore, by Pythagoras' theorem $4x^2 - x^2 = 2a^2$ which means that $x = a\sqrt{\frac{2}{3}}$ is the edge of the regular hexagon (the projection of the cube). Then, the diagonals of the hexagon are of length $2x = 2 a\sqrt{\frac{2}{3}}$, which is also the diameter (the width) of the hexagon you are looking for.

In your case, for a cube of edge-length $a=255$, the width of its projection is $$2 \cdot 255 \cdot \sqrt{\frac{2}{3}}=416.41325627314...$$

Related Question