rotation matrix representations

4
 Representations of Rotation Matrices A rotation matrix  R  in 3D space is given by a 3 × 3 matrix. Hence,  R  has 9 elements. How eve r, these elements are not all independent numerical quantities since there is a set of properties that any rotation matrix must satisfy . Specically, in any rotation matrix  R, each row (and each column ) must be a unit vector. Also, any pair of two dierent rows must be mutually orthogonal and any pair of two dierent columns must be mutually orthogonal, i.e., denoting the (i, j ) th element of  R  by  r ij , we have the equations: 3 j=1 r 2 ij  = 1 fo r any  i  = 1, 2, 3 (1) 3 k=1 r ik r jk  = 0 fo r any  i  = 1, 2, 3 and  j  = 1, 2, 3 such that  i = j.  (2) The equations (1) and (2) represent, respectively, the properties that each row of  R is a unit vector and that any two dier ent rows are mut ually orthogo nal. The equiv alen t propert ies about columns can be sho wn to follow direc tly from equatio ns (1) and (2). Hence, the set of equations in (1) and (2) represen t the set of constrain ts on the 9 elements of  R. The tot al number of equatio ns from (1) and (2) is 6. Hence, there are a tot al of 6 constraints on the 9 elements of  R, implying that there are eectively 3 independent variables in  R, i.e., any rotation matrix  R  can be written as a function of 3 independent variables. The choic e of these 3 independen t variables to dene  R  is not unique and many dierent combinations of variables can be chosen in terms of which the set of all rotation matrices can be parameterized. Some of these choices of parameterizat ions of rotat ion matrices are discussed below. Parameterization of rotation matrices utilizing three elementary rotation matrices with one re- peated axis:  Since a rotation matrix can be, as discussed above, characterized in terms of three independent variables, one way to write a parameterized form of rotation matrices is through a decomposition into elemen- tary rotation matrices. There are man y ways to do this. F or example , the produc t  R x,φ R y,θ R x,ψ  is a rotation matrix where the notations  R x,φ ,  R y,θ , etc., denote the elementary rotation matrices (e.g.,  R x,φ  is a rotation around the  X  axis by angle  φ). This product of three elementary rotation matrices can be physically visualized as the composite rotation matrix obtained for the following transformation: rotate around the  X  axis by angle φ, then rotate around the new  Y  axis by angle  θ, then rotate around the new  X  axis by angle  ψ. Since each successive rotation in this formulation is dened in terms of the new (i.e., the current, and not the original) frame, the corresponding rotation matrices are combined by post-multiplying. Note that the same product  R x,φ R y,θ R x,ψ  of three elementary matrices can also be equivalently physically visualized as the following transformation: rotate around the  X  axis by angle ψ , then rotate around the original Y  axis by angle  θ, then rotate around the original  X  axis by angle  φ. Since each successi ve rotat ion in this formulation is dened in terms of the original (i.e., not the new or current) frame, the corresponding rotation matrices are combined by pre-multiplying. Instead of a composition of three elementary matrices as  R x,φ R y,θ R x,ψ , i.e., as an X Y X  combination, we could use other combinations such as  X Z X ,  Z X Z , etc. In general, there are six possible combinations: X Y  − X ,  X Z X ,  Y  − X Y  ,  Y  − Z Y  ,  Z X Z , and  Z Y  − Z . For example, considering the Z Y  − Z  combination, which is one of the more commonly used combinations, R = R z,φ R y,θ R z.ψ , i.e., R = c φ  −s φ  0 s φ  c φ  0 0 0 1 c θ  0  s θ 0 1 0 s θ  0  c θ c ψ  −s ψ  0 s ψ  c ψ  0 0 0 1  = c φ c θ c ψ s φ s ψ  c φ c θ s ψ s φ c ψ  c φ s θ s φ c θ c ψ  + c φ s ψ  s φ c θ s ψ  + c φ c ψ  s φ s θ s θ c ψ  s θ s ψ  c θ (3) where c φ  = cos(φ),  s φ  = sin(φ)  c ψ  = cos(ψ),  s ψ  = sin(ψ)  c θ  = cos(θ),  s θ  = sin(θ). Given a set of three numbers φ,  θ , and ψ  denoting the Z-Y-Z Euler angles, the corr espondin g rotation matrix can be found directly from (3). Also, given a rotation matrix  R  with its elements denoted as  r ij  (i.e., the (i, j) th element of  R  is denoted as  r ij ), the corresponding Z-Y-Z Euler angles can be found by solving for  φ ,  θ, and  ψ  using equatio n (3). F or example, using the (3, 3) element of  R, we have r 33  =  c θ . Hence,  θ  = cos 1 (r 33 ). Note that the func tion cos 1 is not unique, but has, in general, two possible values (within a 2 π  angular range). Hence, there are two possible values of  θ; for each of these values of  θ, the choices of  φ  and  ψ  are uniqu e as dened below. Hence , given a rotation matrix, there are, typ ically, two p ossibl e solut ions for the correspon ding Z-Y-Z Euler angles. In the special case that the (3 , 3) element of  R  is 1, we get  θ  = 0. In this case, the Euler angle paramet eriza tion of the rotation matrix reduces to  R  =  R z,φ R z,ψ  =  R z,φ+ψ ; hence, the sum  φ + ψ  can be found from the given 1

Upload: mekatron

Post on 04-Oct-2015

224 views

Category:

Documents


0 download

DESCRIPTION

rtr

TRANSCRIPT

  • Representations of Rotation Matrices

    A rotation matrix R in 3D space is given by a 3 3 matrix. Hence, R has 9 elements. However, theseelements are not all independent numerical quantities since there is a set of properties that any rotation matrixmust satisfy. Specifically, in any rotation matrix R, each row (and each column) must be a unit vector. Also,any pair of two different rows must be mutually orthogonal and any pair of two different columns must bemutually orthogonal, i.e., denoting the (i, j)th element of R by rij , we have the equations:

    3j=1

    r2ij = 1 for any i = 1, 2, 3 (1)

    3k=1

    rikrjk = 0 for any i = 1, 2, 3 and j = 1, 2, 3 such that i 6= j. (2)

    The equations (1) and (2) represent, respectively, the properties that each row of R is a unit vector and that anytwo different rows are mutually orthogonal. The equivalent properties about columns can be shown to followdirectly from equations (1) and (2). Hence, the set of equations in (1) and (2) represent the set of constraintson the 9 elements of R. The total number of equations from (1) and (2) is 6. Hence, there are a total of 6constraints on the 9 elements of R, implying that there are effectively 3 independent variables in R, i.e., anyrotation matrix R can be written as a function of 3 independent variables. The choice of these 3 independentvariables to define R is not unique and many different combinations of variables can be chosen in terms of whichthe set of all rotation matrices can be parameterized. Some of these choices of parameterizations of rotationmatrices are discussed below.

    Parameterization of rotation matrices utilizing three elementary rotation matrices with one re-peated axis: Since a rotation matrix can be, as discussed above, characterized in terms of three independentvariables, one way to write a parameterized form of rotation matrices is through a decomposition into elemen-tary rotation matrices. There are many ways to do this. For example, the product Rx,Ry,Rx, is a rotationmatrix where the notations Rx,, Ry,, etc., denote the elementary rotation matrices (e.g., Rx, is a rotationaround the X axis by angle ). This product of three elementary rotation matrices can be physically visualizedas the composite rotation matrix obtained for the following transformation: rotate around the X axis by angle, then rotate around the new Y axis by angle , then rotate around the new X axis by angle . Since eachsuccessive rotation in this formulation is defined in terms of the new (i.e., the current, and not the original)frame, the corresponding rotation matrices are combined by post-multiplying.

    Note that the same product Rx,Ry,Rx, of three elementary matrices can also be equivalently physicallyvisualized as the following transformation: rotate around the X axis by angle , then rotate around the originalY axis by angle , then rotate around the original X axis by angle . Since each successive rotation in thisformulation is defined in terms of the original (i.e., not the new or current) frame, the corresponding rotationmatrices are combined by pre-multiplying.

    Instead of a composition of three elementary matrices as Rx,Ry,Rx,, i.e., as an XY X combination, wecould use other combinations such as XZX, ZXZ, etc. In general, there are six possible combinations:X Y X, X Z X, Y X Y , Y Z Y , Z X Z, and Z Y Z.

    For example, considering the ZY Z combination, which is one of the more commonly used combinations,R = Rz,Ry,Rz., i.e.,

    R =

    c s 0s c 00 0 1

    c 0 s0 1 0s 0 c

    c s 0s c 00 0 1

    = ccc ss ccs sc csscc + cs scs + cc ss

    sc ss c

    (3)

    where c = cos(), s = sin() c = cos(), s = sin() c = cos(), s = sin(). Given a set of three numbers, , and denoting the Z-Y-Z Euler angles, the corresponding rotation matrix can be found directly from (3).

    Also, given a rotation matrix R with its elements denoted as rij (i.e., the (i, j)th element of R is denoted

    as rij), the corresponding Z-Y-Z Euler angles can be found by solving for , , and using equation (3). Forexample, using the (3, 3) element of R, we have r33 = c. Hence, = cos

    1(r33). Note that the function cos1 isnot unique, but has, in general, two possible values (within a 2pi angular range). Hence, there are two possiblevalues of ; for each of these values of , the choices of and are unique as defined below. Hence, given arotation matrix, there are, typically, two possible solutions for the corresponding Z-Y-Z Euler angles. In thespecial case that the (3, 3) element of R is 1, we get = 0. In this case, the Euler angle parameterization ofthe rotation matrix reduces to R = Rz,Rz, = Rz,+; hence, the sum + can be found from the given

    1

  • rotation matrix R but not the individual angles and (i.e., an infinite number of possible solutions for and). Similarly, if the (3, 3) element of a given rotation matrix R is -1, then we get = pi and it can be shownthat the difference can be found but not the individual angles and . Except for the special casesthat the (3, 3) element of R is +1 or -1, the angle has two possible values as discussed above; one of thesevalues will have a positive s and the other value will have a negative s. Using the (3, 1) and (3, 2) elementsof R, we see that sc = r31 and ss = r32. Hence, = Atan2(r31, r32) for the case of positive s and = Atan2(r31,r32) for the case of negative s. Similarly, using the (1, 3) and (2, 3) elements of R, we see thatcs = r13 and ss = r23. Hence, = Atan2(r13, r23) for the case of positive s and = Atan2(r13,r23)for the case of negative s.Note on Atan2 function: Here, Atan2 denotes the two-argument arc-tangent function, i.e., Atan2(x, y) is es-sentially tan1(y/x), but also takes into account the signs of x and y. Hence, Atan2(x, y) is the angle suchthat cos() = x

    x2+y2and sin() = y

    x2+y2. Note that the order of the arguments in this definition of the

    Atan2 function is opposite to the C/C++ atan2 function (i.e., atan2(y,x) using the atan2 function in C/C++is equivalent to Atan2(x, y) defined above).

    Roll-Pitch-Yaw angles: Another way to parameterize rotation matrices is using three independent variablesrepresenting rotations around X, Y , and Z axes. These rotation angles are called roll (around X axis), pitch(around Y axis), and yaw (around Z axis). Since multiplication of rotation matrices is not commutative,different orders of rotations around X, Y , and Z axes would yield physically different composite rotations,i.e., for example, Rx,xRy,yRz,z is, in general, not equal to Rz,zRy,yRx,x , i.e., the order of the elementaryrotation matrices is important to specify. One commonly used convention is Rz,zRy,yRx,x . This productof three elementary rotation matrices can be physically visualized as the composite rotation matrix obtainedfor the following transformation: rotate around the Z axis by angle z, then rotate around the new Y axis byangle y, then rotate around the new X axis by angle x. Since each successive rotation in this formulation isdefined in terms of the new (i.e., the current, and not the original) frame, the corresponding rotation matricesare combined by post-multiplying. Note that the same product Rz,zRy,yRx,x of three elementary matricescan also be equivalently physically visualized as the following transformation: rotate around the X axis byangle x, then rotate around the original Y axis by angle y, then rotate around the original z axis by angle z;since each successive rotation in this formulation is defined in terms of the original (i.e., not the new or current)frame, the corresponding rotation matrices are combined by pre-multiplying.

    With R = Rz,zRy,yRx,x , we get

    R =

    cz sz 0sz cz 00 0 1

    cy 0 sy0 1 0sy 0 cy

    1 0 00 cx sx0 sx cx

    = czcy szcx + czsysx szsx + czsycxszcy czcx + szsysx czsx + szsycxsy cysx cycx

    (4)

    where cx = cos(x), sx = sin(x), cy = cos(y), sy = sin(y), cz = cos(z), and sz = sin(z). Given a set ofthree numbers x, y, and z denoting the roll, pitch, and yaw angles, the corresponding rotation matrix canbe found directly from (4).

    Also, given a rotation matrix R with its elements denoted as rij (i.e., the (i, j)th element of R is denoted

    as rij), the corresponding roll, pitch, and yaw angles can be found by solving for x, y, and z using equation(4). For example, using the (3, 1) element of R, we have r31 = sy. Hence, y = sin1(r31). Note that thefunction sin1 is not unique, but has, in general, two possible values (within a 2pi angular range). Hence, thereare two possible values of y; one of these two values will correspond to a positive cy and the other value willcorrespond to a negative cy. For each of these values of y, the choices of x and z are unique. Using the(1, 1) and (2, 1) elements of R, we see that czcy = r11 and szcy = r21. Hence, z = Atan2(r11, r21) for thecase of positive cy and z = Atan2(r11,r21) for the case of negative cy. Similarly, using the (3, 2) and (3, 3)elements of R, we see that cysx = r32 and cycx = r33. Hence, x = Atan2(r33, r32) for the case of positive cyand x = Atan2(r33,r32) for the case of negative cy. Hence, given a rotation matrix, there are, typically,two possible solutions for the corresponding roll, pitch, and yaw angles.

    In the special case that the (3, 1) element of R is 1 or -1, we get y =3pi2 or

    pi2 , respectively. In this case, the

    r11, r21, r32, and r33 elements are all zero. Hence, x and z would need to be solved for using the expressionsin the (1, 2), (1, 3), (2, 2), and (2, 3) elements. Except in this special case, it is seen above that x can be foundfrom the (3, 2) and (3, 3) elements and z can be found from the (1, 1) and (2, 1) elements.

    Axis-angle representation: Instead of parameterizing a rotation matrix as a product of three elementaryrotation matrices (as in the Euler angles or in the roll-pitch-yaw parameterizations defined above), an alternative

    2

  • parameterization is to characterize a rotation matrix as a single rotation around an appropriate axis. In thisaxis-angle representation, a rotation matrix is characterized as a rotation by an angle around an axis direction(a unit vector) k, and is denoted as Rk,. This combination of a unit vector k and an angle correspondsto three independent variables (as expected since, as discussed above, a rotation matrix can be parameterizedin terms of three independent variables) since the constraint that k is a unit vector (and therefore has unitmagnitude) reduces the number of effectively independent variables in k to 2.

    Given k = [kx, ky, kz]T with k2x + k

    2y + k

    2z = 1, the rotation matrix Rk, corresponding to a rotation around

    axis k by an angle can be found using a few different ways as described below.One way to find Rk, is to utilize the formula that we had found earlier for a rotation performed around a

    different frame (i.e., if a rotation from a frame 1 to a frame 2 is defined numerically as R in terms of a frame c,then the rotation matrix R12 is given by R

    12 = (R

    c1)TR(Rc1)). For example, if we consider a coordinate frame c

    in which the Z axis is along the direction of k, then in this frame c, the rotation around the axis k is simply anelementary rotation around the Z axis. Hence, in frame c, the rotation matrix is defined numerically as Rz,.With frame 1 being the original coordinate frame and frame 2 being the final coordinate frame after the rotationaround axis k by angle , the rotation matrix R12 can therefore be found as Rk, = R

    12 = (R

    c1)TRz,(R

    c1). To

    find the rotation matrix Rc1, first note that the exact definition of the frame c is not important as long as its Zaxis is chosen along direction k, i.e., there are no specific constraints on the X and Y axes in the frame c. Thecondition that the Z axis of the frame c is along the direction of the specified vector k can be characterized asthe requirement that if a point p at unit distance along the direction of the vector k is considered, its coordinatesin the frame c are of the form [0, 0, 1]T ; also, the coordinates of the point p in the frame 1 are [kx, ky, kz]

    T sincek is a unit vector that is numerically defined relative to the original frame (i.e., frame 1). Hence, 00

    1

    = Rc1 kxkykz

    . (5)Since (Rc1)

    1 = (Rc1)T , we get kxky

    kz

    = (Rc1)T 00

    1

    . (6)To find a choice of a rotation matrix Rc1 that satisfies this condition, we can use, for example, the roll-pitch-yawparameterization, i.e., Rc1 = Rz,zRy,yRx,x . Using (4), this results in the equations sy = kx, cysx = ky, andcycx = kz, where cx = cos(x), sx = sin(x), cy = cos(y), and sy = sin(y). Hence, we get

    sy = kx ; cy =k2y + k

    2z ; sx =

    kyk2y + k

    2z

    ; cx =kzk2y + k

    2z

    . (7)

    Since there is no explicit condition on z, we can pick z = 0, i.e., Rc1 = Ry,yRx,x with x and y defined by

    the conditions in (7). Finally, we get Rk, = R12 = (R

    c1)TRz,(R

    c1) = Rx,xRy,yRz,Ry,yRx,x . Expanding

    out this matrix product and doing some algebraic simplifications, we get

    Rk, =

    k2xv + c kxkyv kzs kxkzv + kyskxkyv + kzs k2yv + c kykzv kxskxkzv kys kykzv + kxs k2zv + c

    (8)where c = cos(), s = sin(), and v = vers() = 1 cos().

    Note that in the derivation of the axis-angle representation above, the choice of Rc1 is not unique since theonly condition on this matrix is that the Z axis in frame c should correspond with the vector k in the originalcoordinate frame. Hence, we could, for example, have found the rotation matrix Rc1 using the Euler anglerepresentation above instead of roll-pitch-yaw representation; the final rotation matrix Rk, would be identicalto (8) using any such Rc1.

    Another way to derive the axis-angle representation shown in (8) is using a geometrical analysis from thedefinition of rotation around an axis vector k. For this purpose, consider a point p in 3D space. Recall that oneinterpretation of a rotation matrix is as a physical rotation/transformation of a rigid body, e.g., as a mappingfrom a point in 3D space to a new point. In this interpretation of rotation matrices, a rotation matrix R12transforms a point p to a new point pnew = R

    12p. Given an axis vector k, the point p can be written as a

    combination of two parts, a part that is along the direction k and a part that is perpendicular to the directionk, i.e., as p = pa + pp, where pa is along the direction k and pp is perpendicular to the direction k. The part

    3

  • along the direction k is, by definition, pa = (p.k)k. Also, pp = p pa. When applying a rotation around thevector k, the part along k does not change and the part perpendicular to k will be rotated by the angle , i.e.,pnew = pa + pp where pp denotes a rotated version of pp. To find pp, note that if pp is rotated by 90 degreesaround k, then we would get k pp (this is, by its definition, the vector perpendicular to both k and pp); therotation of pp is in the plane perpendicular to k; hence, in general, if pp is rotated by angle around k, thenwe get pp = pp cos() + (k pp) sin(). Note that since k pa = 0, we get k pp = k p. Therefore,pnew = pa + ppc + (k p)s = pa + (p pa)c + (k p)s = pc + pav + (k p)s = pc + (p.k)kv + (k p)s.

    We can write p = Ip where I is the 3 3 identity matrix. Also, (p.k)k can be expanded as (p.k)k = Pp wherethe matrix P is defined as

    P =

    k2x kxky kxkzkxky k2y kykzkxkz kykz k

    2z

    p. (9)Also, by the definition of the cross product, k p = S(k)p where S(k) is the skew-symmetric matrix defined as

    S(k) =

    0 kz kykz 0 kxky kx 0

    . (10)Hence, pnew = (Ic +Pv +S(k)s)p. Therefore, R

    12 = Ic +Pv +S(k)s. Expanding out the elements of this

    matrix using (9) and (10), we get an identical matrix to (8).Given a unit vector k and an angle , the rotation matrix Rk, can be found directly from (8). Also, given

    a rotation matrix R with its elements denoted as rij (i.e., the (i, j)th element of R is denoted as rij), the

    corresponding axis vector k and angle can be found by solving for kx, ky, kz, and using equation (8).Using r11 = k

    2xv + c, r22 = k

    2yv + c, and r33 = k

    2zv + c, and using the property k

    2x + k

    2y + k

    2z = 1, we

    get v + 3c = r11 + r22 + r33. Hence, since v = (1 c), we get 1 + 2c = r11 + r22 + r33. Therefore, = cos1(0.5[r11 + r22 + r33 1]). Also, using the off-diagonal elements of Rk, from (8), we get

    kx =r32 r32

    2s; ky =

    r13 r312s

    ; kz =r21 r12

    2s(11)

    where s is found as

    1 c2 from the definition of c given above.Note on cross product as skew-symmetric matrix: Given vectors k1 = [k1x, k1y, k1z]

    T and k2 =[k2x, k2y, k2z]

    T , the cross product of these vectors can be found as follows: denoting the unit vectors in the X,Y , and Z axis directions by i, j, and k, respectively, we have k1 = k1xi+k1yj+k1zk and k2 = k2xi+k2yj+k2zk.From the definition of cross product, we have ij = k, ji = k, ik = j, ki = j, jk = i, and kj = i.Hence, expanding, k1k2, we can write k1k2 in the form S(k1)k2 where S(k1) is the skew-symmetric matrix

    S(k1) =

    0 k1z k1yk1z 0 k1xk1y k1x 0

    . (12)Quaternion representation: A quaternion is a 41 vector denoted as q = [q1, q2, q3, q4]T . A unit quaternionis a quaternion with unit magnitude, i.e., q21 + q

    22 + q

    23 + q

    24 = 1. The quaternion representation can be defined in

    terms of the axis-angle representation as follows: A rotation matrix given in axis-angle representation as Rk,can be represented as a unit quaternion q = [q1, q2, q3, q4]

    T with elements

    q1 = cos

    (

    2

    ); q2 = kx sin

    (

    2

    ); q3 = ky sin

    (

    2

    ); q4 = kz sin

    (

    2

    ). (13)

    Using the trigonometric identities that s = 2 sin(2 ) cos(

    2 ), c = cos

    2( 2 )sin2( 2 ) = 12 sin2( 2 ) = 2 cos2( 2 )1,the rotation matrix Rk, corresponding to the equivalent quaternion q in (13) can be written as

    Rk, =

    1 2q23 2q24 2q2q3 2q4q1 2q2q4 + 2q3q12q2q3 + 2q4q1 1 2q22 2q24 2q3q4 2q2q12q2q4 2q3q1 2q3q4 + 2q2q1 1 2q22 2q23

    . (14)Given a quaternion q = [q1, q2, q3, q4]

    T , the corresponding rotation matrix can be found directly from (14). Also,given a rotation matrix R with its elements denoted as rij (i.e., the (i, j)

    th element of R is denoted as rij), thecorresponding quaternion can be found by first finding the equivalent axis vector k and angle and then findingthe corresponding quaternion using (13).

    4