DSTO–TN–0640nθx ′xFigure 4: The matrix R n (θ) rotates x in a right-handed sense around theunit vec<strong>to</strong>r n by an angle θ <strong>to</strong> produce x ′ . That is, x ′ = R n (θ) xwhere n can point in either direction along the axis, but changing the choice of that directionwill change the sign required for the rotation angle θ, since the rotation matrix R n (θ)obeys the right hand rule for rotation. The rotation matrix can be written in the followingway, which is the main equation of this report:⎡⎤⎡⎤n 2 1 n 1 n 2 n 1 n 3R n (θ) = (1 − cos θ) ⎣n 2 n 1 n 2 2 n 2 n 3⎦ + cos θ I 3 + sinθ ⎣n 3 n 1 n 3 n 2 n 2 30 −n 3 n 2n 3 0 −n 1⎦−n 2 n 1 0= (1 − cos θ) nn t + cos θ I 3 + sin θ n × , (3.7)where n t is the transpose of n, I 3 is the 3 × 3 identity matrix, and⎡⎤0 −n 3 n 2n × ≡ ⎣ n 3 0 −n 1⎦ , (3.8)−n 2 n 1 0so-named becausen × x = n × x, (3.9)(with the n written nonbold <strong>to</strong> emphasise its matrix form). The rotation matrix R n (θ)is called orthogonal, by which is meant RR t = R t R = 1, and as well its determinant isalways 1. Equation (3.7) will be used repeatedly in this report <strong>to</strong> break more complicatedprocedures up in<strong>to</strong> single rotations that are easy <strong>to</strong> visualise and easy <strong>to</strong> code. It is, infact, the central equation of the whole of rotation theory.Example of the use of (3.7): Rotate the vec<strong>to</strong>r (2, 0, 0) by 90 ◦ about the y-axis.What vec<strong>to</strong>r results? The required rotation matrix is R y (90 ◦ ) (where by the subscript yis meant n = (0, 1, 0) t ). Equation (3.7) gives it as⎡ ⎤ ⎡ ⎤ ⎡ ⎤0R y (90 ◦ ) = nn t + n × = ⎣1⎦ [ 0 1 0 ] + ⎣00 0 10 0 0⎦ = ⎣−1 0 00 0 10 1 0⎦ . (3.10)−1 0 0(Actually, in this simple example we can calculate R y (90 ◦ ) alternatively using (3.2). Simplynote that the basis vec<strong>to</strong>rs rotate as⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤1 0 0 0 0 1⎣0⎦ −→ ⎣ 0⎦ , ⎣1⎦ −→ ⎣1⎦ , ⎣0⎦ −→ ⎣0⎦ , (3.11)0 −1 0 0 1 08
DSTO–TN–0640so that (3.2) yields R y (90 ◦ ) trivially.) The required rotated vec<strong>to</strong>r is thenas expected.⎡ ⎤ ⎡ ⎤⎡⎤ ⎡ ⎤2 0 0 1 2 0R y (90 ◦ ) ⎣0⎦ = ⎣ 0 1 0⎦⎣0⎦ = ⎣ 0⎦ , (3.12)0 −1 0 0 0 −2An example of combining two rotations is given in Appendix A. As stated by Euler’stheorem, the effect of these is just one rotation, although the values of the resultingequivalent axis and angle turned through are not obvious at all from the original two axesand angles.The rows of a rotation matrix will gradually lose their mutual orthonormality becauseof rounding errors under repeated iterations in a computer programme. This wanderingcan be kept in check by periodically re-orthogonalising, accomplished byR → R ( R t R ) −1/2 . (3.13)Rotation Order and its Possible Blind ApplicationSince matrix multiplication is not commutative, two rotations are also not in general commutative:the result depends on the order in which they are done. However, infinitesimalrotations are commutative. This fact can be used <strong>to</strong> our advantage when writing computercode that takes inputs from a joystick, in order <strong>to</strong> rotate a scene (say, in a flightsimula<strong>to</strong>r). The pilot might induce both a pitch and a roll, but only by applying each ofthese in tiny increments will the software successfully reproduce the effect that the pilotwants.Nevertheless, it’s possible <strong>to</strong> go <strong>to</strong> an extreme of demanding a set rotation order thatdoes not mimic what the user of a software package wants, but that does do somethinghighly misleading. In fact, a search through the internet shows that this mistake seems <strong>to</strong>be a classic of computer graphics programming, and has caused some in that community <strong>to</strong>distrust the mathematics of rotation. An example of this incorrect application of rotationsis discussed in Appendix C.3.4 Rotating using QuaternionsAlthough the rotation matrix R n (θ) has nine entries, it’s really only built from three numbers:the angle θ turned through, and any two components of n; the third component of nis then implied, since n has unit length. <strong>Using</strong> R n (θ) can be computationally inefficient,since not only do all nine components need <strong>to</strong> be manipulated, but if the matrix is appliedwithin a loop, perhaps thousands of times, numerical inaccuracies can degrade itsorthogonality. That is, its rows (or equivalently columns) will slowly lose their mutualorthonormality. It can certainly be periodically re-orthogonalised after an appropriatenumber of iterations, as shown in (3.13). Nevertheless, the question arises as <strong>to</strong> whetherany way exists of rendering the matrix down <strong>to</strong> its basic three numbers, and perhapseliminating some of the numerical complexity in the process.9