Spatial descriptions: rotation matrices and homogeneous transforms
Frames, rotation matrices and their properties, composition rules, and 4x4 homogeneous transforms with chaining and inversion.
Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Every robot calculation — where the tool is, where the camera sees a part, how to reach a fixture — needs a precise way to say where one frame is relative to another. Rotation matrices and 4 × 4 homogeneous transforms are that language; forward kinematics, inverse kinematics, the Jacobian and vision calibration are all built on them.
Key ideas
Frames. A frame {B} is an origin plus three mutually perpendicular unit axes x̂_B, ŷ_B, ẑ_B (right-handed). A position vector is always written in some frame: ᴬp means "p expressed in {A}".
Rotation matrix. ᴬR_B is the 3 × 3 matrix whose columns are the unit axes of {B} written in {A}: ᴬR_B = [ᴬx̂_B ᴬŷ_B ᴬẑ_B]. It does two jobs:
- describes the orientation of {B} relative to {A};
- maps a vector: ᴬv = ᴬR_B · ᴮv.
Properties: columns (and rows) are orthonormal, so Rᵀ·R = I, R⁻¹ = Rᵀ, det R = +1. It preserves lengths and angles. Only 3 of its 9 numbers are independent. A matrix with det = −1 is a reflection, not a rotation.
Elementary rotations about x, y, z by angle θ are given below (counter-clockwise positive when looking down the axis towards the origin — right-hand rule).
Composing rotations. Order matters: rotations do not commute.
- Rotations about the current (moving) axes → post-multiply: R = R₁·R₂.
- Rotations about the fixed (original) axes → pre-multiply: R = R₂·R₁. Example: Z-Y-X Euler angles (yaw-pitch-roll about moving axes) give R = R_z(α)·R_y(β)·R_x(γ), which equals X-Y-Z about fixed axes (roll, pitch, yaw).
Other orientation descriptions. Euler angles (3 numbers, but singular when the middle angle makes two axes line up — "gimbal lock"), axis-angle, and unit quaternions (4 numbers, no singularity, used in ROS and controllers). The rotation matrix itself has no singularity.
Homogeneous transform. Position and orientation together:
ᴬT_B = [ ᴬR_B ᴬp_B ; 0 0 0 1 ], where ᴬp_B is the origin of {B} in {A}.
A point transforms as ᴬp = ᴬR_B·ᴮp + ᴬp_B, written compactly with 4-vectors [x y z 1]ᵀ as ᴬp = ᴬT_B·ᴮp. Transforms chain: ᴬT_C = ᴬT_B·ᴮT_C — the "cancelling" sub/superscripts are a quick check. The inverse is cheap (no general 4 × 4 inversion needed).
Free vectors (velocities, forces, directions) have a 0 as the fourth element, so translation does not affect them.
Formulas
R_x(θ) = [[1, 0, 0], [0, cos θ, −sin θ], [0, sin θ, cos θ]]
R_y(θ) = [[cos θ, 0, sin θ], [0, 1, 0], [−sin θ, 0, cos θ]]
R_z(θ) = [[cos θ, −sin θ, 0], [sin θ, cos θ, 0], [0, 0, 1]]
- θ — rotation angle (rad or degrees), positive by the right-hand rule about the named axis.
R⁻¹ = Rᵀ, det R = +1
ᴬp = ᴬR_B · ᴮp + ᴬp_B
- ᴬp, ᴮp — the same point in frames {A} and {B} (m); ᴬp_B — origin of {B} in {A} (m).
ᴬT_B = [[ᴬR_B, ᴬp_B], [0 0 0, 1]] (4 × 4)
ᴬT_C = ᴬT_B · ᴮT_C
ᴮT_A = (ᴬT_B)⁻¹ = [[ᴬR_Bᵀ, −ᴬR_Bᵀ · ᴬp_B], [0 0 0, 1]]
Rotation angle from R: cos φ = (r₁₁ + r₂₂ + r₃₃ − 1) / 2 (equivalent axis-angle)
Worked examples
Example 1 (standard). Frame {B} is rotated 90° about z_A and its origin is at (5, 0, 0) m in {A}. A point has ᴮp = (2, 1, 0) m. Find ᴬp.
- ᴬR_B = R_z(90°) = [[0, −1, 0], [1, 0, 0], [0, 0, 1]].
- ᴬR_B·ᴮp = (0·2 − 1·1 + 0, 1·2 + 0 + 0, 0) = (−1, 2, 0) m.
- ᴬp = (−1, 2, 0) + (5, 0, 0) = (4, 2, 0) m.
Answer: ᴬp = (4, 2, 0) m.
Example 2 (GATE level). With ᴬT_B as in Example 1, frame {C} is rotated 90° about x_B with its origin at (0, 2, 0) m in {B}. Find (a) ᴬT_C, (b) the origin of {C} in {A}, (c) the origin of {A} expressed in {B}.
- ᴮT_C: R = R_x(90°) = [[1, 0, 0], [0, 0, −1], [0, 1, 0]], p = (0, 2, 0).
- ᴬR_C = R_z(90°)·R_x(90°) = [[0, 0, 1], [1, 0, 0], [0, 1, 0]] (check: det = +1).
- ᴬp_C = ᴬR_B·(0, 2, 0) + (5, 0, 0) = (−2, 0, 0) + (5, 0, 0) = (3, 0, 0) m.
- So ᴬT_C = [[0, 0, 1, 3], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]].
- (c) ᴮp_A = −ᴬR_Bᵀ·ᴬp_B. ᴬR_Bᵀ = [[0, 1, 0], [−1, 0, 0], [0, 0, 1]]; ᴬR_Bᵀ·(5, 0, 0) = (0, −5, 0); negate → (0, 5, 0) m.
Answer: (a) as above, (b) (3, 0, 0) m, (c) (0, 5, 0) m.
Example 3 (order matters). The unit vector x̂ = (1, 0, 0) is rotated 90° about the fixed y-axis and then 90° about the fixed z-axis. Pre-multiply: R_z(90°)·R_y(90°)·x̂. R_y(90°)·x̂ = (0, 0, −1); R_z leaves a z-vector unchanged → (0, 0, −1), i.e. along −z. Doing the same rotations about the moving axes (post-multiply) gives R_y(90°)·R_z(90°)·x̂ = (0, 1, 0) — a different answer.
Common mistakes
- Putting the axes of {B} in the rows instead of the columns of ᴬR_B.
- Sign of sin θ in R_y: the minus sign is in the bottom-left, unlike R_x and R_z.
- Inverting T by inverting R and negating p separately: the translation of the inverse is −Rᵀ·p, not −p.
- Mixing fixed-axis and moving-axis rules (pre- vs post-multiplication).
- Applying translation to direction vectors — use a 0 in the fourth slot.
- Using degrees in one place and radians in another inside a calculator.
For GATE ME
Expect short numericals: transform a point between frames, compose two transforms, find the inverse, or check whether a given matrix is a valid rotation (orthonormal, det = +1). Conceptual MCQs test properties of R and the effect of rotation order. Practise multiplying 3 × 3 matrices quickly and checking results with det R = 1 and unit-length columns.
Quick check
- What is the inverse of a rotation matrix?
- Rotate the point (1, 0, 0) by 90° about z. Result?
- In ᴬT_B, what does the fourth column (top three entries) represent?
- Is [[1, 0, 0], [0, 1, 0], [0, 0, −1]] a rotation matrix?
- For rotations about moving axes, do you pre- or post-multiply?
Answers: 1. Its transpose; 2. (0, 1, 0); 3. The origin of {B} expressed in {A}; 4. No — det = −1, it is a reflection; 5. Post-multiply.
Interview questions
All Robotics interview questionsTry answering each one aloud before you open it.
1.What is a rotation matrix, and how is it used in robotics?Concept
A rotation matrix is a mathematical representation used to describe the rotation of an object in space. In robotics, it is used to transform the coordinates of a point or vector from one coordinate frame to another, maintaining the object's orientation. Rotation matrices are orthogonal and have a determinant of 1, ensuring that they preserve the length and angles of vectors.
2.Explain what a homogeneous transformation matrix is and its significance in robotics.Concept
A homogeneous transformation matrix is a 4x4 matrix used to represent both rotation and translation in a single matrix operation. In robotics, it is significant because it allows for the transformation of points between different coordinate frames, combining both rotational and translational movements. This is crucial for tasks like robotic arm manipulation, where both position and orientation need to be controlled.
3.Why are rotation matrices preferred over Euler angles in certain robotic applications?Application
Rotation matrices are preferred over Euler angles in certain applications because they avoid the problem of gimbal lock, which can occur with Euler angles. Gimbal lock is a situation where the loss of one degree of freedom occurs, leading to a singularity. Rotation matrices provide a more stable and continuous representation of orientation, which is essential for precise control in robotics.
4.What happens if a rotation matrix is not orthogonal? How does it affect robotic operations?Application
If a rotation matrix is not orthogonal, it means that it does not preserve the length and angles of vectors, leading to distortions in the transformed coordinates. In robotic operations, this can result in incorrect positioning and orientation of robotic components, potentially causing errors in tasks such as assembly or navigation.
5.How can you verify if a given matrix is a valid rotation matrix?Concept
To verify if a given matrix is a valid rotation matrix, check two main properties: orthogonality and determinant. The matrix should be orthogonal, meaning its transpose is equal to its inverse. Additionally, the determinant of the matrix should be 1. These properties ensure that the matrix preserves vector lengths and angles.
6.Explain the role of homogeneous transformation matrices in robotic kinematics.Concept
In robotic kinematics, homogeneous transformation matrices are used to describe the position and orientation of robotic links relative to each other. They allow for the calculation of forward kinematics, determining the end-effector's position and orientation based on joint parameters. This is essential for controlling the robot's movement and ensuring it performs tasks accurately.
7.What is the impact of numerical errors in rotation matrices on robotic systems?Application
When many rotation matrices are multiplied or integrated over time, round-off makes the result drift away from orthonormality, so it no longer preserves lengths and angles and det R departs from 1. The computed tool pose is then slightly skewed and the error grows with each update. Controllers and estimators fix this by periodically re-orthonormalising R (Gram-Schmidt or SVD) or by working with unit quaternions and renormalising them.
8.Calculate the resulting coordinates of a point (2, 3, 4) after a 90-degree rotation about the Z-axis using a rotation matrix.Numerical
To perform a 90-degree rotation about the Z-axis, use the rotation matrix: Rz = [[0, -1, 0], [1, 0, 0], [0, 0, 1]]. Multiply this matrix by the point's coordinates: [0, -1, 0] * [2] + [1, 0, 0] * [3] + [0, 0, 1] * [4] = [-3, 2, 4]. Thus, the resulting coordinates are (-3, 2, 4).
9.Given a homogeneous transformation matrix, how would you extract the rotation and translation components?Concept
In a homogeneous transformation matrix, the upper-left 3x3 submatrix represents the rotation component, while the first three elements of the fourth column represent the translation component. By isolating these parts, you can determine the orientation and position of the object in space.
10.If a robot's end-effector needs to move from pose A to pose B, how would you use homogeneous transformation matrices to describe the motion?Application
Express both poses in the base frame as 4×4 transforms, ⁰T_A and ⁰T_B. The relative motion expressed in the tool's current frame is ᴬT_B = (⁰T_A)⁻¹·⁰T_B, where the inverse uses Rᵀ and −Rᵀp rather than a general matrix inverse. Its rotation part gives the reorientation (convertible to axis-angle for interpolation) and its translation part gives the displacement. Inverse kinematics on ⁰T_B then gives the joint angles for the goal pose.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?