Rotation matrices
On this page
Lay a phone flat on a table. Turn it a quarter turn to the left, then lift its far edge until it stands upright. Start again and do the same two moves in the other order: the phone ends facing a different way. A rotation matrix is a small table of numbers that records one turn exactly, so that a machine can apply it to any point and can combine turns in the right order.
See it
A flat part lies on a table. It gets two quarter turns: 90° about the vertical axis Z and 90° about the horizontal axis X. Does it matter which turn is done first?
The dotted outline is where the part started, with corner P at (2, 1, 0). The axes X, Y and Z do not move. The four numbers are cos γ and −sin γ in the first row, sin γ and cos γ in the second. With two turns, the only thing the second button changes is the order.
The idea
Take a point at (x, y) and turn it about the Z axis by the angle γ, counterclockwise. Its new place is found with four numbers, and those four numbers are the rotation matrix of the turn.
y′ = x sin γ + y cos γ
(x, y) is the point before the turn, (x′, y′) after it, γ is the angle of the turn
In space the matrix has three rows and three columns, because a point has three numbers. A turn about Z leaves z as it was and uses the same four numbers for x and y.
A turn changes direction only. Every length and every angle inside the part stays the same, which is how you can test whether a matrix is a true rotation.
To combine two turns, multiply their matrices. The matrix written on the right is applied first: Rx Rz means the Z turn, then the X turn. Only turns about one and the same axis can be swapped.
One worked number
Corner P of a part is at (2, 1, 0). The part turns 30° about the Z axis. Where is P now? Use cos 30° = 0.866 and sin 30° = 0.500.
Show the worked solution, 3 steps
- Find the new x
x′ = 2 × 0.866 − 1 × 0.500 = 1.732 − 0.500 = 1.23.
- Find the new y
y′ = 2 × 0.500 + 1 × 0.866 = 1.000 + 0.866 = 1.87. The turn is about Z, so z stays 0.
- Check the length
Before: √(22 + 12) = 2.24. After: √(1.232 + 1.872) = 2.24. The length did not change, as it must. The figure opens on this case and shows P at (1.23, 1.87, 0.00).
The mistake to avoid
Check yourself
A point is at (2, 1). It turns 90° counterclockwise about the origin. Where is it now? Use cos 90° = 0 and sin 90° = 1.
A program for a robot wrist says: turn 90° about Z, then 90° about X. A technician enters the X turn first, because the two angles are the same. What happens?
A link of a robot arm is 0.5 m long. A rotation matrix turns it by 37° about some axis. How long is the link after the turn?
Where you meet it
- A robot armEach joint adds one turn, and the controller multiplies the matrices in order to know where the tool points.
- A camera gimbal on a droneThe gimbal applies the opposite of the drone's turn, so the camera keeps looking at the ground.
- A solar tracker with two axesThe panel turns about a vertical axis and then tilts. The two angles mean something only in that order.
- A tilt sensor on a machineThe sensor reports gravity in its own axes, and a rotation matrix converts the reading to the axes of the machine.
- A rotation matrix records one turn. For a turn about Z its four numbers are cos γ, −sin γ, sin γ and cos γ.
- A rotation keeps every length and every angle of the part.
- Two turns are combined by multiplying their matrices. The one on the right is applied first.
- In space the order of the turns changes the result.
Discussion
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
My notes on this page
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.