A rotation matrix, RR, describes the rotation of an object in 3-D space.
It was introduced on the previous two pages covering
deformation gradients and
polar decompositions.
A transformation matrix describes the rotation of a coordinate system while
an object remains fixed. In contrast, a rotation matrix describes the rotation
of an object in a fixed coordinate system. The amazing fact, and often a confusing one,
is that each matrix is the transpose of the other.
This entire page is essentially the transpose of
the transformation matrix page.
The two pages together border on being redundant.
However, there are subtle differences between the two and they
are stressed on this page.
Summary
The rotation matrix, RR, is used in the rotation of vectors
and tensors while the coordinate system remains fixed.
The vector or tensor is usually related to some object that is actually
undergoing the rotation, and the vector and/or tensor is along for the ride.
The general rules for applying the rotation matrix are the same as for
the coordinate transformation matrix.
Vectors
v′v′
==
R⋅vR⋅v
2nd Rank Tensors
σ′
=
R⋅σ⋅RT
4th Rank Tensors
C′
=
R⋅R⋅C⋅RT⋅RT
and in tensor notation...
Vectors
v′i
=
Rijvj
2nd Rank Tensors
σ′mn
=
RmiRnjσij
4th Rank Tensors
C′mnop
=
RmiRnjRokRplCijkl
In two dimensions, R is
R=[cosθ−sinθsinθcosθ]
where θ is the rotation angle. Note that R is just the
transpose of Q, i.e., R=QT and Q=RT.
Rotation Matrix Properties
Rotation matrices have several special properties that, while easily seen in this
discussion of 2-D vectors, are equally applicable to 3-D applications as well.
This list is useful for checking the accuracy of a rotation matrix if questions
arise. While a matrix still could be wrong even if it passes all these checks,
it is definitely wrong if it fails even one!
The determinant of R equals one.
The inverse of R is its transpose (this is discussed at the bottom of this page).
The dot product of any row or column with itself equals one.
Ex: (cosθi+sinθj)⋅(cosθi+sinθj)=1
The dot product of any row with any other row equals zero.
Ex: (cosθi+sinθj)⋅(−sinθi+cosθj)=0
The dot product of any column with any other column equals zero.
Ex: (cosθi−sinθj)⋅(sinθi+cosθj)=0
Multiplication of Rotation Matrices
Recall from above that the dot product of any two different rows or columns of
a rotation matrix is zero, while the dot product of any row or column
with itself is one. This can be written in matrix and tensor notation as
R⋅RT=IandRikRjk=δij
This shows that the transpose of a rotation matrix is also
its inverse.
Rotating the Potato...
Recall that the vector on the potato was
v=2ˆi+9ˆj
and the 50° counter-clockwise rotation of the coordinate system yielded
v′=8.18ˆi′+4.25ˆj′
In contrast, rotating the potato itself 50° counter clockwise gives
{v′xv′y}=[cos50∘−sin50∘sin50∘cos50∘]{29}⟶{−5.6097.317}
So the rotated vector is
v′=−5.609ˆi+7.317ˆj
Note that the apostrophe is on v′ to signify that
it is somehow different from the reference v vector
(rotated in this case), but it is not on i and
j because they are still in the reference
coordinate system.
Comparing Rotations to Transformations
The previous example rotated the potato and vector 50° counter-clockwise.
This example will instead rotate the coordinate system 50° clockwise,
so θ will be -50° this time.
{v′xv′y}=[cos(-50∘)sin(-50∘)−sin(-50∘)cos(-50∘)]{29}⟶{−5.6097.317}
So the vector can be written as
v′=−5.609ˆi′+7.317ˆj′
in the rotated coordinate system. The important point to be made here
is that the numerical values of the rotated vector in the 1st example
and the vector in the oppositely-rotated coordinate system of this
example, are the same.
The general definition of R, in 3-D, is
R=[cos(x′,x)cos(y′,x)cos(z′,x)cos(x′,y)cos(y′,y)cos(z′,y)cos(x′,z)cos(y′,z)cos(z′,z)]
where (x′,x) represents the angle between the x′ and x axes,
(x′,y) is the angle between the x′ and y axes, etc. Yes, this
is indeed the transpose of Q.
3-D Reduction to 2-D
So a rotation about the z-axis means that cos(z′,z)=1 because
the angle between z′ and z remains 0°. Meanwhile,
cos(x′,z)=cos(y′,z)=cos(z′,x)=cos(z′,y)=0 because the
angles between these axes remains 90°.
The angle between y′ and x is (90∘+θ), and
cos(y′,x)=cos(90∘+θ)=−sinθ.
Likewise, the angle between x′ and y is (90∘−θ), and
cos(x′,y)=cos(90∘−θ)=sinθ.
All of this leads to
R=[cosθ−sinθ0sinθcosθ0001]
which reveals the 2-D rotation matrix within the 3-D matrix.
An alternative way of interpreting and generating the rotation matrix is as follows.
R=[(x-compof i′)(x-compof j′)(x-compof k′)(y-compof i′)(y-compof j′)(y-compof k′)(z-compof i′)(z-compof j′)(z-compof k′)]
where "x-comp of i′" means the x-component of the i′ unit vector.
Pay close attention here to which terms have primes on them and which don't.
Don't confuse this with "the x'-component" because "the x'-comp of i′"
is simply 1. Yet another way to say this is, "the first component of the i′
unit vector in the non-primed reference x,y,z coordinate system."
Once again, this is just the transpose of the Q matrix.
Successive Rotations - Roe Convention
The 3-D rotation matrix can be viewed as a series of three successive
rotations about coordinate axes. There must be dozens of variations of this
since any combination of axes can be chosen in any order to rotate about.
One popular choice is the so-called Roe convention.
As shown in the figure,
it consists of (i) a rotation through angle ψ about the z-axis, then
(ii) a rotation of angle θ
about the new y-axis (which has already rotated itself due to the first rotation
about z), and finally, (iii) a second rotation of ϕ about the now-tilted
z-axis.
The Roe convention is very popular despite one key challenge it contains. That
is... if θ=0, then ψ and ϕ become indistinguishable
and only the sum of the two is what matters.
R=[cosψ−sinψ0sinψcosψ0001][cosθ0sinθ010−sinθ0cosθ][cosϕ−sinϕ0sinϕcosϕ0001]=[cosψcosθcosϕ−sinψsinϕ−cosψcosθsinϕ−sinψcosϕcosψsinθsinψcosθcosϕ+cosψsinϕ−sinψcosθsinϕ+cosψcosϕsinψsinθ−sinθcosϕsinθsinϕcosθ]
This time, the rotation matrices are indeed written in the same order: ψ,θ,ϕ.
Roe Angles Example
In the figure above, ψ=60∘,θ=30∘, and ϕ=45∘.
These Roe angles give a coordinate transformation matrix equal to
Going In Reverse - Determining Roe Angles from a Rotation Matrix
Suppose you have a rotation matrix populated with values as shown here
and would like to know what Roe transformation angles were responsible
for producing the matrix.
R=[R11R12R13R21R22R23R31R32R33]
The first and easiest step is to look at the R33 component. It is simply the cosine of θ,
so θ=Cos−1(R33).
The second step is to determine ψ as follows
R23R13=sinψsinθcosψsinθ=sinψcosψ=tanψ
So
ψ=Tan−1(R23R13)
The same process leads to
ϕ=Tan−1(R32−R31)
So in summary
ψ=Tan−1(R23R13)θ=Cos−1(R33)ϕ=Tan−1(R32−R31) UNLESS!!!.......θ proves to be very small!
In this case, sinθ will be very small and therefore, so will
R31,R32,R13, and R23 because all these terms contain sinθ.
This can lead to major round-off errors in any such calculations.
Fortunately, the solution for this (θ→0) is to recall that ψ and
ϕ become indistinguishable from each other. This permits ϕ to be set to zero, and
ψ to be computed according to ψ=Sin−1(R21).
Example: Roe Angles from Matrix
Let's start with the matrix in the previous example and work backwards.
R=[−0.3062−0.91860.25000.8839−0.17680.4330−0.35360.35360.8660]
Start with the R33 term to determine θ.
θ=Cos−1(R33)=Cos−1(0.8660)=30∘
Since θ is not near zero, ψ and ϕ can be computed as follows.
ψ=Tan−1(R23R13)=Tan−1(0.43300.2500)=60∘ ϕ=Tan−1(R32−R31)=Tan−1(0.35360.3536)=45∘
So as expected, the original values are recovered: ψ=60∘,θ=30∘,
and ϕ=45∘.
Rotation About An Axis
Yet another way of specifying the rotation matrix is through
a rotation axis vector, p, and a rotation angle, α, about
the p axis.
In this case, the rotation matrix is written as
R=cosαI+(1−cosα)p⊗p−sinαP
with
P=[0p3−p2−p30p1p2−p10]
Writing the matrix out gives
R=[cosα+(1−cosα)p21(1−cosα)p1p2−sinαp3(1−cosα)p1p3+sinαp2(1−cosα)p2p1+sinαp3cosα+(1−cosα)p22(1−cosα)p2p3−sinαp1(1−cosα)p3p1−sinαp2(1−cosα)p3p2+sinαp1cosα+(1−cosα)p23]
As usual, this can be written quite concisely in tensor notation
Rij=cosαδij+(1−cosα)pipj−sinαϵijkpk
Note the similarity to the tensor equation of Q. The only difference is the + or -
in front of sinα.
Qij=cosαδij+(1−cosα)pipj+sinαϵijkpk
It is very important to recognize that p is a unit vector. Using any
other length will lead to incorrect results.
Also, it's actually more common to use
θ or ϕ as the rotation angle instead of α. But
α is being used here to minimize confusion with
ψ,θ, and ϕ used as the Roe convention angles.
It is easy to visualize the coordinate rotations in this method. For example,
the 2-D case can be reproduced by noting that the rotation is about the z-axis,
so the vector is p=(0,0,1). This leads to
R=[cosα−sinα0sinαcosα0001]
As with the Roe angles, it is possible to back-out p and α given
a rotation matrix, R. The first step is to determine α.
This is done by taking the trace of the matrix.
α=Cos−1{12[tr(R)−1]}
Once α is determined, the components of p are computed by
p1=R32−R232sinαp2=R13−R312sinαp3=R21−R122sinα
The three equations can be conveniently summarized in tensor notation as
pi=−ϵijkRjk2sinα
Note that p becomes undefined when α=0. This means, "the axis
you rotate about doesn't matter if you don't rotate in the first place."
Backing Out P and α
Determine the single rotation, p and α, that is equivalent to
that produced by the Roe angles used earlier: ψ=60∘,θ=30∘,
and ϕ=45∘.
Recall that the Roe angles ψ=60∘,θ=30∘,
and ϕ=45∘ lead to
R=[−0.3062−0.91860.25000.8839−0.17680.4330−0.35360.35360.8660]
Solving for α gives
α=Cos−1{12[−0.3062−0.1768+0.8660−1]}=108∘
Solving for p gives
p1=0.3536−0.43302sin108∘=−0.0417 p2=0.2500−(−0.3536)2sin108∘=0.3173 p3=0.8839−(−0.9186)2sin108∘=0.9475
So the Roe angles ψ=60∘,θ=30∘,
and ϕ=45∘ are equivalent to a single rotation of
108∘ about the axis given by
p=(−0.0417, 0.3173, 0.9475).
Both sets lead to the same rotation of an object.
The above example closes the loop on converting rotations from one system, Roe,
to a second system, about an axis. In this case, and any other, the
transformation matrix R is the go-between permitting the conversion.
The procedure is always to calculate the R matrix in the first system
and then back-out the angles in the second system from R.
Inverses and Transposes
All rotation matrices possess a rather remarkable
property - their transpose is their inverse. So it becomes trivial
to compute the inverse of such a matrix.
RT=R−1soRT⋅R=I
Dot Product Example
The above R matrix is
R=[−0.3062−0.91860.25000.8839−0.17680.4330−0.35360.35360.8660]
Multiply it by its transpose to demonstrate that the result is the identity matrix
and therefore, its transpose must also be its inverse.