Rotation Matrix Instructor
Rotation Matrix Instructor
Rotation Matrix Instructor
Rotation matrices
4.1 Basis orientation
a
A rotation matrix is sometimes called a direction cosine matrix and (i, j = x, y, z)
its elements are called direction cosines.
aRb
A rotation matrix R is an orthogonal matrix which means that bx by bz
the transpose of R is equal to the inverse of R, i.e., R T = R -1 . ax ax · bx ax · by ax · bz
It is convenient to encapsulate the orientation information in a (2)
ay ay · bx ay · by ay · bz
rotation table that can be read either horizontally or vertically.a
az az · bx az · by az · bz
a
If one or both of the bases are non-orthogonal, a rotation matrix (not
a rotation table) stores information because the inverse of a non-orthogonal
bRa
a b -1 T
matrix is not its transpose. = R = aRb (3)
The following rotation matrix R relates two right-handed, orthogonal, unitary bases.
Calculate its inverse by-hand (no calculator) in less than 30 seconds.
0.3830 -0.6634 0.6428 0.3830 0.9237 -0.0058
R = 0.9237 0.2795 -0.2620 -
R =
1 -0.6634 0.2795 0.6941
-0.0058 0.6941 0.7198 0.6428 -0.2620 0.7198
The following rotation table aRb relates right-handed, orthogonal, unit vectors ax , ay , az and bx , by , bz .
Calculate the angle between ax and bz to four (or more) significant digits.
aRb
az
bx by bz bz by
ax 0.9622502 -0.08418598 0.258819 ay
ay 0.1700841 0.9284017 -0.3303661
az -0.2124758 0.3619158 0.9076734
ax bx
◦
(ax , bz ) = 75
ax bx bx ax -1
ay = a b
R by or by = b a
R ay where R
b a
= R
a b
az bz bz az
Copyright
c 1992-2009 by Paul Mitiguy 34 Chapter 4: Rotation matrices
ay
4.4 Example: Using a rotation matrix A
ax
The figure to the right shows a rod B connected to a fixed support A by a revolute az
fixed in A and B, respectively. The bRa rotation matrix is given to the right. θ bx
by
B
This example shows how to use a rotation matrix to express a vector in another
bz
basis and to perform dot-products and cross-products. For example, the bx row
of the bRa rotation table allows bx to be expressed in terms of ax , ay , az as
bRa ax ay az
bx = cos(θ) ax + sin(θ) ay bx cos(θ) sin(θ) 0
by -sin(θ) cos(θ) 0
The ax column of the bRa rotation table expresses ax in terms of bx , by , bz as
bz 0 0 1
ax = cos(θ) bx − sin(θ) by
The dot-product by · ax is simply the element in the by row and ax column of the bRa rotation table, i.e.,
by · ax = -sin(θ)
Copyright
c 1992-2009 by Paul Mitiguy 35 Chapter 4: Rotation matrices
nz
bx
a
Simple rotation matrices can be determined with little more than the definitions of
sine and cosine (SohCahToa).
1
When two sets of basis vectors ax , ay , az and bx , by , bz are initially aligned and then the bases undergoes a simple
rotation about bi = ai by an angle θ, the bRa rotation matrix has a specific pattern. The bi row and ai column contains
cos(θ) ± sin(θ)
only 1 or 0 and the remaining elements have the pattern where the ± sign is plus (+) if the
± sin(θ) cos(θ)
unit vector is “hugged” (e.g, bx is between ax and ay ) or minus (-) when the unit vector is “left out in the cold” (e.g, by is
not between ax and ay ). [Analogy courtesy of Dr. Mandy Koop].
Copyright
c 1992-2009 by Paul Mitiguy 36 Chapter 4: Rotation matrices
4.5.3 Matrix multiplication and bRn
The rotation matrix bRn which relates bx , by , bz with nx , ny , nz is formed R
b n
= R
b a
∗ R
a n
(4)
by matrix multiplication of bRa by aRn as shown to the right.
cos(qB ) sin(qB ) 0 1 0 0 cos(qB ) sin(qB ) cos(qA ) sin(qB ) sin(qA )
b n
R = -sin(qB ) cos(qB ) 0 ∗ 0 cos(qA ) sin(qA ) = -sin(qB ) cos(qB ) cos(qA ) cos(qB ) sin(qA )
0 0 1 0 -sin(qA ) cos(qA ) 0 -sin(qA ) cos(qA )
For example, reading the first row and first column of the rotation table gives
As shown below, the dot product bx · nz is simply the element in the bx row and nz column of the bRn
rotation table (the angle between bx and nz can be calculated via the definition of the dot-product).
Using three vectors (or two vectors and a sense) an angle θ can be calculated with the atan2 function
described in Section 1.6.4 so that -180 ≤ θ ≤ 180◦ . By using wrap, θ may have values -∞ < θ < +∞.
It is worth reiterating that, like distances, angles are inherently positive quantities. Angles may be
regarded as negative when one associates a sense with their value. For example, one may measure a
distance from sea level as 10 m. Alternately, one may say the distance from sea-level is -10 m by implying
that a upward sense is positive. Similarly, angles measurements are inherently positive, but an angle may
be regarded as negative when a sense is associated with the angle (e.g., counter-clockwise is positive).
Historically, angles (e.g., used by the ancient Greeks) predate negative numbers (in widespread use by
Europeans in 1700 A.D.) by thousands of years.
Copyright
c 1992-2009 by Paul Mitiguy 38 Chapter 4: Rotation matrices