---
title: "3D rotation about arbitrary axis"
subject: "Computer Graphics"
chapter: 4
key: "semester_5/computer_graphics:rotate-3d-arbitrary-axis-steps"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/rotate-3d-arbitrary-axis-steps
site: BCT Engineering
---

# 3D rotation about arbitrary axis

Computer Graphics · Chapter 4: Three-Dimensional Graphics

- Asked in: 2074 Asoj, 10 marks; 2069 Chaitra, 8 marks (asked 2 times)
- Video: [ROTATION ABOUT AN ARBITRARY AXIS IN SPACE in 3D|Computer Graphics](https://www.youtube.com/watch?v=OhgiPknf2mc) — Abhishek Sharma
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/rotate-3d-arbitrary-axis-steps
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-4

## Question

Explain the steps required to rotate an object in 3D about an arbitrary axis (a line which is not parallel to any one coordinate axis).

## Short answer

To rotate about an arbitrary axis, first translate so the axis passes through the origin, rotate it onto the z-axis via Rx(α) then Ry(β), apply the desired rotation Rz(θ), then undo the alignment rotations and translation. The composite matrix is T⁻¹·Rx(−α)·Ry(−β)·Rz(θ)·Ry(β)·Rx(α)·T.

## Answer

Let the axis pass through the points P1(x1, y1, z1) and P2(x2, y2, z2). The idea is to make the axis coincide with a coordinate axis (z), rotate about it, and then undo the first transformations.

Axis vector V = P2 − P1 = (a', b', c'), length L = √(a'² + b'² + c'²). Unit vector u = (a, b, c) = V/L. Let d = √(b² + c²).

**Steps**
1. **Translate** the axis so that P1 is at the origin: T(−x1, −y1, −z1).
2. **Rotate about the x-axis by angle α** to bring the axis into the xz plane, with cosα = c/d and sinα = b/d.

```text
Rx(α) = | 1  0     0    0 |
        | 0  c/d  -b/d  0 |
        | 0  b/d   c/d  0 |
        | 0  0     0    1 |
```

3. **Rotate about the y-axis by angle β** to bring the axis onto the z-axis, with cosβ = d and sinβ = a. The axis must turn clockwise (seen from +y) to reach the z-axis, so the matrix has the clockwise form:

```text
Ry(β) = | d  0 -a  0 |
        | 0  1  0  0 |
        | a  0  d  0 |
        | 0  0  0  1 |
```

4. **Rotate about the z-axis by the required angle θ**: Rz(θ).
5. **Apply the inverse of step 3:** Ry(−β).
6. **Apply the inverse of step 2:** Rx(−α).
7. **Translate back:** T(x1, y1, z1).

**Composite matrix**

M = T(P1) · Rx(−α) · Ry(−β) · Rz(θ) · Ry(β) · Rx(α) · T(−P1)

Each point of the object is multiplied by M: P' = M·P. When d = 0 (the axis is along the x-axis), the Rx step is skipped.

## Check yourself

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

1. What is the first step when rotating about an arbitrary axis through P1?
   A. Rotate about the z-axis by θ
   B. Translate P1 to the origin
   C. Scale the axis to unit length in space
   D. Translate the object to infinity
   Answer: B. The axis must pass through the origin before aligning it with a coordinate axis. (Key point: Idea and step 1)

2. Rotating about the x-axis by α (cosα = c/d, sinα = b/d) accomplishes:
   A. Bringing the axis onto the z-axis
   B. Rotating the object by the required angle
   C. Bringing the axis into the xz plane
   D. Moving the axis to the y-axis
   Answer: C. This removes the y component of the axis, leaving it in the xz plane; then Ry(β) aligns it with z. (Key point: Rotation about x)

3. The composite matrix is:
   A. T(P1)·Rx(-α)·Ry(-β)·Rz(θ)·Ry(β)·Rx(α)·T(-P1)
   B. T(-P1)·Rx(α)·Ry(β)·Rz(θ)·Ry(-β)·Rx(-α)·T(P1)
   C. Rz(θ)·T(P1)·Ry(β)·Rx(α)
   D. Rx(α)·Ry(β)·Rz(θ) only
   Answer: A. Matrices apply right to left: align, rotate by θ about z, then undo the alignment in reverse order. (Key point: Order of composite)

4. When d = 0 (axis along the x-axis):
   A. The rotation is impossible
   B. The Ry step is skipped but Rx is needed
   C. Rz is replaced by a shear
   D. The Rx step is skipped
   Answer: D. With b = c = 0 the axis is already on the x-axis, so the first alignment rotation is unnecessary. (Key point: Special case)

## Related in Computer Graphics

- [3D rotation steps and perspective projection](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Arotate-3d-arbitrary-axis-perspective) — Computer Graphics, chapter 4
- [Rotate object about axis y=4](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Arotate-object-about-y-4) — 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
- [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 world to viewing coordinate matrix](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aworld-to-viewing-3d-matrix) — Computer Graphics, chapter 4, asked 2×
- [3D scaling about arbitrary point](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Ascale-3d-arbitrary-point) — Computer Graphics, chapter 4

## Related in other subjects

- [Parallel axis theorem; centroid of area under y = Kx²](https://www.bctengineer.com/question.md?key=semester_1%2Fapplied_mechanics%3Aparallel-axis-centroid-y-kx2-ashad) — Applied Mechanics, chapter 4
- [Column 35x40 cm, not restrained against rotation](https://www.bctengineer.com/question.md?key=semester_7%2Fdesign_of_rcc_structure%3Acolumn-35x40-cm-not-restrained-against) — Design of RCC Structure, chapter 10
- [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
- [Parallel axis theorem; MOI of trapezoid with cutout](https://www.bctengineer.com/question.md?key=semester_1%2Fapplied_mechanics%3Aparallel-axis-theorem-moi-trapezoid-semicircle) — Applied Mechanics, chapter 4
