<<

Rotation Matrices and Quaternion

Siamak Faal 2/2 07/02/2016

1 Reviews from Last Presentation

2 Application

Analytical Navigation calculations

Visual representations

Automation

3 Representation of Orientation

The same shape in three different orientations

4 Exercise

Q) We have a vector that is defined as: = 4 + 3 1 𝑝𝑝⃗ What are the coordinates𝑝𝑝 𝚤𝚤̂ of𝚥𝚥̂ in coordinate frame {0}? 𝑝𝑝⃗ 𝑦𝑦0 A) 1 𝑦𝑦 = 4 cos 30 3 sin 30 0 = 4 sin 30 + 3 cos 30 0𝑝𝑝 ⋅ 𝚤𝚤̂ − cos𝑝𝑝30⋅ 𝚥𝚥̂ sin 30 4 1.964 1 = 𝑝𝑝 𝑥𝑥 sin 30 cos 30 3 4.598 − 30°

0 𝑥𝑥 5 Integrating Angular

Forces Dynamic Linear Moments Equations Angular Accelerations

Lets go over two simple examples in 2D and 3D

6 2-D Example

Outcomes of kinetics / computation: degree = = 30 s Model 𝜃𝜃2 where:𝜔𝜔1 𝜔𝜔2

𝜃𝜃1 = Initial 𝑑𝑑 Initial conditions:𝜔𝜔𝑖𝑖 𝜃𝜃𝑖𝑖 configuration 𝑑𝑑𝑑𝑑 = = 0

𝜃𝜃1 𝑡𝑡 𝜃𝜃2 𝑡𝑡 Q) What is the final configuration of Final the mechanism at t = 3 seconds? configuration 7 𝑥𝑥 3-D Example 𝑦𝑦

𝑧𝑧 𝑧𝑧 𝑧𝑧

𝑥𝑥

𝑦𝑦 𝑥𝑥 degree = = = 30 𝑦𝑦 s 𝑥𝑥 Q) at 𝜔𝜔t =𝑥𝑥 3 seconds𝜔𝜔𝑦𝑦 𝜔𝜔 which𝑧𝑧 one of the 𝑧𝑧 configurations represent the orientation of the object?

𝑦𝑦 A) None! We cant be sure! 8 Quaternion and Orientation Puzzle

Orientation

9 Background Information

10 Complex Numbers

A short review: Im

= + 𝑣𝑣 𝑏𝑏 = 1 where𝑣𝑣 𝑎𝑎 𝑏𝑏𝑏𝑏

𝑖𝑖 − Re Euler’s formula

𝑎𝑎 = cos + sin 𝑖𝑖𝑖𝑖 𝑒𝑒 𝜃𝜃 𝑖𝑖 𝜃𝜃

11 Angle-Axis

Any orientation (or a rotation operation) can be defined as a rotation about a defined axis: Euler Parameters = sin 2 𝜃𝜃 𝜖𝜖1 𝑘𝑘𝑥𝑥 𝑧𝑧 = sin Orientation can 2 visualized as point 𝑧𝑧푧 𝜃𝜃 𝜖𝜖2 𝑘𝑘𝑦𝑦 on a 4D sphere 𝜃𝜃 = sin 𝑘𝑘 2 ′ 𝜃𝜃 𝜖𝜖3 𝑘𝑘𝑧𝑧 𝑦𝑦 = cos 2 𝜃𝜃 where: 𝜖𝜖1 𝑦𝑦 ′ = 1 𝑥𝑥 𝑥𝑥 2 𝑘𝑘 = 1 2 12 � 𝜖𝜖𝑖𝑖 Quaternion and Orientation Puzzle

Orientation

Angle-Axis

13 Quaternions Theory Sir August 4, 1805, Dublin, Republic of Ireland September 2, 1865, Dublin, Republic of Ireland

14 History

Broom Bridge Dublin, Irland

+ + = = 1 2 2 2 15 𝑖𝑖 𝑗𝑗 𝑘𝑘 𝑖𝑖𝑖𝑖𝑖𝑖 − Quaternions

• Quaternions are a number system which extends the complex numbers + + +

• Quaternions are noncommutative𝑎𝑎푎 𝑏𝑏𝑏𝑏: 𝑐𝑐𝑐𝑐 𝑑𝑑𝑑𝑑

• Hamilton defined a quaternion𝐻𝐻1 as𝐻𝐻2 the≠ 𝐻𝐻quotient2𝐻𝐻1 of two directed lines in a 3D

= 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞𝑞 • The algebra of quaternions𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 is often𝑑𝑑𝑑𝑑𝑑𝑑 denoted by H (for Hamilton)

16 Quaternions

• As a set, the quaternions may be identified with • H has three operations: 4 𝐻𝐻 ℝ

• Addition

• Scalar multiplication

• Quaternion multiplication

17 Quaternions Addition

The sum of two elements of is defined to be their sum as elements of 4 𝐻𝐻 ℝ Example:

Let = + + + and = + + + , then: 𝐻𝐻1 𝑎𝑎1 𝑏𝑏1𝑖𝑖 𝑐𝑐1𝑗𝑗 𝑑𝑑1𝑘𝑘 𝐻𝐻2 𝑎𝑎2 𝑏𝑏2𝑖𝑖 𝑐𝑐2𝑗𝑗 𝑑𝑑2𝑘𝑘 + = + + + + + + +

𝐻𝐻1 𝐻𝐻2 𝑎𝑎1 𝑎𝑎2 𝑏𝑏1 𝑏𝑏2 𝑖𝑖 𝑐𝑐1 𝑐𝑐2 𝑗𝑗 𝑑𝑑1 𝑑𝑑2 𝑘𝑘

18 Quaternions Scalar Multiplication

The product of an element of by a real number is defined to be the same as the product by a scalar in 𝐻𝐻 4 ℝ Example:

Let = + + + and , then:

1 1 1 1 𝐻𝐻 𝑎𝑎 𝑏𝑏 𝑖𝑖 𝑐𝑐=𝑗𝑗 𝑑𝑑+𝑘𝑘 𝑠𝑠+∈ ℝ +

𝑠𝑠𝑠𝑠 𝑠𝑠𝑎𝑎1 𝑠𝑠𝑏𝑏1𝑖𝑖 𝑠𝑠𝑐𝑐1𝑗𝑗 𝑠𝑠𝑑𝑑1𝑘𝑘

19 Quaternion Multiplication

The identities are: = = = = 1 2 2 2 The above identities can be used𝑖𝑖 to𝑗𝑗 derive𝑘𝑘 multiplication𝑖𝑖𝑖𝑖𝑖𝑖 − of basis elements

Example:

Multiplying both sides of the above equation with yields

= = 1 = 𝑘𝑘 = 2 All the possible products𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 are:𝑖𝑖𝑖𝑖 𝑘𝑘 𝑖𝑖𝑖𝑖 − −𝑘𝑘 ⇒ 𝑖𝑖𝑖𝑖 𝑘𝑘 = = = = 𝑖𝑖𝑖𝑖 𝑘𝑘 𝑗𝑗𝑗𝑗 −𝑘𝑘 = = 𝑗𝑗𝑗𝑗 𝑖𝑖 𝑘𝑘𝑘𝑘 −𝑖𝑖 20 𝑘𝑘𝑘𝑘 𝑗𝑗 𝑖𝑖𝑖𝑖 −𝑗𝑗 Quaternion Multiplication

Let = + + + and = + + + , then:

𝐻𝐻1 𝑎𝑎1 𝑏𝑏1𝑖𝑖 𝑐𝑐1𝑗𝑗 𝑑𝑑1𝑘𝑘 𝐻𝐻2 𝑎𝑎2 𝑏𝑏2𝑖𝑖 𝑐𝑐2𝑗𝑗 𝑑𝑑2𝑘𝑘 =𝐻𝐻1𝐻𝐻2 + + + + + + + 2 + 𝑎𝑎1+𝑎𝑎2 𝑎𝑎1𝑏𝑏2𝑖𝑖 𝑎𝑎1𝑐𝑐2𝑗𝑗 𝑎𝑎1𝑑𝑑2𝑘𝑘 𝑏𝑏1𝑎𝑎2𝑖𝑖 𝑏𝑏1𝑏𝑏2𝑖𝑖 𝑏𝑏1𝑐𝑐2𝑖𝑖𝑖𝑖 𝑏𝑏1𝑑𝑑2𝑖𝑖𝑖𝑖 2 Using⋯ the𝑑𝑑 basis1𝑑𝑑2𝑘𝑘 element multiplication rules: =

𝐻𝐻1𝐻𝐻+2 𝑎𝑎1+𝑎𝑎2 − 𝑏𝑏1+𝑏𝑏2 − 𝑐𝑐1𝑐𝑐2 − 𝑑𝑑1𝑑𝑑2 + 𝑎𝑎1𝑏𝑏2 𝑏𝑏1𝑎𝑎2 + 𝑐𝑐1𝑑𝑑2 +− 𝑑𝑑1𝑐𝑐2 𝑖𝑖 + 𝑎𝑎1𝑐𝑐2 −+ 𝑏𝑏1𝑑𝑑2 𝑐𝑐1𝑎𝑎2 + 𝑑𝑑1𝑏𝑏2 𝑗𝑗 1 2 1 2 1 2 1 2 𝑎𝑎 𝑑𝑑 𝑏𝑏 𝑐𝑐 − 𝑐𝑐 𝑏𝑏 𝑑𝑑 𝑎𝑎 𝑘𝑘 21 Conjugation

Conjugation of quaternions is analogous to conjugation of complex numbers and to transposition

Let = + + + , the conjugate of is the quaternion:

𝐻𝐻 𝑎𝑎 𝑏𝑏𝑏𝑏 𝑐𝑐𝑐𝑐 𝑑𝑑𝑑𝑑 = 𝐻𝐻 ∗ Conjugation is an involution (it is𝐻𝐻 its own𝑎𝑎 − inverse)𝑏𝑏𝑏𝑏 − 𝑐𝑐𝑐𝑐 − 𝑑𝑑𝑑𝑑 = ∗ ∗ The conjugate of a product of two quaternions𝐻𝐻 is𝐻𝐻 the product of the conjugates in the reverse order = ∗ ∗ ∗ 𝐻𝐻1𝐻𝐻2 𝐻𝐻2𝐻𝐻1 22 Norm

= + + +

Scalar𝐻𝐻 part𝑎𝑎 𝑏𝑏𝑏𝑏Vector𝑐𝑐𝑐𝑐 part𝑑𝑑𝑑𝑑

The scalar part of is + /2 and the vector part of is /2 ∗ ∗ The norm of H is defined𝐻𝐻 𝐻𝐻 as:𝐻𝐻 𝐻𝐻 𝐻𝐻 − 𝐻𝐻 = ∗ 𝐻𝐻 = 𝑞𝑞 𝑞𝑞 𝛼𝛼𝛼𝛼 = 𝛼𝛼 𝐻𝐻 The unit quaternion is defined𝐻𝐻1 as:𝐻𝐻2 =𝐻𝐻1/ 𝐻𝐻2

𝑈𝑈𝐻𝐻 𝐻𝐻 𝐻𝐻 23 Reciprocal

Using conjugation and the norm makes it possible to define the reciprocal of a non-zero quaternion.

= ∗ −1 𝐻𝐻 𝐻𝐻 2 𝐻𝐻 The division between two quaternions can be defined as their multiplication by ones reciprocal:

= 𝐻𝐻1 −1 𝐻𝐻1 𝐻𝐻2 𝐻𝐻2

24 Quaternion and Orientation Puzzle

Orientation

Angle-Axis

Quaternions Theory

25 Quaternions As a definition for orientation

26 Introduction

• Notations:

• : The orientation of frame B relative to frame A 𝐴𝐴 • 𝐵𝐵𝒒𝒒� : Vector described in frame A 𝐴𝐴 Quaternion𝑟𝑟̂ as a rotation𝑟𝑟 operator / orientation:

= = cos sin sin sin 2 2 2 2 𝐴𝐴 1 2 3 4 𝜃𝜃 𝜃𝜃 𝜃𝜃 𝜃𝜃 𝐵𝐵𝒒𝒒� 𝑞𝑞 𝑞𝑞 𝑞𝑞 𝑞𝑞 −𝑟𝑟𝑥𝑥 −𝑟𝑟𝑦𝑦 −𝑟𝑟𝑧𝑧 is the conjugate of 𝐵𝐵 𝐴𝐴 𝐴𝐴𝒒𝒒� =𝐵𝐵𝒒𝒒� = 𝐴𝐴 ∗ 𝐵𝐵 𝐵𝐵𝒒𝒒� 𝐴𝐴𝒒𝒒� 𝑞𝑞1 −𝑞𝑞2 −𝑞𝑞3 −𝑞𝑞4 Compound Orientations and Mappings

A compound orientation can be defined as multiplication of two quaternions = 𝐴𝐴 𝐵𝐵 𝐴𝐴 𝐶𝐶𝒒𝒒� 𝐶𝐶𝒒𝒒�𝐵𝐵𝒒𝒒� A vector mapping using quaternions is defined as:

= where: 𝐵𝐵 𝐴𝐴 𝐴𝐴 𝐴𝐴 ∗ 𝒗𝒗 𝐵𝐵𝒒𝒒� 𝒗𝒗𝐵𝐵𝒒𝒒�

= 0 𝐴𝐴 = 𝐴𝐴 𝐴𝐴 𝐴𝐴 𝑇𝑇 0 1 2 3 𝐵𝐵𝒗𝒗 𝐵𝐵𝑣𝑣 𝐵𝐵𝑣𝑣 𝐵𝐵𝑣𝑣 𝑇𝑇 𝒗𝒗 𝑣𝑣1 𝑣𝑣2 𝑣𝑣3 Rotation matrix from quaternions

The rotation matrix based on quaternions is defined as:

2 1 + 2 2 + 2 = 2 2 2 2 1 + 2 2 + 𝑞𝑞1 − 𝑞𝑞2 𝑞𝑞2𝑞𝑞3 𝑞𝑞1𝑞𝑞4 𝑞𝑞2𝑞𝑞4 − 𝑞𝑞1𝑞𝑞3 𝐴𝐴 2 + 2 2 2 2 1 + 2 𝐵𝐵𝑹𝑹 2 3 1 4 1 3 3 4 1 2 𝑞𝑞 𝑞𝑞 − 𝑞𝑞 𝑞𝑞 𝑞𝑞 − 𝑞𝑞 𝑞𝑞2 𝑞𝑞 𝑞𝑞 𝑞𝑞 2 The z-y-x Euler angles𝑞𝑞2𝑞𝑞4 based𝑞𝑞1𝑞𝑞3 on quaternions𝑞𝑞3𝑞𝑞4 − 𝑞𝑞1 are𝑞𝑞2: 𝑞𝑞1 − 𝑞𝑞4 = 2 , 2 + 1 2 2 𝜓𝜓 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎푎= 𝑞𝑞sin2𝑞𝑞3 −2𝑞𝑞1𝑞𝑞4 + 2𝑞𝑞1 𝑞𝑞2 − −1 = 𝜃𝜃 2− 𝑞𝑞2𝑞𝑞4 , 2 𝑞𝑞1𝑞𝑞+3 1 2 2 𝜙𝜙 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎푎 𝑞𝑞3𝑞𝑞4 − 𝑞𝑞1𝑞𝑞2 𝑞𝑞1 𝑞𝑞4 − Angular and rate of change of quaternions If the in the body coordinate frame defined as:

= 0 𝑆𝑆 𝜔𝜔 𝜔𝜔𝑥𝑥 𝜔𝜔𝑦𝑦 𝜔𝜔𝑧𝑧 The quaternion derivative describing the rate of change of orientation of the earth frame relative to the body frame is defined as: 1 = 2 𝑆𝑆 𝑆𝑆 𝑆𝑆 𝐸𝐸𝒒𝒒̇ 𝐸𝐸𝒒𝒒� 𝜔𝜔 Quaternion and Orientation Puzzle

Orientation

Angle-Axis

Quaternions Theory Quaternions for Orientation

31