Rotation matrices, Euler angles, and gimbal lock
Elementary rotations
Section titled “Elementary rotations”The fundamental rotations along the three axes are expressed by the following matrices:
Rotation for an angle about the -axis:
Rotation for an angle about the -axis:
Rotation for an angle about the -axis:
Practically, inverting a rotation means applying another rotation with the inverse of the angle. So we derive that .
Rotation of a vector
Section titled “Rotation of a vector”When staying in a fixed coordinate system, we can use transformation matrices to apply rotations to a vector.
The distance of the vector from the center remains constant:
Fixed vs current frame rotations
Section titled “Fixed vs current frame rotations”When applying rotations, we must distinguish between fixed frames and current frames. In fixed frames we apply the rotation staying in the original frame; in current frames we rotate by referring to the new frame after each rotation.
Composition of rotation matrices
Section titled “Composition of rotation matrices”A rotation can be expressed as a sequence of partial rotations, each one defined with respect to the previous one. All rotations are defined with respect to the current frame, but there’s an important distinction to keep in mind when applying them.
- When applying a rotation from the current frame, the sequence of rotations is obtained by post-multiplying the matrices associated with each rotation.
- Instead, when applying the rotation from the fixed frame, the matrix of the later operation must be pre-multiplied to the matrices of the earlier rotations.
Let’s say we have two rotations: around the axis followed by for angle , which happens around (not the of the current frame).
We know how to do rotations in the current axis, so we can translate the fixed axis rotation to:
which leads to:
Parametrisation of rotation matrices
Section titled “Parametrisation of rotation matrices”A 3D rotation matrix has 9 elements, but a rotation can be completely specified by three parameters (an element of can be specified by parameters).
Euler angles
Section titled “Euler angles”A popular convention is the use of , , rotations about fixed axes (known in aeronautics as roll-pitch-yaw or RPY).
Since the rotation is about fixed axes we have to pre-multiply:
Let’s introduce the notation and .
We see that:
Given a matrix , the inverse operation (finding the three angles) has two solutions:
Gimbal lock
Section titled “Gimbal lock”In Euler-based parametrisations, the three angles act as three independent degrees of freedom.
At a pitch angle of , the roll and yaw rotation axes become aligned, resulting in the loss of a degree of freedom. This means that a rotation around one axis can be replicated by a rotation around the other.
The real problem surfaces when we try to calculate the inverse, to find the angles of the rotation. We can verify that in a gimbal lock situation, there are infinitely many combinations of and that produce the same rotation matrix.