---
title: "Cube spinning 180° about z-parallel axis"
subject: "Computer Graphics"
chapter: 4
key: "semester_5/computer_graphics:cube-spin-180-z-axis"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/cube-spin-180-z-axis
site: BCT Engineering
---

# Cube spinning 180° about z-parallel axis

Computer Graphics · Chapter 4: Three-Dimensional Graphics

- Asked in: 2066 Magh (old course)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/cube-spin-180-z-axis
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-4

## Question

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.

## 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]].

## Answer

**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

```text
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:

```text
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).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why is the axis taken as x = 1, y = 1?
   A. It passes through the origin
   B. It is parallel to z and passes through the cube centre, keeping the cube in place
   C. It is parallel to the x-axis
   D. It is the cube's diagonal
   Answer: B. The centre of the cube (1,1,1) lies on that axis, so the cube maps onto its own region. (Key point: Axis choice)

2. The matrix is:
   A. T(1,1,0)·Rz(180°)·T(-1,-1,0)
   B. Rz(180°)·T(1,1,0)
   C. T(-1,-1,0)·Rz(180°)·T(1,1,0)
   D. Rx(180°)·T(1,1,0)
   Answer: A. Translate axis to origin, rotate, translate back. (Key point: Composite)

3. The result gives:
   A. x' = -x, y' = -y, z' = z
   B. x' = x, y' = y, z' = -z
   C. x' = 2 - x, y' = 2 - y, z' = z
   D. x' = 2 + x, y' = 2 + y, z' = z
   Answer: C. With cos180° = -1, M has -1 on x and y and 2 in the translation column. (Key point: Final equations)

## Related in Computer Graphics

- [Shear unit cube w.r.t. yz plane](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acube-shear-yz-constant-2) — Computer Graphics, chapter 4, asked 4×
- [Shear cube w.r.t. ZX plane, constant 3](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acube-shear-zx-constant-3) — Computer Graphics, chapter 4, asked 4×
- [Rotate unit cube 90° about axis AB](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acube-rotate-90-axis-a-b) — Computer Graphics, chapter 4, asked 2×
- [Derive parallel projection matrix](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aparallel-projection-matrix-derive) — Computer Graphics, chapter 4, asked 2×
- [Rotate line about Y-axis by 90°](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Arotate-line-y-axis-90) — Computer Graphics, chapter 4
- [3D rotation about axis (1,2,3)-(10,20,30)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Arotate-3d-axis-1-2-3) — Computer Graphics, chapter 4

## Related in other subjects

- [Degree of curve, tangential angle formula](https://www.bctengineer.com/question.md?key=semester_4%2Fsurveying_ii%3Adegree-of-curve-tangential-angle-derivation) — Surveying II, chapter 6
- [Cable on piers: tension, length, pier thrust (180 m)](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Acable-180m-5m-above-60-degree-backstay) — Theory of Structures I, chapter 7, asked 2×
- [Five units of length, area, volume](https://www.bctengineer.com/question.md?key=semester_7%2Festimating_and_costing%3Afive-units-length-area-volume) — Estimating and Costing, chapter 1
- [Curvature where tangent is parallel to x-axis](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Acurvature-y-x2-x-minus-3) — Mathematics I, chapter 1
