Rotations
Rotations are one of the fundamental mathematical tools used to describe the orientation of rigid bodies and reference frames in robotics.
This section introduces the conventions used by Moro for rotation matrices and common orientation representations.
The discussion assumes the notation introduced in Mathematical notation and conventions.
Rotation matrices
The orientation of a reference frame \(\{i\}\) with respect to a reference frame \(\{j\}\) is represented by the rotation matrix
With the conventions used throughout Moro,
where \(\vec{v}^{\,i}\) and \(\vec{v}^{\,j}\) represent the coordinates of the same geometric vector expressed in frames \(\{i\}\) and \(\{j\}\), respectively.
Thus, \(R_i^j\) transforms vector coordinates from frame \(\{i\}\) to frame \(\{j\}\).
Moro uses:
column vectors,
left multiplication by transformation matrices,
right-handed coordinate systems,
positive rotations according to the right-hand rule.
Properties of rotation matrices
A three-dimensional rotation matrix belongs to the special orthogonal group \(SO(3)\):
This means that
and
Consequently,
For the relative orientation between two frames,
and therefore
Geometric interpretation
The columns of \(R_i^j\) correspond to the unit axes of frame \(\{i\}\) expressed in frame \(\{j\}\):
For example, the first column gives the direction of the \(x\) axis of frame \(\{i\}\) expressed using the coordinates of frame \(\{j\}\).
Because the axes of a Cartesian reference frame form an orthonormal basis, the columns and rows of a rotation matrix are mutually orthogonal unit vectors.
Elementary rotations
Moro follows the right-hand rule for positive rotations.
A rotation of angle \(\theta\) about the \(x\) axis is represented by
A rotation about the \(y\) axis is
A rotation about the \(z\) axis is
For example,
This corresponds to a positive \(90^\circ\) rotation according to the right-hand rule.
The functions rotx, roty, rotz, and rot implement these elementary rotations.
Composition of reference-frame orientations
Relative orientations compose according to their reference frames.
For three frames \(\{0\}\), \(\{1\}\), and \(\{2\}\),
and
Substitution gives
and therefore
More generally,
This composition rule is used extensively in the kinematic description of serial manipulators.
Active rotations and coordinate transformations
A rotation matrix can be interpreted in two closely related ways.
Active rotation
In an active interpretation, the coordinate frame remains fixed while the geometric vector itself is rotated:
For example, applying \(R_z(\theta)\) actively rotates a vector by \(\theta\) around the positive \(z\) axis.
Change of representation
In a coordinate-transformation interpretation, the geometric vector remains unchanged while its coordinate representation changes:
Both interpretations use the same matrix algebra. The distinction lies in the geometric meaning assigned to the operation.
Important
When interpreting a rotation matrix, always distinguish between rotating a geometric object and expressing the same object in a different reference frame.
Successive rotations about fixed axes
Consider several rotations applied successively about axes belonging to a fixed reference frame.
Suppose a first rotation \(R_a(\alpha)\) is followed by a rotation \(R_b(\beta)\).
The resulting transformation is
Therefore,
A new rotation about a fixed axis is multiplied on the left.
For example, three successive rotations about the fixed \(x\), \(y\), and \(z\) axes give
With column vectors, the rightmost operation acts first.
Successive rotations about moving axes
Now consider rotations about axes attached to a reference frame that moves after every rotation.
Suppose the first rotation is about the initial \(x\) axis:
A second rotation about the new, already-rotated \(y\) axis is composed on the right:
A third rotation about the new \(z\) axis gives
Therefore, for rotations about moving axes,
The matrices appear in the same order as the intrinsic rotations are performed.
The two composition rules may be summarized as
Intrinsic and extrinsic rotation sequences
A sequence of rotations about moving axes is called an intrinsic sequence.
A sequence of rotations about fixed axes is called an extrinsic sequence.
For an intrinsic sequence \(ABC\) with angles \((\phi,\theta,\psi)\),
where the first, second, and third rotations are performed about successive moving axes.
An equivalent orientation can be obtained using an extrinsic sequence with reversed axis and angle order:
For example,
Note
A sequence name such as XYZ or ZXZ is ambiguous unless it is also specified whether the rotations are intrinsic or extrinsic.
Moro supports both intrinsic and extrinsic interpretations. The public conversion functions use intrinsic=True by default.
Euler angles
Three successive elementary rotations can be used to parameterize an arbitrary three-dimensional orientation.
Moro denotes the three angles of a selected sequence by
where:
\(\phi\) is the first angle of the sequence,
\(\theta\) is the second angle,
\(\psi\) is the third angle.
These symbols are associated with their position in the sequence, not permanently with the \(x\), \(y\), or \(z\) axes.
For example, for an intrinsic ZXZ sequence,
while for an intrinsic YZY sequence,
This convention allows the same notation to be used consistently across different Euler-angle sequences.
Proper Euler angles
Proper Euler sequences use the same axis for the first and third rotations.
There are six possible proper Euler sequences:
In general,
Moro supports these six proper Euler sequences.
For example, for ZXZ,
under Moro’s intrinsic-rotation convention.
Tait–Bryan angles
Tait–Bryan sequences use three different rotation axes.
The six possible sequences are
Their general form is
with
Tait–Bryan sequences are widely used in applications involving concepts such as roll, pitch, and yaw.
However, the terms roll, pitch, and yaw should not be treated as universal synonyms for \(\phi\), \(\theta\), and \(\psi\). Their precise interpretation depends on the selected sequence and on whether the rotations are intrinsic or extrinsic.
Note
Moro 0.5.0 supports all six Tait–Bryan sequences in eul2rot and rot2eul, using the same intrinsic/extrinsic convention as for proper Euler sequences.
Canonical Euler-angle ranges
Euler-angle representations are not unique. In general, several angle triples may represent the same physical orientation.
When extracting Euler angles from a rotation matrix, Moro returns the valid branches associated with the selected sequence. In a nonsingular configuration, two equivalent triples are generally returned; at singular configurations, Moro applies a deterministic convention with the third angle set to zero.
For proper Euler sequences, the canonical ranges are
For Tait–Bryan sequences, the intended canonical convention is
The returned solutions represent the same orientation. Applications that require a single branch should select one explicitly according to their continuity or configuration needs.
Note
A canonical Euler-angle triple is not the unique mathematical representation of an orientation. It is one representative chosen from a family of equivalent angle triples.
Euler-angle singularities
Every three-angle Euler parameterization contains singular configurations in which the first and third rotations cannot be determined independently.
For proper Euler sequences, singularities occur when
or
At these configurations, only a combination of \(\phi\) and \(\psi\) can be determined from the orientation matrix.
Moro resolves this ambiguity by selecting the convention
and computing the remaining angle so that the returned triple still represents the correct orientation.
For Tait–Bryan sequences, singularities occur at
These configurations are commonly associated with the phenomenon known as gimbal lock.
Singularities do not indicate that the physical orientation is invalid. They indicate that the chosen three-angle parameterization loses one degree of representational freedom at those configurations.
Axis–angle representation
An alternative representation of orientation consists of a unit rotation axis
and a rotation angle \(\theta\).
The pair
represents a rotation of \(\theta\) radians about the axis \(\hat{u}\) according to the right-hand rule.
Skew-symmetric matrix
For a vector
the associated skew-symmetric matrix is
It satisfies
Rodrigues’ rotation formula
Given a unit axis \(\hat{u}\) and an angle \(\theta\), the corresponding rotation matrix can be obtained from Rodrigues’ formula:
This expression provides the basis for converting between axis–angle and rotation-matrix representations.
The functions axa2rot and rot2axa provide these conversions in Moro.
Canonical axis–angle representation
Moro uses a canonical axis–angle representation with
Restricting the rotation angle to this interval removes the redundancy associated with the equivalence
For rotations satisfying
the rotation axis is uniquely determined.
Identity rotation
When
the corresponding orientation is
In this case, the rotation axis is geometrically undefined because every unit axis produces the same zero rotation.
To provide a deterministic representation, Moro uses
when converting the identity rotation to axis–angle form.
Therefore,
Note
The choice of the \(x\) axis for the identity rotation is purely conventional. It does not carry geometric information about the rotation.
Rotation by pi
When
the rotation axis is determined only up to sign.
The representations
and
describe the same physical orientation.
Therefore, Moro does not assign geometric significance to the sign of the axis in this case.
Important
When comparing axis–angle representations for rotations of \(\pi\) radians, the axes \(\hat{u}\) and \(-\hat{u}\) must be considered equivalent.
The cases near \(\theta=0\) and \(\theta=\pi\) are handled explicitly by Moro because the general expressions used to recover the rotation axis from a matrix become numerically ill-conditioned near these configurations.
Quaternions
Moro represents orientation quaternions as scalar-first column vectors
For a unit axis \(\hat u\) and angle \(\theta\),
Because \(q\) and \(-q\) represent the same physical orientation, quaternion comparisons should normally be made through the represented rotation rather than by component equality. rot2quat() prefers a representative with nonnegative scalar component whenever that sign can be determined.
The public conversions are:
rot2quat(R)
quat2rot(q)
axa2quat(k, theta)
quat2axa(q)
Quaternion inputs do not need to be normalized in advance; Moro normalizes nonzero quaternions internally.
Rotation vectors
A rotation vector combines axis and angle in one vector:
Its magnitude is the rotation angle,
Moro exposes:
rot2rotvec(R)
rotvec2rot(phi)
rot2rotvec() returns the principal rotation vector with magnitude in \([0,\pi]\), while rotvec2rot() accepts non-principal magnitudes as well.
The exponential-map form used by rotvec2rot() is
At the identity rotation the principal rotation vector is the zero vector.
The vex operator
The inverse vectorization of a skew-symmetric matrix is provided by vex().
For
Moro satisfies
and therefore
vex() validates skew symmetry rather than silently projecting an arbitrary matrix onto the skew-symmetric subspace.
Summary of conventions used by Moro
The rotation conventions used throughout Moro may be summarized as follows:
Convention |
Moro |
|---|---|
Vector representation |
Column vectors |
Matrix action |
Left multiplication |
Coordinate systems |
Right-handed |
Positive rotation |
Right-hand rule |
Relative orientation |
\(R_i^j\) |
Coordinate transformation |
\(\vec v^{\,j}=R_i^j\vec v^{\,i}\) |
Composition |
\(R_k^j=R_i^jR_k^i\) |
Fixed-axis rotation |
New rotation multiplies on the left |
Moving-axis rotation |
New rotation multiplies on the right |
Euler interpretation |
Intrinsic by default; extrinsic supported |
Current Euler sequences |
Proper Euler + Tait–Bryan |
Proper Euler middle-angle range |
\([0,\pi]\) |
Proper Euler first/third range |
\([-\pi,\pi]\) |
Singular Euler convention |
\(\psi=0\) |
Rotation direction |
Right-hand rule |
Axis normalization |
\(|\hat{u}|=1\) |
Angle range |
\(\theta\in[0,\pi]\) |
Positive rotation |
Right-hand rule |
Identity rotation |
\(\theta=0\), \(\hat{u}=[1,0,0]^T\) |
Rotation by \(\pi\) |
\(\hat{u}\) and \(-\hat{u}\) are equivalent |
Matrix construction |
Rodrigues’ rotation formula |
These conventions are used consistently throughout Moro’s kinematics, transformations, and visualization tools.