You are on page 1of 31

Navigation and Guidance

Dr. Shashi Ranjan Kumar

Assistant Professor
Department of Aerospace Engineering
Indian Institute of Technology Bombay
Powai, Mumbai, 400076 India

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 1 / 31


Coordinate Transformation
Computations of Euler Angles

When θ = π/2, we have some issues.


Equivalent rotation matrix
 
cos θ cos ψ cos θ sin ψ − sin θ
C =  cos ψ sin θ sin ϕ − sin ψ cos ϕ sin ψ sin θ sin ϕ + cos ψ cos ϕ cos θ sin ϕ 
cos ψ sin θ cos ϕ + sin ψ sin ϕ sin ψ sin θ cos ϕ − cos ψ sin ϕ cos θ cos ϕ
 
0 0 −1
=  cos ψ sin ϕ − sin ψ cos ϕ sin ψ sin ϕ + cos ψ cos ϕ 0 
cos ψ cos ϕ + sin ψ sin ϕ sin ψ cos ϕ − cos ψ sin ϕ 0
 
0 0 −1
=  sin(ϕ − ψ) cos(ϕ − ψ) 0 
cos(ϕ − ψ) − sin(ϕ − ψ) 0

First and third rotations are not distinguishable.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 2 / 31


Coordinate Transformation
Transformation of Angular Velocities

Similar to DCM orientation, Euler angles also vary


with time when an input angular velocity vector is
applied between the two reference frames.
Angular velocity vector ω, in body-fixed coordinate
system, has components p, q, and r in the x, y, and
z directions, respectively.
Consider each derivative of an Euler angle as the
magnitude of the angular velocity vector in the
coordinate system in which the angle is defined.
For example, ψ̇ is the magnitude of ψ̇ that lies along
the Z axis of the Earth-fixed coordinate system.
     
ψ̇x 0 −ψ̇ sin θ
ψ̇ =  ψ̇y  =C  0  =  ψ̇ cos θ sin ϕ 
ψ̇z ψ̇ ψ̇ cos θ cos ϕ

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 3 / 31


Coordinate Transformation
Transformation of Angular Velocities

Similarly, the components of θ̇ in X ′ Y ′ Z ′ are given


by (0, θ̇, 0)T .
In body frame, it can be obtained as
   
θ̇x 0
θ̇ =  θ̇y  = DB  θ̇ 
θ̇z 0
   
1 0 0 cos θ 0 − sin θ 0
=  0 cos ϕ sin ϕ   0 1 0   θ̇ 
0 − sin ϕ cos ϕ sin θ 0 cos θ 0
 
0
=  θ̇ cos ϕ 
−θ̇ sin ϕ

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 4 / 31


Coordinate Transformation
Transformation of Angular Velocities

′′ ′′ ′′
Similarly, the components of ϕ̇ in X Y Z are
given by (ψ̇, 0, 0)T .
In body frame, it can be obtained as
   
ϕ̇x ϕ̇
ϕ̇ =  ϕ̇y  = D  0 
ϕ̇z 0
  
1 0 0 ϕ̇
=  0 cos ϕ sin ϕ   0 
0 − sin ϕ cos ϕ 0
 
ϕ̇
= 0 
0

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 5 / 31


Coordinate Transformation
Transformation of Angular Velocities

Components of ω in body-fixed coordinate system is given by


ω = ψ̇ + θ̇ + ϕ̇
Now, we have
       
ωx p ψ̇x + θ̇x + ϕ̇x ϕ̇ − ψ̇ sin θ
 ωy  =  q  =  ψ̇y + θ̇y + ϕ̇y  =  ψ̇ cos θ sin ϕ + θ̇ cos ϕ 
ωz r ψ̇z + θ̇z + ϕ̇z ψ̇ cos θ cos ϕ − θ̇ sin ϕ

Euler angle rates


  q sin ϕ + r cos ϕ
 
ψ̇
 θ̇  =  cos θ 
 q cos ϕ − r sin ϕ 
ϕ̇ p + tan θ(q sin ϕ + r cos ϕ)

What happen when θ = ±90◦ ? Gimbal lock problem


How to avoid such difficulties? Nonsingular representation, e.g.,
quaternions
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 6 / 31
Coordinate Transformation
Singularity of Euler Angle Rates

For θ = π/2, p = ϕ̇ − ψ̇, q = θ̇ cos ϕ, r = −θ̇ sin ϕ


Azimuth and elevation rates
q sin ϕ + r cos ϕ θ̇ cos ϕ sin ϕ − θ̇ sin ϕ cos ϕ 0
ψ̇ = = =
cos θ cos θ 0
sin θ(q sin ϕ + r cos ϕ) 0
ϕ̇ = p + =p+
cos θ 0

Indeterminate forms!!!
Using L’Hospital rule, and the fact that d() d() dt
dθ = dt dθ , we have
d
dθ (q sin ϕ + r cos ϕ)
ψ̇|θ=π/2 = lim d(cos θ)
θ→π/2

q̇ sin ϕ + q cos ϕϕ̇ − r sin ϕϕ̇ + ṙ cos ϕ
= lim
θ→π/2 −θ̇ sin θ
q̇ sin ϕ + ṙ cos ϕ + ϕ̇θ̇
=−
θ̇
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 7 / 31
Coordinate Transformation
Singularity of Euler Angle Rates

Also, for θ = π/2, p = ϕ̇ − ψ̇

ϕ̇|θ=π/2 = p + ψ̇|θ=π/2
q̇ sin ϕ + ṙ cos ϕ + ϕ̇θ̇
= p−
θ̇

On solving this equation,


p q̇ sin ϕ + ṙ cos ϕ
ϕ̇|θ=π/2 = −
2 2θ̇

Also, θ̇ = q cos ϕ − r sin ϕ.


For θ ≈ π/2, use these limiting values, else use usual update equations.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 8 / 31


Quaternions
Quaternion: Complex Numbers

Complex numbers C = {a + bi| a, b ∈ R, i2 = −1} form a plane.


Their operations are related to two-dimensional geometry.
Any complex number has a length, given by the Pythagorean formula
p
|a + bi| = a2 + b2

We can add and subtract in C.


a + bi + c + di = (a + c) + (b + d)i

We can also multiply in C.


(a + bi)(c + di) = (ac − bd) + (ad + bc)i

What does this last formula mean? difficult to interpret


Fortunately, there is a better way to multiply complex numbers.
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 9 / 31
Quaternions
Quaternion: Complex Numbers

Geometrically, this formula says eiϕ lies


on the unit circle in C.
If we multiply eiϕ by a positive number
r, we get a complex number of length r,
reiϕ .
If we denote a + bi = r1 eiθ1 and
c + di = r2 eiθ2 then

(a + bi)(c + di) = r1 r2 ei(θ1 +θ2 )

To multiply two complex numbers,


multiply their lengths and add their
We can use complex arithmetic angles.
(multiplication) to perform a In particular, if we multiply a given
geometric operation (rotation). complex number z by eiϕ then it is
rotated by ϕ degrees.
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 10 / 31
Quaternions
Quaternions: History

The 19th century Irish mathematician and physicist William Rowan Hamilton
was fascinated by the role of C in two-dimensional geometry.
For years, he tried to invent an algebra of “triplets” to play the same role in
three dimensions.
On October 16th, 1843, while walking with his wife to a meeting of the Royal
Society of Dublin, Hamilton discovered a 4-D division algebra called the
quaternions.

Although, similar concept was developed by Gauss in 1819 (but unfortunately


not published).
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 11 / 31
Quaternions
Quaternions: History

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 12 / 31


Quaternions
Quaternions Definitions

Hamilton noticed that


 
i2 = j 2 = k2 = ijk = −1
 

The quaternions are denoted as

H = {a + bi + cj + dk : a, b, c, d ∈ R}.

Cyclic symmetry:

ij =k = −ji
jk =i = −kj
ki =j = −ik

Quaternions don’t commute.


i, j and k are recognized as unit vectors.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 13 / 31


Quaternions
Quaternions Operations

The quaternion product is the same as the cross product of vectors.

i × j =k
j × k =i
k × i =j

However, unlike the unit vectors i × i = j × j = k × k = 0, we have

i×i=−1
j×j =−1
k×k =−1
i×j×k =−1

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 14 / 31


Quaternions
Quaternions Operations

A Hamilton quaternion can be considered as scalar part and a vector part



[Q] = ⟨q0 , q⟩ = q0 + q1 i + q2 j + q3 k
| {z }
q


1, i, j, k serves as basis for quaternion vector space.


Quaternions span the space of real and imaginary numbers.
Quaternion algebra includes scalar and vector algebra.
Addition, subtraction and multiplication: Similar way as in vector algebra.
Addition:

[Q] + [S] =(q0 + q1 i + q2 j + q3 k) + (s0 + s1 i + s2 j + s3 k)


=(q0 + s0 ) + (q1 + s1 )i + (q2 + s2 )j + (q3 + s3 )k

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 15 / 31


Quaternions
Quaternion Operations

Subtraction: Addition of negative quaternion −[Q] = (−1)[Q]


[Q] − [S] =(q0 + q1 i + q2 j + q3 k) − (s0 + s1 i + s2 j + s3 k)
=(q0 − s0 ) + (q1 − s1 )i + (q2 − s2 )j + (q3 − s3 )k

Multiplication:
[Q][S] =(q0 + q1 i + q2 j + q3 k)(s0 + s1 i + s2 j + s3 k)
=(q0 s0 − q1 s1 − q2 s2 − q3 s3 ) + (q0 s1 + q1 s0 + q2 s3 − q3 s2 )i
+ (q0 s2 − q1 s3 + q2 s0 + q3 s1 )j + (q0 s3 + q1 s2 − q2 s1 + q3 s0 )k

Using dot product of vectors q.s = q1 s1 + q2 s2 + q3 s3 , we have


[Q][S] = ⟨q0 , q⟩⟨s0 , s⟩ = ⟨q0 s0 − q.s, q0 s + s0 q + q × s⟩

Product of two quaternions is still a quaternion, with scalar part (q0 s0 − qs)
and vector part (q0 s + s0 q + q × s).
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 16 / 31
Quaternions
Quaternion Operations

The set of quaternions is closed under multiplication and addition.

Example
Consider two quaternions below and find their quaternion product.

[Q] =3 + i − 2j + k
[S] =2 − i + 2j + 3k

⇒ q.s = −2, q × s = −8i − 4j.


⇒ We know that

⟨q0 , q⟩⟨s0 , s⟩ =⟨q0 s0 − q.s, q0 s + s0 q + q × s⟩


=6 − (−2) + 3(−i + 2j + 3k) + 2(i − 2j + k) + (−8i − 4j)
=8 − 9i − 2j + 11k

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 17 / 31


Quaternions
Quaternion Operations

Scalar multiplication:
λ[Q] = λq0 + λq1 i + λq2 j + λq3 k

Conjugate:
[Q]⋆ = q0 − q = q0 − q1 i − q2 j − q3 k

We have the following relations


([Q]⋆ )⋆ =q0 − (−q) = [Q]
[Q] + [Q]⋆ =2q0
[Q]⋆ [Q] =(q0 + q)(q0 − q)
=q0 q0 − (−q).q + q0 q + (−q)q0 + (−q × q)
=q02 + q.q
=q02 + q12 + q22 + q32 = [Q][Q]⋆
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 18 / 31
Quaternions
Quaternion Operations

Norm of Length of quaternion:


N ([Q]) =[Q][Q]⋆ = [Q]⋆ [Q] = (q0 + q)(q0 − q)
= q02 + q.q = q02 + q12 + q22 + q32

For two quaternions [Q] and [S], we have


([Q][S])⋆ = [S]⋆ [Q]⋆
⇒ Proof:

([Q][S])⋆ = [(q0 + q) (s0 + s)]

= (q0 s0 − q.s + q0 s + s0 q + q × s)
= (q0 s0 − q.s − q0 s − s0 q − q × s)

[S]⋆ [Q]⋆ = (s0 − s) (q0 − q)


=q0 s0 − (−s).(−q) + q0 (−s) + s0 (−q) + (−s) × (−q)
= (q0 s0 − q.s − q0 s − s0 q − q × s) = ([Q][S])⋆
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 19 / 31
Quaternions
Quaternion Operations

Norm of product of two quaternions is equal to product of their norms.

N ([Q][S]) = N ([Q])N ([S])

⇒ Proof:

N ([Q][S]) = ([Q][S])([Q][S])⋆
= [Q][S][S]⋆ [Q]⋆
= [Q]N ([S])[Q]⋆
= N ([Q])N ([S])

Also, by using mathematical induction, one may write

N ([Q1 ][Q2 ] . . . [Qn ]) = N ([Q1 ])N ([Q2 ]) . . . N ([Qn ])

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 20 / 31


Quaternions
Quaternion Operations

Inverse of quaternion: If [Q] ̸= 0 then its inverse is defined by

[Q][Q]−1 = [Q]−1 [Q] = 1

[Q]⋆
Using norm concept, [Q]−1 = , N (Q) ̸= 0. Does it make sense?
N (Q)

[Q][Q]⋆
[Q][Q]−1 = [Q]−1 [Q] = =1
N (Q)

If [Q] is unit quaternion then

[Q]⋆
[Q]−1 = = [Q]⋆
N (Q)

Inverse and conjugate for the unit quaternions are the same.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 21 / 31


Quaternions
Quaternion Operations

Identities:
How to define zero and unit quaternions?
A zero quaternion is quaternion with zero scalar and zero vector.
A unit quaternion is defined as any quaternion whose norm is 1.

[0] = 0 + 0i + 0j + 0k, [1] = 1 + 0i + 0j + 0k

Unlike direction cosine matrix, where six redundancies are present, the
quaternion has only one.
For unit quaternion,

q02 + q12 + q22 + q32 = 1


p
q02 + q12 + q22 + q32 can be used for normalizing factor for each parameter.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 22 / 31


Quaternions
Quaternion Operations

How to identify if two quaternions are equal?


Equality of quaternions: Two quaternions are equal if both their scalars as
well as their vectors are equal.
[Q] =[S]
⇒ q0 =s0 , q1 = s1 , q2 = s2 , q3 = s3
⇒ [Q]i =[S]i ∀ i = 0, 1, 2, 3
Can we express 3D vector as quaternion?
Any three dimensional vector can be expressed as quaternion with zero scalar.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 23 / 31


Quaternions
Quaternion Operations

Quaternions obey the associative and commutative laws of addition, and the
associative and distributive laws of multiplication.
For three quaternions, Q1 , Q2 , Q3
□ Associative addition

(Q1 + Q2 ) + Q3 =Q1 + (Q2 + Q3 )

□ Commutative addition

Q1 + Q2 = Q2 + Q1

□ Associative multiplication

(Q1 Q2 )Q3 = Q1 (Q2 Q3 )

□ Distributive multiplication

Q1 (Q2 + Q3 ) = Q1 Q2 + Q1 Q3

Is the multiplication of quaternions commutative?


Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 24 / 31
Quaternions
Quaternion Operations

Pure quaternions: Quaternion with zero real or scalar part


Any vector in R3 is a pure quaternion.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 25 / 31


Quaternions
Quaternion Rotation Operator

How quaternion [Q] ∈ R4 operate on a vector in R3 ?


Define quaternion operator with unit quaternion [Q] as
LQ (v) =[Q]v[Q]⋆ = (q02 − ∥q∥2 )v + 2(q.v)q + 2q0 (q × v)
⇒ Proof:
LQ (v) =[Q]v[Q]⋆ = (q0 + q)(0 + v)(q0 − q)
=(q0 + q)(v.q + {q0 v − v × q})
=q0 (v.q) − q.{q0 v − v × q} + (v.q)q + q0 {q0 v − v × q}
+ q × {q0 v − v × q}
=q.{v × q} + (v.q)q + q0 {q0 v − v × q} + q × {q0 v − v × q}
=(v.q)q + q02 v + 2q0 {q × v} + q × {q × v}
=(v.q)q + q02 v + 2q0 {q × v} + q(q.v) − v(q.q)
=(q02 − ∥q∥2 )v + 2(q.v)q + 2q0 {q × v}

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 26 / 31


Quaternions
Quaternion Rotation Operator

Operation of Unit Quaternion on Vector


This operator LQ does not change the length of the vector v.

∥LQ (v)∥ =∥[Q]v[Q]⋆ ∥ = |[Q]|∥v∥|[Q]⋆ | = ∥v∥

The direction of v, if along q (say v = kq), is left unchanged by the operator LQ .

[Q]v[Q]⋆ =[Q](kq)[Q]⋆ = (q02 − |q|2 )(kq) + 2(q.(kq))q + 2q0 (q × (kq))


=k(q02 + ∥q∥2 )q = kq

Any vector along q is thus not changed under operator LQ . This makes us
guess that the operator LQ acts like a rotation about q.
The operator LQ is linear over R3 . For any two vectors v 1 , v 2 ∈ R3 and any
a1 , a2 ∈ R

LQ (a1 v 1 + a2 v 2 ) = a1 LQ (v 1 ) + a2 LQ (v 2 ).

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 27 / 31


Quaternions
Quaternion Rotation Operator

Rotation of Vector using Quaternion


For any unit quaternion
θ θ
[Q] = q0 + q = cos + q̂ sin
2 2
and for any vector v ∈ R3 , the action of the operator LQ (v) = [Q]v[Q]⋆ on v is
equivalent to a rotation of the vector through an angle θ, about q̂ as the axis of
rotation.

A vector v ∈ R3 , we decompose it as v = a + n, where a is the component


along the vector q and n is the component normal to q.
Under the operator LQ , a is invariant, while n is rotated about q through an
angle θ.
Since the operator is linear, the image [Q]v[Q]⋆ is indeed interpreted as a
rotation of v about q through an angle θ.

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 28 / 31


Quaternions
Quaternion Rotation Operator

The operator Lq on vectors n

LQ (n) =(q02 − ∥q∥2 )n + 2(q.n)q + 2q0 (q × n)


=(q02 − ∥q∥2 )n + 2q0 (q × n)
=(q02 − ∥q∥2 )n + 2q0 ∥q∥(q̂ × n)

Denote n⊥ = q̂ × n. Now,

LQ (n) =(q02 − ∥q∥2 )n + 2q0 ∥q∥n⊥


 
2 θ 2 θ θ θ
= cos − sin n + 2 sin cos n⊥
2 2 2 2
= cos θn + sin θn⊥

Resulting vector is a rotation of n through an angle θ in the plane defined by


n and n⊥ .

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 29 / 31


Quaternions
Quaternion Rotation Operator

L−[Q] = [−Q]v[−Q]⋆ = [Q]v[Q]⋆ How?


Negative quaternion −[Q]
2π + θ 2π + θ
−[Q] = cos + q̂ sin
2 2
It represents the rotation about the same axis through the angle 2π + θ,
essentially the same rotation.
Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 30 / 31
Quaternions

Reference
1 George M. Siouris, Aerospace Avionics Systems: A Modern Synthesis,
Academic Press, Inc. 1993.
2 Bandhu N. Pamadi, Performance, Stability, and Control of Airplanes, AIAA
Education Series, 1998.

Thank you for your attention !!!

Dr. Shashi Ranjan Kumar IITB-AE 410/641 Quaternions 31 / 31

You might also like