<<

Properly establishing the relation between linear algebra and geometry makes it easier to obtain the three-by-three that describes a specified .

A Note on Rotation Matrices

Jay P. Fillmore University of California at San Diego

The connection between three-by-three orthogonal The rows of an orthogonal matrix A are iA, jA, kA, the matrices and the rotations of space that they describe is images of the axis vectors i = [1,0,0], etc., and these rows quite misleading when trying to describe a rotation of are orthonormal vectors, since AA T = L From AA T = I space by angles of rotation about the three coordinate we have A T = A - I and A TA = I, so the columns of A are axes. If the relation between the linear algebra and the orthonormal also. geometry is properly established, not only do obscurities The determinant of an orthogonal matrix A is + 1 or vanish but less computation is required to obtain the - 1, since AA T = I gives (det A)2 = 1. The rotation is matrix describing a specified rotation. called proper or improper (or occasionally direct or op- This article will describe all three-by-three orthogonal posite), as det A is + 1 or - 1. Proper rotations, usually matrices, what they do geometrically, and how to obtain called simply rotations, are the most useful. Let's discuss directly a matrix having prescribed geometric properties. these first. The arguments leading to the formulas are included for completeness, but the goals are the statements that con- nect these formulas with the geometry. Proper rotations-matrix known The characteristic polynomial of a three-by-three matrix Rotations A is det (XI-A) = X 3 - (trA)X 2 + .. ._det A This discussion is restricted to rigid motions of space where tr A is the trace of A and the coefficient of X is not that fix at least one point: rotations; a fixed point is chosen needed. When A is proper orthogonal, det A = + 1, and to be the origin. Such a rigid is then given by a this polynomial has at least one positive real root X >0. three-by-three matrix A: The row vector x is sent to xA. If f is an eigenvector accompanying X, LA =X, and Since angles are preserved, (xA) (yA) T always equals (eA ) A ) T = (Xf) (Xf) T equals gfT, so X2 =1. Thus, Xy T, where T denotes transpose, so xAA TyT=xyT. That X= + 1 and LA =Q. L is the axis of rotation of A; A is, AA T = I iS the identity; A is an orthogonal matrix. represents a rigid motion of space about a line through the Conversely, orthogonal matrices yield rotations. origin in the direction of e.

30 0272-1716/84/0200-0030$01.00 (C) 1984 IEEE IEEE CG&A

Authorized licensed use limited to: IEEE Xplore. Downloaded on January 8, 2009 at 09:23 from IEEE Xplore. Restrictions apply. The angle 0 of the rotation is the angle through which Proper rotations-axis and angle known any vector in the plane through the origin and perpen- dicular to ( is moved. We can change the length of ( to A proper rotation of space is determined by its axis and length 1 and choose e andforthogonal to (so that e, f, f is angle. The problem, opposite that of the last section, is to orthonormal and right-handed. Then eA = (cos 6)e + find the proper orthogonal matrix having a prescribed vec- (sin 0)fand similarlyfA. If the rotation is referred to this tor determining the axis of the rotation and rotating by a basis, its matrix is prescribed angle about that axis. A formula for that matrix F can be obtained by elementary methods (Rogers and cos 0 sin 0 01 Adams, and Pavlidis2), but the argument to follow, -sin 0 cos0 0 which uses power series of matrices (Nobel and Daniel3), L 0 1 is chosen because it is simplest and the technique is useful in general. which we denote by R. This means that A = PRP 1, Given the vector e = [a, b, c] along the axis of rotation where P is the change-of-basis matrix; P expresses e, f, and and of length X = -/a2 + b2 + c2 not necessarily 1, in- (in terms of i, j, k-that is, e, f, and (are the rows of P. It troduce the matrix is not necessary to know P to determine the angle 0; for 0 c -b- tr A = tr (PRP- 1) = trR = 1 + 2cos 0. L = -c O a The eigenvalues of a three-by-three matrix A can be b -a O easily found by the following observations. If B is any three-by-three matrix, let Ba be its matrix of cofactors: This matrix represents the linear transformation of cross The ijth entry is (- l)i+j times the two-by-two determi- product with e; that is, xL = -xx(. Indeed, the cross nant obtained by striking thejth row and ith column from product ofx by {is obtained by projecting x onto the plane B. Ba is commonly called the adjoint or adjugate of B. perpendicular to (and rotating through a right angle there. One has BaB = (det B)IL If det B.0, this gives Cramer's The cross product rule (xxf)xm = -x(f-m) (x.m) ewith m rule B - 1 = Ba/det B; and if det B = 0, then BaB = 0 + = fgives xL 2 xX 2 + x( TQfor every shows any row e . 0 of Ba satisfies (B = 0. Eigenvectors ( x, so of A for eigenvalue X, fA = XI?or ((A - I) = 0, are thus a L2 + X2I= QT [ b [a b cI obtained as the rows of (A XXI) a. Especially, ifA is prop- er orthogonal, its axis is obtained as a row of (A - I) a. If X is not a repeated eigenvalue of A, then A - I has rank Aside: The same cross product rule also gives xx ((x m) two and all rows of (A - )J) a are in fact scalar multiples = (xx() xm- (xxm) so of one of them. x(, that the matrix corre- sponding to (x m is the "bracket" ML -LM. Note that eL = 0, so L3 + X2L = (L2 +X2I)L = Formulas: A proper orthogonal matrix A (AA T = I (T(L = 0, and we have and det A = + 1) represents a rotation, of space about a L3 = fixed axis. An eigenvector of A for the eigenvalue 1 is in X2L L6= X4L2 the direction of the axis and is obtained as any row of L4 =- _X2L2 L' = - X6L the matrix of cofactors (A - I) a. The angle 0 of rotation L5 = X4L about this axis is given by tr A = 1 + 2 cos 0. The exponential of a matrix is obtained by replacing x with a matrix in the usual series exp x = 1 + x + x2 /2! + The desired eigenvector can be obtained even more x3 /3! + . .. . Every partial sum is a matrix, and the se- simply as any row of the symmetric matrix (A + A T) quences of entries converge. The argument now proceeds - (tr A - 1). This will be shown later. analogous to that of Euler's formula e t = cos t + The sign of the angle 0 changes when the eigenvector - I sin t by power series of complex numbers. ( is replaced by - (, since this reverses the direction along Using the familiar series for cosine and sine, we have the axis used for the usual right-hand rule. The proper choice of sign for 0 is that of the determinant det (x, xA, f), exp tL = I + tL + 2 LL2 + t3 L3 +t4 L4 where x is any vector not parallel to (. Because, if we make f 2! 3! 4! of length 1, choose e in the plane ofx and (, and choosefso that e, fis orthonormal and as + iL5 + L6 + ... f, right-handed before, then 5! 6! x = ue + w(, and from eA = (cos 0) e + (sin 0)fwe ob- tain det (x, xA, f) = u2 sin 0. = I+ tL + t L2 t X2L t X2L2 Example: One can use these formulas to show that the 2! 3! 4! product of rotations through angles of 10 degrees, 20 t5 * * - degrees, and 30 degrees about the x-, y-, and z- axes respec- + 4L+ t6 X4L2 - tively, done in that order, is the same as a single rotation 5! 6! through an angle of 35.8 degrees about an axis with direc- = I+ (t-X2 t + X4 t . ..)L tion cosines 0.124, 0.616, and 0.778. In general, this prod- 3! 5! uct of rotations about axes through angles ca, 3, and -y is a rotation through an angle 0 given by 1 + 2 cos 0 = + ( _ X2t + 4t_ .)L2 cos cos y + cosy cosa + cos a cos,B + sin a sinf3 sin y. 2! 4! 6! February 1984 31

Authorized licensed use limited to: IEEE Xplore. Downloaded on January 8, 2009 at 09:23 from IEEE Xplore. Restrictions apply. or This symmetric matrix is of rank one, and its rows are scalar multiples of e. The skew-symmetric part of A is a exp tL = I + sin XtL + 1 - cos XtL2 scalar multiple of L. x X 0 1 0 ( = = Aside: If [0,0,1], then L -1 000and)X= 1, Reflections 0 0 0]l i so the formula gives The transformation that reverses a vector ( and fixes 0 1 0 1 0 0 0 1 0 every vector in the plane (through the origin) perpen- exp t -1 0 0 1 0 +(sin t) -1 0 0 dicular to ( is the in that plane. The projection O 0 1 0 0 0 of the (row) vector x on ( has length x(T/l(T, so elemen- [ tary geometry shows that the reflection sends x to x - -1I 0 0 2 (x(T/l(T) e== x (I- 2(eTe/Q¢T) ) andthusislinearand + (I - cos t) O - I 0 described by the matrix A = I - 2 ((Tf/lfT). Using L 2 + L-0 0 0- X2I = fT(of the previous section, we can even write A - (I + 2 (L2/X2)). [0 0 1 0 0 O 1 0 The matrix A of a reflection satisfies A 2 = Iand A T = - L O J + (cos t) O 1 0 + (sin t) 1 0 0 A; so A T = A - 1, and A is orthogonal. With respect to a two perpendicular vectors perpendicu- O 0 1 O ° ° L ° ° basis consisting of lar to f and fitself, the reflection has matrix which is Euler's formula withL 0 1 in the xy plane playing the role of .1 1 0 0 We routinely verify that 0 1 0 0 0-1] * exp tL is an orthogonal matrix, since L T -L; [ * det (exp tL) = + 1, since tr L = 0 and, for any matrix and hence det A - 1. A reflection is an improper A, det (exp A) = etr A (see note below); rotation. * exp tL has (as an eigenvector with eigenvalue 1, since The central theoretical role of reflections will be dis- fL = 0; and cussed later. * tr (exp tL) = 1 + 2 cos Vt, since tr L 2 2X2. Thus, exp tL is the matrix of a proper rotation having axis ( and angle Vt. Improper rotations Formula: The proper orthogonal matrix representing a rotation of space through an angle 0 about an axis in When the three-by-three matrix A is improper or- the direction [a, b, c] is given by thogonal, det A = -1 and the characteristic polynomial I+ sinOL + 1 - cosOL2 det(XI-A) = X3 - (trA) X2 + . . . _detA x X has at least one negative real root X <0. As before, (A where X)gives X2 = 1, s0o = - 1; A has an eigenvector (, which O c -b it reverses. L -c 0 a andX-= N/a2+ b2 + c2 Let B be the reflection in the plane perpendicular to this -a O (. Then AB fixes (and is a proper rotation through an angle Lb 0. Using two vectors perpendicular to (and f as basis, Note that this gives the desired matrix from the axis and (AB)B = A becomes angle given by a, b, c, and 0 with very little computation. This formula (in less modern dress) for the parametric Lcos 0 sinG 0 i1 0 LF cosO sinG 01 specification of rotations about a point dates back to -sin 0 cos 0 O 1 0 = -sinO cosO Euler. 0 0 1 0 IlL 0 0 A consequence of this formula is a simple way to obtain the eigenvector (for eigenvalue 1 of the proper orthogonal Thus A is a rotatory reflection-a rotation about an axis matrix A. This is because A = I + (sin 0/X) L + ((1 - together with a simultaneous reflection in the plane cos 0)/X2) L 2 together with tr A = 1 + 2 cos 0, L2 +X2 I perpendicular to that axis. The angle and axis are obtained = f(T, and the fact that L is skew-symmetric and L2 is by trace and eigenvector of A as before. symmetric, gives Formulas: An improper orthogonal matrix A (AA T A A = 3 tr A (T( (A + T) -(tr 1)I Iland det A = - 1) represents simultaneously a rota- tion about an axis and a reflection in the plane perpen- dicular to that axis. An eigenvector of A for the eigen- This last formula is obvious when the matrix is diagonal and easy if it is up- value - 1 is in the direction of the axis and is obtained as per triangular. In general, A = PJP- I with J upper triangular and P and J possibly complex. Then exp A = P (exp J) P- I, so det (exp A) = det (P any row of the matrix of cofactors (A + I) a. The angle (exp J) P- 1) = det (exp J) = etr J = etr A 0 of the rotation is obtained by tr A I + 2 cos 0.

32 IEEE CG&A

Authorized licensed use limited to: IEEE Xplore. Downloaded on January 8, 2009 at 09:23 from IEEE Xplore. Restrictions apply. Changing a A to -A interchanges proper and improper, changes the sign of the rotation Moving? angle, but does not change the axis. From this we obtain PLEASE NOTIFY US 4 WEEKS IN ADVANCE -I+ sino L _ + cos9 LI, L =[0c O bl x X2 bj a~ ] which is the matrix of a rotatory reflection about an axis in MAIL TO: CHECK ONE: the direction [a, b, cl through the angle 0. IEEE Service Center I] NCGA member 445 Hoes Lane C1 Siggraph subscription Products of reflections Piscataway, NJ 08854 [l IEEE/CS subscription

The product of the two reflections in planes perpen- dicular to (and m is a proper rotation with axis in the direc- tion perpendicular to both e and m and through an angle Name (Please Print) twice that between (and m. This is an easy geometric fact. It can also be argued using matrices by writing the matrices New Address for the reflections as A = - (I + 2 (L2/X2)) and B = - (I + 2 (M2/js2)), recalling that the angle of rotation is found by 1 + 2cos0 = tr(AB), and computing tr(L2M2) City State/Country Zip from (L2 + X21) (M2 + u2I) = (Tb(Tm. Conversely, every proper rotation is the product of two reflections; we simply choose ( and m perpendicular to the axis and * This notice of address change will apply to all IEEE separated by a suitable angle. ATTACH Cemputer Soety publications to which you subscribe. From the argument in the last section, we know that an LABEL * Ust new address above. improper rotation HERE is the product of a reflection and a * It have a proper so you question about your subscription, rotation, three reflections suffice to obtain place label here and clip this form to your letter. improper rotations. Theorem: Every rotation of space (proper or im- proper) is the product ofno more than three reflections. This is a special case of a theorem going back to E. Car- tan. A general formulation can be found in the beautiful but difficult book by Artin. 4 An elementary discussion of ICCDW8 direct and opposite isometries of space that includes translations and their kin appears in Coxeter. 5 The utility of this particular theorem for computer graphics is not the statement but the connection with linear algebra, as discussed here. E References 1. D. F. Rogers and J. A. Adams, Mathematical Elementsfor Computer Graphics, McGraw-Hill, New York, 1976. 2. T. Pavlidis, Algorithmsfor Graphics andImageProcessing, Computer Science Press, Rockville, Md., 1982. 3. B. Noble and J. W. Daniel, Applied Linear Algebra, 2nd Conference papers reflect the industry's dichotomy of views ed., Prentice-Hall, Englewood Cliffs, N.J., 1977. regarding computer design: the desire to integrate design approaches independent of technologies on one hand and the 4. E. Artin, GeometricAlgebra, Interscience Press, New York, 1957. continuing divergence of technologies on the other. 764 pp. 5. H. S. M. Coxeter, Introduction to Geometry, John Wiley & Order #480 Sons, New York, 1969. PROCEEDINGS-Intemational Conference on Jay P. Fillmore is a professor of mathe- Computer Design: VLSI In Computers matics at the University ofCalifornia at San October 31 November 3,1983 Diego, where he has been since 1966. His research interests include and higher sphere geometry. Fillmore Members-S33.00 received his BS and PhD in mathematics Nonmembers-$66.00 from the University of Minnesota at Minne- Order from IEEE Computer Society Order Dept. PO Box 80452, Worldway Postal Center Los Angeles, CA 90080 USA (714) 821-8380

February 1984 33

Authorized licensed use limited to: IEEE Xplore. Downloaded on January 8, 2009 at 09:23 from IEEE Xplore. Restrictions apply.