Given a cube rotated around the center, how would you calculate the lowest possible point from the center?

287 Views Asked by At

Imagine a cube of any arbitrary size.

Furthermore, imagine the cube can be rotated in any dimension: X/Y/Z.

Given both the rotations and the size, how can you calculate the difference between the center and the lowest point of the cube? (Example: center[z] - lowestZCordinateOfAnyCorner)

For example, let's say there is a cube of size 100 (width/height/depth are the same). If there are no rotations (XRot = 0, YRot = 0, ZRot = 0), then the lowest point is 50 units away from the center. This is because the calculation occurs from the center of the cube to the center of the lowest face of the cube.

On the other hand, with the same cube, if it is rotated so one corner is pointed as low as possible (XRot = 45deg, YRot = 45deg, ZRot = 45deg), the lowest point would be the corner. Using the distance from the center of cube to face (50) and distance of center of face to corner (sqrt(50^2 + 50^2)), we can calculate the distance from cube center to corner using the pythagorean theorem (sqrt((50^2 + 50^2) + 50^2) = ~86.602).

Now my question is, how would you calculate the lowest point of a cube with any arbitrary combination of X/Y/Z rotations? Another way to look at it is, if I take a rod, and move it straight down from the center of the cube, how long until the end of the rod is at the same level as the lowest corner?