3D Transformations
3D Transformations
3D Rotations
- Rotation matrices
- Euler angles
- Three rotations about x-, y- and z-axis
- 3D homogeneous and affine transformations
- Euler angle problems – “gimbal lock”
Recap: 2D Rotation
Homogenous transformation:
(x', y') > (x, y)
is a positive angle along the counter-clockwise direction
3D Coordinate System Conventions
- Positive Z direction for left-handed coordinates.
- Positive Z direction for right-handed coordinates.
- We use right-handed coordinates unless otherwise noted.
3D Rotation Conventions
- Right-hand screw rule:
- Thumb aligns with axis rotated about.
- Other fingers indicate positive rotation.
- For right-handed coordinates.
- 2D Rotation about origin.
- 3D Rotation about an axis or arbitrary line.
- Positive angle along the counter-clockwise direction.
3D Rotations about Z-axis
Find matrix for a positive rotation of about the z-axis.
(x', y') > (x, y)
(x', y', z') > (x, y, z)
The point only moves in the X-Y plane that is orthogonal to Z axis, z value remains the same.
Not homogeneous coordinates (z value is not affected).
3D Rotations – by Swapping Axes
Rotation about Z-axis:
Final look of the rotation matrix about Y axis:
Reordering the Matrix
Step 1: Rearrange the Input Columns
The input vector order changes from:
To achieve this:
- The 1st column of the matrix (corresponding to z) becomes the 3rd column.
- The 2nd column of the matrix (corresponding to x) becomes the 1st column.
- The 3rd column of the matrix (corresponding to y) becomes the 2nd column.
This yields the Intermediate Matrix:
Step 2: Rearrange the Output Rows
The output vector order changes from:
To achieve this:
- The 1st row of the matrix (corresponding to z') becomes the 3rd row.
- The 2nd row of the matrix (corresponding to x') becomes the 1st row.
- The 3rd row of the matrix (corresponding to y') becomes the 2nd row.
This yields the Final Matrix:
Rotation about X-axis:
Hints:
3D Rotation Matrices
Rotation about Y-axis:
Rotation about X-axis:
Rotation about Z-axis:
The rows with “1” preserve the values of related components.
- e.g., z component of a point does not change after the point rotated about z axis
Euler Angles
We need 3 angles to describe the orientation of a rigid body.
Number of possible rotations:
- XXX, XXY, XXZ, XYX, XYY, XYZ, XZX, XZY, XZZ,
- YXX, YXY, YXZ, YYX, YYY, YYZ, YZX, YZY, YZZ,
- ZXX, ZXY, ZXZ, ZYX, ZYY, ZYZ, ZZX, ZZY, ZZZ
Generates an arbitrary rotation matrix (rotation about an arbitrary axis passing through the origin).
Simple idea: use an ordered combination of rotations about the x-, y- and z-axes, e.g. first X, then Y then Z (all variations used).
NB: order matters!
3D Rotation Strangeness
Suitable (ordered) combination of rotations about any two axes can generate any 3D rotation.
Steps to combine the rotations
Represent the rotation as matrices
Rotation Matrix around X-axis () :
Rotation Matrix around Y-axis () :
Define the Rotations
First rotation:
Second rotation:
Combine the Rotations
The combined rotation matrix is:
Compute
Compute
Apply the Combined Rotation
Let's assume the initial point is . After applying , the final point becomes:
For an example point :
Euler Angle Troubles
- Gimbal lock occurs when one axis of rotation lines up with another, losing a degree of freedom.
Gimbal Lock
- The rotation axis of is made to line up with the rotation axis of . We are no longer able to move in the direction that previously enabled us to.
Homogeneous Coordinates in 3D
Add a “1” to the last coordinate to make translation a linear operation (i.e. a matrix multiplication).
Represent T as a matrix.
3D Affine Transformations
Recall 2D:
So in 3D:
12 degrees of freedom
6 degrees of freedom
Affine Transformation in Homogeneous Coordinates
Example: Transformation Decomposition
Given Transformation Matrix
Components:
- Scaling:
- The diagonal elements [2, 3, 4] indicate scaling along the x, y, and z axes, respectively.
- Translation:
- The last column [5, 2, -3] represents a translation by (tx = 5, ty = 2, tz = −3).
- No Rotation or Shearing:
- The off-diagonal elements are all 0, indicating no rotation or shearing.
- Scaling:
Applying to a Point
Given a point :
Compound Transformations
Homogeneous transformations in 3D are just as easily concatenated as in 2D:
Remember that the order of operations matters in general:
Order of Transformations
2D Local/Global Coordinates
- Transformation matrix that combines rotation and translation.
3D Local/Global Coordinates
Coordinate Transformations
- Hand coordinates to arm coordinates:
- Arm coordinates to Wall-e coordinates:
- Wall-e coordinates to world coordinates:
- Hand coordinates to world coordinates:
- Order of Transformations is important. These transformations are in a hierarchy.
- For example, if the hand moves, only the matrix would change because the hand is relative to the arm. The other transformations will remain the same.