Computing Euler angles from a rotation matrix



Similar documents
TWO-DIMENSIONAL TRANSFORMATION

THE COMPLEX EXPONENTIAL FUNCTION

Area and Arc Length in Polar Coordinates

Lecture L3 - Vectors, Matrices and Coordinate Transformations

Trigonometric Functions and Triangles

Evaluating trigonometric functions

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

10 Polar Coordinates, Parametric Equations

Trigonometry Review with the Unit Circle: All the trig. you ll ever need to know in Calculus

Triangle Trigonometry and Circles

The Vector or Cross Product

Trigonometric Functions: The Unit Circle

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

The Force Table Introduction: Theory:

Calculus with Parametric Curves

[1] Diagonal factorization

v 1 v 3 u v = (( 1)4 (3)2, [1(4) ( 2)2], 1(3) ( 2)( 1)) = ( 10, 8, 1) (d) u (v w) = (u w)v (u v)w (Relationship between dot and cross product)

SAT Subject Math Level 2 Facts & Formulas

MATH 381 HOMEWORK 2 SOLUTIONS

Angles and Quadrants. Angle Relationships and Degree Measurement. Chapter 7: Trigonometry

Understanding Poles and Zeros

2 Session Two - Complex Numbers and Vectors

PROBLEM SET. Practice Problems for Exam #1. Math 1352, Fall Oct. 1, 2004 ANSWERS

Fundamentals of Computer Animation

G. GRAPHING FUNCTIONS

Linear algebra and the geometry of quadratic equations. Similarity transformations and orthogonal matrices

Trigonometry Review Workshop 1

Rotation Matrices and Homogeneous Transformations

One advantage of this algebraic approach is that we can write down

Lectures notes on orthogonal matrices (with exercises) Linear Algebra II - Spring 2004 by D. Klain

4. How many integers between 2004 and 4002 are perfect squares?

Lecture 7. Matthew T. Mason. Mechanics of Manipulation. Lecture 7. Representing Rotation. Kinematic representation: goals, overview

Section V.3: Dot Product

5.3 The Cross Product in R 3

Understanding Rotations

The Matrix Elements of a 3 3 Orthogonal Matrix Revisited

a cos x + b sin x = R cos(x α)

Review B: Coordinate Systems

Chapter 17. Orthogonal Matrices and Symmetries of Space

Section 9.5: Equations of Lines and Planes

Lecture 3: Coordinate Systems and Transformations

D.3. Angles and Degree Measure. Review of Trigonometric Functions

Algebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123

Geometric Transformation CS 211A

Vector Math Computer Graphics Scott D. Anderson

1. Introduction sine, cosine, tangent, cotangent, secant, and cosecant periodic

Solutions to Homework 10

Metrics on SO(3) and Inverse Kinematics

Introduction to Matrices

88 CHAPTER 2. VECTOR FUNCTIONS. . First, we need to compute T (s). a By definition, r (s) T (s) = 1 a sin s a. sin s a, cos s a

COMPLEX NUMBERS. a bi c di a c b d i. a bi c di a c b d i For instance, 1 i 4 7i i 5 6i

Lecture L29-3D Rigid Body Dynamics

Solutions to Exercises, Section 5.1

The elements used in commercial codes can be classified in two basic categories:

LINEAR MAPS, THE TOTAL DERIVATIVE AND THE CHAIN RULE. Contents

Week 13 Trigonometric Form of Complex Numbers

Chapter 6 Circular Motion

animation animation shape specification as a function of time

v w is orthogonal to both v and w. the three vectors v, w and v w form a right-handed set of vectors.

CIRCLE COORDINATE GEOMETRY

Solutions to Practice Problems

Geometry of Vectors. 1 Cartesian Coordinates. Carlo Tomasi

5.3 SOLVING TRIGONOMETRIC EQUATIONS. Copyright Cengage Learning. All rights reserved.

Section 10.5 Rotation of Axes; General Form of a Conic

13.4 THE CROSS PRODUCT

x 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1

Linear Programming. March 14, 2014

Unified Lecture # 4 Vectors

ANALYTICAL METHODS FOR ENGINEERS

Introduction to Matrices for Engineers

Chapter 18 Static Equilibrium

Lecture 8. Generating a non-uniform probability distribution

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Animation (-4, -2, 0 ) + (( 2, 6, -4 ) - (-4, -2, 0 ))*.75 = (-4, -2, 0 ) + ( 6, 8, -4)*.75 = (.5, 4, -3 ).

Rotation about an arbitrary axis and reflection through an arbitrary plane

FRICTION, WORK, AND THE INCLINED PLANE

Chapter 2. Parameterized Curves in R 3

1 Symmetries of regular polyhedra

Higher Order Equations

Review A: Vector Analysis

Experiment 9. The Pendulum

Section 11.1: Vectors in the Plane. Suggested Problems: 1, 5, 9, 17, 23, 25-37, 40, 42, 44, 45, 47, 50

Mechanics 1: Conservation of Energy and Momentum

Inner Product Spaces

TOPIC 4: DERIVATIVES

4.5 Chebyshev Polynomials

Math Placement Test Practice Problems

Chapter 6. Linear Transformation. 6.1 Intro. to Linear Transformation

6.4 Logarithmic Equations and Inequalities

Geometric Transformations

Inverse Trig Functions

Trigonometry Hard Problems

List the elements of the given set that are natural numbers, integers, rational numbers, and irrational numbers. (Enter your answers as commaseparated

Linear Programming. April 12, 2005

Analysis of Stresses and Strains

521493S Computer Graphics. Exercise 2 & course schedule change

2D Geometric Transformations

Trigonometry for AC circuits

2.2 Magic with complex exponentials

Section 2.7 One-to-One Functions and Their Inverses

Transcription:

Computing Euler angles from a rotation matrix Gregory G. Slabaugh Abstract This document discusses a simple technique to find all possible Euler angles from a rotation matrix. Determination of Euler angles is sometimes a necessary step in computer graphics vision robotics and kinematics. However the solution may or may not be obvious. Rotation matrices We start off with the standard definition of the rotations about the three principle axes. A rotation of ψ radians about the x-axis is defined as R x ψ = 1 0 0 0 cos ψ sin ψ 0 sin ψ cos ψ Similarly a rotation of θ radians about the y-axis is defined as cos θ 0 sin θ R y θ = 0 1 0 sin θ 0 cos θ Finally a rotation of φ radians about the z-axis is defined as cos φ sin φ 0 R z φ = sin φ cos φ 0 0 0 1 The angles ψ θ and φ are the Euler angles. Generalized rotation matrices A general rotation matrix can will have the form R = R 11 R 12 R 13 R 21 R 22 R 23 R 31 R 32 R 33 1

This matrix can be thought of a sequence of three rotations one about each principle axis. Since matrix multiplication does not commute the order of the axes which one rotates about will affect the result. For this analysis we will rotate first about the x-axis then the y-axis and finally the z-axis. Such a sequence of rotations can be represented as the matrix product R = R z φr y θr x ψ 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 matrix R we can compute the Euler angles ψ θ and φ by equating each element in R with the corresponding element in the matrix product R z φr y θr x ψ. This results in nine equations that can be used to find the Euler angles. Finding two possible angles for θ Starting with R 31 we find This equation can be inverted to yield R 31 = sin θ. θ = sin 1 R 31. 1 However one must be careful in interpreting this equation. Since sinπ θ = sinθ there are actually two distinct values for R 31 ±1 of θ that satisfy Equation 1. Therefore both the values θ 1 = sin 1 R 31 θ 2 = π θ 1 = π + sin 1 R 31 are valid solutions. We will handle the special case of R 31 = ±1 later in this report. So using the R 31 element of the rotation matrix we are able to determine two possible values for θ. Finding the corresponding angles of ψ To find the values for ψ we observe that We use this equation to solve for ψ as R 32 R 33 = tanψ. ψ = atan2r 32 R 33 2 2

where atan2y x is arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y/x except that the signs of both arguments are used to determine the quadrant of the result which lies in the range [ π π]. The function atan2 is available in many programming languages. One must be careful in interpreting Equation 2. If cosθ > 0 then ψ = atan2r 32 R 33. However when cosθ < 0 ψ = atan2 R 32 R 33. A simple way to handle this is to use the equation R32 ψ = atan2 cos θ R 33 3 cos θ to compute ψ. Equation 3 is valid for all cases except when cos θ = 0. We will deal with this special case later in this report. For each value of θ we compute a corresponding value of ψ using Equation 3 yielding R32 R 33 ψ 1 = atan2 4 R32 R 33 ψ 2 = atan2 5 Finding the corresponding angles of φ A similar analysis holds for finding φ. We observe that We solve for φ using the equation φ = atan2 R 21 R 11 = tan φ. R21 cos θ R 11 cos θ Again this equation is valid for all cases except when cos θ = 0. We will deal with this special case later in this report. For each value of θ we compute a corresponding value of φ using Equation 6 R21 R 11 φ 1 = atan2 7 R21 R 11 φ 2 = atan2 8 Two solutions if cos θ 0 For the case of cos θ 0 we now have two triplets of Euler angles that reproduce the rotation matrix namely Both of these solutions will be valid. ψ 1 θ 1 φ 1 ψ 2 θ 2 φ 2 6 3

What if cos θ = 0? This technique described above does not work if the R 31 element of the rotation 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 and therefore Equations 3 and 6 will become 0 ψ = atan2 φ = atan2 0 0 0 0 0 0 0 In this case R 11 R 21 R 32 and R 33 do not constrain the values of ψ and φ. Therefore we must use different elements of the rotation matrix to compute the values of ψ and φ.. θ = π/2 case: Consider the case when θ = π/2. Then R 12 = sin ψ cos φ cos ψ sin φ = sinψ φ R 13 = cos ψ cos φ + sin ψ sin φ = cosψ φ R 22 = sin ψ sin φ + cos ψ cos φ = cosψ φ = R 13 R 23 = cos ψ sin φ sin ψ cos φ = sinψ φ = R 12 Any ψ and φ that satisfy these equations will be a valid solution. Using the equations for R 12 and R 13 we find that ψ φ = atan2r 12 R 13 ψ = φ + atan2r 12 R 13 θ = π/2 case: Not surprisingly a similar result holds for the case when θ = π/2 for which R 12 = sin ψ cos φ cos ψ sin φ = sinψ + φ R 13 = cos ψ cos φ + sin ψ sin φ = cosψ + φ R 22 = sin ψ sin φ + cos ψ cos φ = cosψ + φ = R 13 R 23 = cos ψ sin φ sin ψ cos φ = sinψ + φ = R 12 Again using the equations for R 12 and R 13 we find that ψ + φ = atan2 R 12 R 13 ψ = φ + atan2 R 12 R 13 4

if R 31 ±1 θ 1 = asinr 31 θ 2 = π θ 1 ψ 1 = atan2 R32 ψ 2 = atan2 R32 φ 1 = atan2 R21 R 33 R 33 R 11 R 11 φ 2 = atan2 R21 else φ = anything; can set to 0 if R 31 = 1 θ = π/2 ψ = φ + atan2r 12 R 13 else θ = π/2 ψ = φ + atan2 R 12 R 13 end if end if Figure 1: Pseudo-code for computing Euler angles from a rotation matrix. See text for details. Either case: In both the θ = π/2 and θ = π/2 cases we have found that ψ and φ are linked. This phenomenon is called Gimbal lock. Although in this case there are an infinite number of solutions to the problem in practice one is often interested in finding one solution. For this task it is convenient to set φ = 0 and compute ψ as described above. Pseudo-code We now summarize the method by providing a pseudo-code implementation in Figure 1. The code is very simple. Example An example that demonstrates the computation of ψ θ and φ from a rotation matrix is provided below. Suppose we are asked to find the Euler angles that produce the matrix R =.1464.8536.8536.1464.7071 First we find the possible values for θ to be θ 1 = sin.7071 = π 4 5

θ 2 = π θ 1 = 3π 4 Then we find the corresponding values of ψ to be ψ 1 = atan2 cosπ/4 = π cosπ/4 4 ψ 2 = atan2 cos3π/4 = 3π cos3π/4 4 And we find φ to be φ 1 = atan2 cosπ/4 = π cosπ/4 4 φ 2 = atan2 cos3π/4 = 3π cos3π/4 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 is always more than one sequence of rotations about the three principle axes that results in the same orientation of an object. As we have shown in this report in the non-degenerate case of cos θ 0 there are two solutions. For the degenerate case of cos θ = 0 an infinite number of solutions exist. As an example consider a book laying on a table face up in front of you. Define the x-axis as to the right the y-axis as away from you and the z-axis up. A rotation of π radians about the y-axis will turn the book so that the back cover is now facing up. Another way to achieve the same orientation would be to rotate the book π radians about the x-axis and then π radians about the z-axis. Thus there is more than one way to achieve a desired rotation. Acknowledgement I wish to thank Sinisa Segvic from the University of Zagreb for providing some insights into how to reduce the number of possible solutions to two for the non-degenerate case. Also many thanks to Tobias Ziegler from the Fraunhofer Institute for pointing out the need for negative signs on R 12 and R 13 in the θ = π/2 case. 6

References [1] Ken Shoemake Animating Rotation with Quaternion Curves Proc. SIG- GRAPH 1985 pp. 245-254. 7