Example: bachelor of science

Computing Euler angles from a rotation matrix

Computing Euler angles from a rotation document discusses a simple technique to find all possible Euler angles froma rotation matrix . Determination of Euler angles is sometimes a necessary stepin computer graphics, vision, robotics, and kinematics. However, the solutionmay or may not be matricesWe start off with the standard definition of the rotations about the three prin-ciple rotation of radians about thex-axis is defined asRx( ) = 1 000 cos sin 0 sin cos Similarly, a rotation of radians about they-axis is defined asRy( ) = cos 0 sin 01 0 sin 0 cos Finally, a rotation of radians about thez-axis is defined asRz( )

matrix is 1 or −1, which corresponds to θ= −π/2 or θ= π/2, respectively, and to cosθ= 0. When we try to solve for the possible values of ψand φusing the above technique, problems will occur, since the elements R 11, R 21, R 32, and R 33 will all be zero, …

Tags:

  Form, Computing, Glean, Matrix, Euler, Rotation, Computing euler angles from a rotation matrix

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Computing Euler angles from a rotation matrix

1 Computing Euler angles from a rotation document discusses a simple technique to find all possible Euler angles froma rotation matrix . Determination of Euler angles is sometimes a necessary stepin computer graphics, vision, robotics, and kinematics. However, the solutionmay or may not be matricesWe start off with the standard definition of the rotations about the three prin-ciple rotation of radians about thex-axis is defined asRx( ) = 1 000 cos sin 0 sin cos Similarly, a rotation of radians about they-axis is defined asRy( ) = cos 0 sin 01 0 sin 0 cos Finally, a rotation of radians about thez-axis is defined asRz( )

2 = cos sin 0sin cos 0001 The angles , , and are the Euler rotation matricesA general rotation matrix can will have the form ,R= R11R12R13R21R22R23R31R32R33 1 This matrix can be thought of a sequence of three rotations, one about eachprinciple axis. Since matrix multiplication does not commute, the order of theaxes which one rotates about will affect the result. For this analysis, we willrotate first about thex-axis, then they-axis, and finally thez-axis. Such asequence of rotations can be represented as the matrix product,R=Rz( )Ry( )Rx( )= cos cos sin sin cos cos sin cos sin cos + sin sin cos sin sin sin sin + cos cos cos sin sin sin cos sin sin cos cos cos Given a rotation matrixR, we can compute the Euler angles , , , and by equating each element inRwith the corresponding element in the matrixproductRz( )Ry( )Rx( ).

3 This results in nine equations that can be used tofind the Euler two possible angles for Starting withR31, we findR31= sin .This equation can be inverted to yield = sin 1(R31).(1)However, one must be careful in interpreting this equation. Since sin( ) =sin( ),there are actuallytwodistinct values (forR316= 1) of that satisfyEquation 1. Therefore, both the values 1= sin 1(R31) 2= 1= + sin 1(R31)are valid solutions. We will handle the special case ofR31= 1 later in thisreport. So using theR31element of the rotation matrix , we are able to determinetwo possible values for.

4 Finding the corresponding angles of To find the values for , we observe thatR32R33= tan( ).We use this equation to solve for , as = atan2(R32,R33),(2)2where atan2(y,x) is arc tangent of the two variablesxandy. It is similar tocalculating the arc tangent ofy/x, except that the signs of both arguments areused to determine the quadrant of the result, which lies in the range [ , ].The function atan2 is available in many programming must be careful in interpreting Equation 2. If cos( )>0, then =atan2(R32,R33). However, when cos( )<0, = atan2( R32, R33). A simpleway to handle this is to use the equation = atan2(R32cos ,R33cos )(3)to compute.

5 Equation 3 is valid for all casesexceptwhen cos = 0. We will deal with thisspecial case later in this report. For each value of , we compute a correspondingvalue of using Equation 3, yielding 1= atan2(R32cos 1,R33cos 1)(4) 2= atan2(R32cos 2,R33cos 2)(5)Finding the corresponding angles of A similar analysis holds for finding . We observe thatR21R11= tan .We solve for using the equation = atan2(R21cos ,R11cos )(6)Again, this equation is valid for all casesexceptwhen cos = 0. We willdeal with this special case later in this report. For each value of , we computea corresponding value of using Equation 6, 1= atan2(R21cos 1,R11cos 1)(7) 2= atan2(R21cos 2,R11cos 2)(8)Two solutions ifcos 6=0 For the case of cos 6= 0, we now have two triplets of Euler angles that reproducethe rotation matrix , namely( 1, 1, 1)( 2, 2, 2)Bothof these solutions will be ifcos =0?

6 This technique described above does not work if theR31element of the rotationmatrix is 1 or 1, which corresponds to = /2 or = /2, respectively, andto cos = 0. When we try to solve for the possible values of and usingthe above technique, problems will occur, since the elementsR11,R21,R32, andR33will all be zero, and therefore Equations 3 and 6 will become = atan2(00,00) = atan2(00,00).In this caseR11,R21,R32, andR33do not constrain the values of and .Therefore, we must use different elements of the rotation matrix to compute thevalues of and . = /2case:Consider the case when = /2.

7 Then,R12= sin cos cos sin = sin( )R13= cos cos + sin sin = cos( )R22= sin sin + cos cos = cos( ) =R13R23= cos sin sin cos = sin( ) = R12 Any and that satisfy these equations will be a valid solution. Usingthe equations forR12andR13, we find that( ) = atan2(R12,R13) = + atan2(R12,R13) = /2case:Not surprisingly, a similar result holds for the case when = /2, for whichR12= sin cos cos sin = sin( + )R13= cos cos + sin sin = cos( + )R22= sin sin + cos cos = cos( + ) = R13R23= cos sin sin cos = sin( + ) =R12 Again, using the equations forR12andR13, we find that( + ) = atan2( R12, R13) = + atan2( R12, R13)4if (R316= 1) 1= asin(R31) 2= 1 1=atan2(R32cos 1,R33cos 1) 2=atan2(R32cos 2,R33cos 2) 1=atan2(R21cos 1,R11cos 1) 2=atan2(R21cos 2,R11cos 2)else =anything.

8 Can set to0if (R31= 1) = /2 = +atan2(R12,R13)else = /2 = +atan2( R12, R13)end ifend ifFigure 1: Pseudo-code for Computing Euler angles from a rotation matrix . Seetext for case:In both the = /2 and = /2 cases, we have found that and are linked. This phenomenon is calledGimbal lock. Althoughin this case, there are an infinite number of solutions to the problem, inpractice, one is often interested in finding one solution. For this task, it isconvenient to set = 0 and compute as described now summarize the method by providing a pseudo-code implementation inFigure 1.

9 The code is very example that demonstrates the computation of , , and from a rotationmatrix is provided we are asked to find the Euler angles that produce the matrixR= .5 ..1464 . First, we find the possible values for to be 1= sin( .7071) = 45 2= 1=3 4 Then, we find the corresponding values of to be 1= atan2(.5cos( /4),.5cos( /4))= 4 2= atan2(.5cos(3 /4),.5cos(3 /4))= 3 4 And we find to be 1= atan2(.5cos( /4),.5cos( /4))= 4 2= atan2(.5cos(3 /4),.5cos(3 /4))= 3 4 Therefore, the solutions are( 4, 4, 4)( 3 4,3 4, 3 4)More than one solution?It is interesting to note that there isalwaysmore than one sequence of rotationsabout the three principle axes that results in the same orientation of an we have shown in this report, in the non-degenerate case of cos 6= 0, thereare two solutions.

10 For the degenerate case of cos = 0, an infinite number ofsolutions an example, consider a book laying on a table face up in front of thex-axis as to the right, they-axis as away from you, and thez-axisup. A rotation of radians about they-axis will turn the book so that the backcover is now facing up. Another way to achieve the same orientation would beto rotate the book radians about thex-axis, and then radians about thez-axis. Thus, there is more than one way to achieve a desired wish to thank Sinisa Segvic, from the University of Zagreb, for providing someinsights into how to reduce the number of possible solutions to two for thenon-degenerate case.


Related search queries