Skip to main content

Cube spinning 180° about z-parallel axis

Short answer

Translate centre to origin, rotate 180° about z, translate back. Matrix: x' = 2-x, y' = 2-y, z' = z, or M = [[-1,0,0,2],[0,-1,0,2],[0,0,1,0],[0,0,0,1]].

A 2 units length cube with a diagonal passing through (0,0,0) and (2,2,2) is spinning about an axis parallel to z-axis with angle 180 degree. Obtain the matrix involved for the operation.

Assumption: the cube has side 2 with opposite corners (0,0,0) and (2,2,2). The axis is parallel to the z-axis and passes through the centre of the cube, so the axis is the line x = 1, y = 1. (Rotating about an axis through the centre keeps the cube in place.)

Method: translate the axis to the z-axis, rotate by 180° about z, translate back.

M = T(1, 1, 0) · Rz(180°) · T(−1, −1, 0)

cos180° = −1, sin180° = 0

T(1,1,0)   Rz(180°)            T(-1,-1,0)
| 1 0 0 1 | | -1  0 0 0 |    | 1 0 0 -1 |
| 0 1 0 1 | |  0 -1 0 0 |    | 0 1 0 -1 |
| 0 0 1 0 | |  0  0 1 0 |    | 0 0 1  0 |
| 0 0 0 1 | |  0  0 0 1 |    | 0 0 0  1 |

Multiplying:

M = | -1  0 0 2 |
    |  0 -1 0 2 |
    |  0  0 1 0 |
    |  0  0 0 1 |

So x' = 2 − x, y' = 2 − y, z' = z. Check: the corner (0,0,0) goes to (2,2,0) and (2,2,2) goes to (0,0,2), so the cube occupies the same region.

If the axis were instead the z-axis itself (through the origin), the matrix would be diag(−1, −1, 1, 1).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 4 questions →