Quat Dynamics

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Quaternions And Dynamics

arXiv:0811.2889v1 [math.DS] 18 Nov 2008

Basile Graf
[email protected]
February, 2007

Abstract
We give a simple and self contained introduction to quaternions and their prac-
tical usage in dynamics. The rigid body dynamics are presented in full details.
In the appendix, some more exotic relations are given that allow to write more
complex models, for instance, the one of a satellite with inertial wheels and
expressed in a non-inertial reference frame. As it is well known, one nice ad-
vantage of quaternions over Euler angles, beside the usual arguments, is that it
allows to write down quite complex dynamics completely by hand.
Contents
1 Quaternions 3
1.1 Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Notations and Definitions . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Quaternion Product . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Quaternions and Spatial Rotations . . . . . . . . . . . . . . . . . 4
1.5 Quaternions and Rotation Velocity . . . . . . . . . . . . . . . . . 6
1.5.1 Rotation Velocity in Fixed Reference Frame ω . . . . . . 7
1.5.2 Rotation Velocity in Body Reference Frame ω ′ . . . . . . 7
1.5.3 Matrix-Product Notation for ω . . . . . . . . . . . . . . . 8
1.5.4 Matrix-Product Notation for ω ′ . . . . . . . . . . . . . . . 8
1.5.5 Rotation Matrix R . . . . . . . . . . . . . . . . . . . . . . 9
1.5.6 Ep and Gp . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5.7 One Last Relation . . . . . . . . . . . . . . . . . . . . . . 10
1.5.8 Relations Summary . . . . . . . . . . . . . . . . . . . . . 11
1.6 Rigid Body Rotational Dynamics . . . . . . . . . . . . . . . . . . 11
1.6.1 Derivatives of L . . . . . . . . . . . . . . . . . . . . . . . 12
1.6.2 Generalized Forces . . . . . . . . . . . . . . . . . . . . . . 13
1.6.3 Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

A Derivatives and Quaternions 15


A.1 Quadratic Form Derivative by a Quaternion . . . . . . . . . . . . 15
A.1.1 ”Single R” Quadratic Form . . . . . . . . . . . . . . . . . 15
A.1.2 ”Double R” Quadratic Form . . . . . . . . . . . . . . . . . 16
A.1.3 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
A.2 Time Derivative of R . . . . . . . . . . . . . . . . . . . . . . . . . 17

B Speed Composition 18

C Euler Angles to Quaternions 20

2
1 Quaternions
1.1 Fundamentals
Relation (1), together with associativity and distributivity is all what we will
use to derive the basic practical applications for quaternions.

i2 = j 2 = k 2 = ijk = −1 (1)
By left- and right-multiplication in the above equation, we can write

i ijk = −jk = −i
ijk k = −ij = −k
j jk = −k = ji ij j = −i = kj
i ij = −j = ik ji i = −j = −ki
This shows the product is non commutative and gives the basic multiplication
rules:

ij = k ji = −k
jk = i kj = −i (2)
ki = j ik = −j

1.2 Notations and Definitions


A quaternion q is a set of four parameters, a real value q0 and three imaginary
values q1 i, q2 j, q3 k with q1 , q2 , q3 ∈ R; it may be written

q = q0 + q1 i + q2 j + q3 k.
However, this notation proves itself to be very unpractical. We will therefore
use two different notations:

• The quaternion q as apair of real value


 and vectorial imaginary value
q = (q0 , ~
q) Re q = q0 ~ q = ~q = (q1 q2 q3 )T
Im
• A column vector of four parameters
q = (q0 q1 q2 q3 )T

The conjugate q̄ of q is defined as

q̄ = (q0 , −~q)
and it’s norm (a nonnegative real value) as
q
|q| = |q| = q02 + q12 + q22 + q32 .
The product of two quaternions written as pairs, as described in the next
section will be noted with ◦.

3
1.3 Quaternion Product
From the rules given in (2), we may write the product of q with p.

(q0 + q1 i + q2 j + q3 k)(p0 + p1 i + p2 j + p3 k) =

p0 q0 + q0 p1 i + q0 p2 j + q0 p3 k
+ q1 p0 i + q1 p1 ii + q1 p2 ij + q1 p3 ik
+ q2 p0 j + q2 p1 ji + q2 p2 jj + q2 p3 jk
+ q3 p0 k + q3 p1 ki + q3 p2 kj + q3 p3 kk =
p0 q0 − q1 p1 − q2 p2 − q3 p3
+ (q1 p0 + q0 p1 + q2 p3 − q3 p2 ) i
+ (q2 p0 + q0 p2 + q3 p1 − q1 p3 ) j
+ (q3 p0 + q0 p3 + q1 p2 − q2 p1 ) k

q ◦ p = (p0 q0 − p~ · ~q, q0 p~ + p0 ~q + ~q × p~). (3)

From (3) it turns out that

q ◦ q̄ = q̄ ◦ q = (|q|2 , ~0) = |q|2 (4)


and if q is normed (|q| = 1)

q ◦ q̄ = q̄ ◦ q = (1, ~0) = Id. (5)


In (3) we also see that

q ◦ p = p̄ ◦ q̄ (6)
that is

|q ◦ p|2 = (q ◦ p) ◦ (q ◦ p) = q ◦ p ◦ p̄ ◦q̄ = |p|2 (q ◦ q̄) = |q|2 |p|2


|{z}
|p|2

|q ◦ p| = |q||p|. (7)

1.4 Quaternions and Spatial Rotations


First, note the following relations

(~u × ~v ) × w
~ = (~u · w)~
~ v − (~v · w)~
~ u
ϕ 1 − cos ϕ ϕ 1 + cos ϕ
sin2 = cos2 = .
2 2 2 2
From now on, q will generally represent a normed quaternion (|q| = 1)
involved in a rotation. Let’s now place a vector ~x ∈ R3 in the imaginary part
of a quaternion x and see what happens with it in the following relation

4
x′ = q̄ ◦ x ◦ q x = (0, ~x) q = (q0 , ~q).
Using (3)

x′ = (~q · ~x, q0 ~x − ~q × ~x) ◦ q


= ((~
q · ~x)q0 − (q0 ~x − ~
q × ~x) · ~q, (~q · ~x)~q + q0 (q0 ~x − ~q × ~x) + (q0 ~x − ~q × ~x) × ~q)
| {z } | {z }
Re{x′ } ~
Im{x ′}


Re x′ = (~
q · ~x)q0 − q0 (~x · ~q) − (~q × ~x) · ~q = 0
⇒ x′ = (0, ~x′ ),
 ′
~ x = ~x′
Im
= (~ q + q02 ~x − q0 (~q × ~x) + q0 (~x × ~q) − (~q × ~x) × ~q
q · ~x)~
= (~ q + q02 ~x + 2q0 (~x × ~q) − (~q × ~x) × ~q
q · ~x)~
= (~ q + q02 ~x + 2q0 (~x × ~q) − (~q · ~q)~x + (~x · ~q)~q
q · ~x)~
= 2(~ q + q02 ~x + 2q0 (~x × ~q) − (~q · ~q)~x.
q · ~x)~
p
A valid normed quaternion (|q| = (q02 + q12 + q22 + q32 ) = 1) would be
ϕ ϕ
q = (q0 , ~
q ) = (cos , sin ~n) |~n| = 1.
2 2
In this case, ~x′ becomes

ϕ ϕ ϕ ϕ ϕ
~x′ = 2 sin2 (~n · ~x)~n + cos2 ~x + 2 cos sin (~x × ~n) − sin2 ~x
2 2 2 2 2
= (1 − cos ϕ)(~n · ~x)~n + cos ϕ ~x + sin ϕ (~x × ~n).
This last relation is the formula for a rotation by an angle ϕ around a normed
axis vector ~n, as can be shown with the following figure as follows:

~v3
~v2
· ~n)~n ϕ
(~x
~x′ ~v1
~n
~x
0

5
~v2 = cos ϕ ~v1 + sin ϕ ~v3
~v1 = ~x − (~x · ~n)~n
~v3 = ~v1 × ~n
= (~x − (~x · ~n)~n) × ~n
= (~x × ~n) − (~x · ~n) ~n × ~n}
| {z
~0

⇒ ~v2 = cos ϕ (~x − (~x · ~n)~n) + sin ϕ (~x × ~n)

~x′ = (~x · ~n)~n + ~v2


= (~x · ~n)~n + cos ϕ (~x − (~x · ~n)~n) + sin ϕ (~x × ~n)
= (1 − cos ϕ)(~n · ~x)~n + cos ϕ ~x + sin ϕ (~x × ~n).

Moreover

x′ = q̄ ◦ x ◦ q
q ◦ x′ ◦ q̄ = q ◦ q̄ ◦x ◦ q ◦ q̄ .
|{z} |{z}
(1,~0) (1,~0)

Thus we have the relations for the rotation and its inverse

x′ = q̄ ◦ x ◦ q x = q ◦ x′ ◦ q̄ . (8)

1.5 Quaternions and Rotation Velocity


We will now derive the relation between the rotational velocity vector and the
quaternion time derivative. ~x′ is any constant vector within the body (rotating)
reference frame and ~x is the same vector in the fixed reference frame. As seen
before, both vectors can be put in relation with

x = q ◦ x′ ◦ q̄ x′ = q̄ ◦ x ◦ q.
Applying the time derivative to x = (0, ~x), with x′ = (0, ~x′ ) and ~x˙ ′ = ~0, we
get

ẋ = q̇ ◦ x′ ◦ q̄ + q ◦ x′ ◦ q̄˙
ẋ = q̇ ◦ q̄ ◦ x ◦ q ◦ q̄ + q ◦ q̄ ◦x ◦ q ◦ q̄˙
|{z} |{z}
Id Id

ẋ = q̇ ◦ q̄ ◦ x + x ◦ q ◦ q̄˙ (9)
and from (3)

6
q̇ ◦ q̄ = (q˙0 q0 + ~q˙ · ~q, −q˙0 ~q + q0 ~q˙ − ~q˙ × ~q)
| {z }


 = q0 q˙0 + q1 q˙1 + q2 q˙2 + q3 q˙3 = q · q̇ = 0


because |q| = 1. That is

q̇ ◦ q̄ = (0, ~ν ) and similarly ~


q̄ ◦ q̇ = (0, −ν). (10)

1.5.1 Rotation Velocity in Fixed Reference Frame ω


From (9) and (10) and using (3) we have

~
ẋ = (0, ~ν ) ◦ x − x ◦ (0, −ν)
~x˙ = ~ν × ~x − ~x × ~ν = 2~ν × ~x
and from (7)
|~x˙ | = |2~ν ||~x| ⇒ ~ν ⊥~x
If ~x undergoes a pure rotation, we know that

~x˙ = ~ω × ~x and ~ω ⊥~x


thus

ω = (0, ~ω) = 2(0, ~ν ) = 2q̇ ◦ q̄ . (11)


And right-multiplication by q

ω ◦ q = 2q̇ ◦ q̄ ◦ q ⇒ ω ◦ q = 2q̇
|{z}
Id

q̇ = 21 ω ◦ q . (12)

1.5.2 Rotation Velocity in Body Reference Frame ω ′

ω ′ = q̄ ◦ ω ◦ q with ω = 2q̇ ◦ q̄

⇒ ω = 2q̄ ◦ q̇ ◦ q̄ ◦ q
|{z}
Id

ω ′ = 2q̄ ◦ q̇ . (13)
And left-multiplication by q

q ◦ ω ′ = 2 q ◦ q̄ ◦q̇ = 2q̇
|{z}
Id
1
q̇ = 2q ◦ ω′ . (14)

7
1.5.3 Matrix-Product Notation for ω
From

ω = 2q̇ ◦ q̄
and using (3)


~ 2q̇ ◦ q̄
ω = Im
~ = 2(−q˙0 ~q+q0 ~q˙−~q˙ × ~q)
 
  q˙0
−q1 q0 −q3 q2  q˙1 
= 2  −q2 q3 q0 −q1    q˙2


−q3 −q2 q1 q0
| {z } q˙3
E

~ω = 2E q̇.
Changing the sign and inverting the cross product allows to make an other
identification

ω = −2(−q0 ~q˙ + q˙0 ~q − ~q × ~q˙)


~

~ = −2Ėq.
ω
So the rotation velocity vector in the fixed reference frame can be written as

~ω = 2E q̇ = −2Ėq . (15)
And from
1
q̇ = ω◦q ω = (0, ~ω) ⇒ ω0 = 0
2
one can similarly find
 
1 (−~ω · ~q) 1
q̇ = = E T ~ω
2 (q0 ω
~ + ~ω × ~q) 2

q̇ = 21 E T ~ω . (16)

1.5.4 Matrix-Product Notation for ω ′


From

ω ′ = 2q̄ ◦ q̇
and using (3)

8

ω~′ = Im
~ 2q̄ ◦ q̇ = 2(q0 ~q˙−q˙0 ~q−~q × ~q˙)
 
  q˙0
−q1 q0 q3 −q2  q˙1 
= 2  −q2 −q3 q0 q1   
 q˙2 
−q3 q2 −q1 q0
| {z } q˙3
G

ω~′ = 2Gq̇.
Changing the sign and inverting the cross product allows to make an other
identification

ω~′ = −2(q˙0 ~q − q0 ~q˙ − ~q˙ × ~q)

ω~′ = −2Ġq.
So the rotation velocity vector in the body reference frame can be written as

ω~′ = 2Gq̇ = −2Ġq . (17)


And from
1
q̇ = q ◦ ω′ ω ′ = (0, ω~′ ) ⇒ ω0′ = 0
2
one can similarly find
 
1 (−~q · ω~′ ) 1
q̇ = = GT ω~′
2 (q0 ω~′ + ~q × ω~′ ) 2

q̇ = 12 GT ω~′ . (18)

1.5.5 Rotation Matrix R


We already have

ω = 2E q̇ = −2Ėq
~ ω~′ = 2Gq̇ = −2Ġq
1 1
q̇ = E T ~
ω q̇ = GT ω~′
2 2
So we can write

ω = 2E q̇
~ ω~′ = 2Gq̇
1 1
= 2E( E T ~
ω) = 2G( GT ω~′ )
2 2
= EE T ~ω = GGT ω~′
⇒ EE T = Id . ⇒ GGT = Id .

9
And by mixing both sides

1
ω~′ = 2Gq̇ = 2G( E T ~ω) = GE T ~ω
2
1 T ~′
ω = 2E q̇ = 2E( G ω ) = EGT ω~′ .
~
2
We shall now remember that ~ω is a vector in the fixed reference frame and
~ ′ is the same vector in the body reference frame, that is ~ω = Rω~′ . By
that ω
comparing with the previous two results, we find

R = EGT and R−1 = RT = GE T . (19)

1.5.6 Ep and Gp
From the identifications made in sections 1.5.3 and 1.5.4, we can see that the
general meaning the product of E and G with any quaternion p is
 
~ p ◦ q̄
Ep = Im ~ q̄ ◦ p .
Gp = Im (20)
And from

q ◦ q̄ = q̄ ◦ q = (|q|, ~0) = (1, ~0)


it follows

Eq = ~0 Gq = ~0 .

1.5.7 One Last Relation


For any ~v and due to associativity

(0, ω~′ ) ◦(0, ~v) = (−ω~′ · ~v , ω~′ × ~v )


| {z }
2q̄◦q̇

= 2q̄ ◦ q̇ ◦ v
= 2(q0 q˙0 +~ q˙, q0 ~q˙−q˙0 ~q−~q × ~q˙) ◦ v = 2q̄ ◦ (q˙0 v0 −~q˙ · ~v , q˙0~v +v0 ~q˙+~q˙ × ~v )
q·~
   
q0 q1 q2 q3 q˙0 −q ˙ 1 −q ˙ 2 −q ˙3 0
˙
  q˙1 q˙0 −q3 q˙2   v1 
 −q1 q0 q3 −q2    
≡ 2 ˙
 −q2 −q3 q0 q1   q˙2 q˙3 q˙0 −q1   v2 
−q3 q2 −q1 q0 ˙
q˙3 −q2 q˙1 q˙0 v3
 T     
q 0 ~ ′
−ω · ~v
=2 q̇ ĠT =
G ~v ω~′ × ~v
⇒ 2GĠT ~v = Ω′~v = ω~′ × ~v .

10
Comparing with (17), we conclude that

Ω′ = 2GĠT = −2ĠGT and Ω′~v = ω~′ × ~v . (21)

1.5.8 Relations Summary


The following table summaries the developed relations. q is always a normed
quaternion, that is q02 + q12 + q22 + q32 = 1.

Quaternion notation Matrix notation


Fixed ref Body ref Fixed ref Body ref
~x = R~x′ ~x′ = RT ~x
x = q ◦ x′ ◦ q̄ x′ = q̄ ◦ x ◦ q
R = EGT RT = R−1 = GE T

ω = (0, ~
ω) = 2q̇◦ q̄ ω ′ = (0, ~ω ′ ) = 2q̄ ◦ q̇ ~ω = 2E q̇ = −2Ėq ~ω ′ = 2Gq̇ = −2Ġq

q̇ = 12 ω ◦ q q̇ = 21 q ◦ ω ′ q̇ = 12 E T ~ω q̇ = 21 GT ~ω ′

EE T = Id GGT = Id

q ◦ q̄ = q̄ ◦ q = (|q|, ~0) Eq = ~0 Gq = ~0

Ω′ = 2GĠT
(0, ~ω ) ◦ (0, ~v ) =
= −2ĠGT
(−ω~′ · ~v , ω~′ × ~v )
Ω ~v = ω~′ × ~v

   
−q1 q0 −q3 q2 −q1 q0 q3 −q2
E =  −q2 q3 q0 −q1  G =  −q2 −q3 q0 q1 
−q3 −q2 q1 q0 −q3 q2 −q1 q0

1.6 Rigid Body Rotational Dynamics


We now will have a look at the dynamics of a freely rotating rigid body to which
a momentum T~ ′ is applied. Translation of the body will not be discussed (it
can be decoupled from the dynamics of rotation and is fairly easy). We will
also consider a potential free system, so that the Lagrangian resumes to the
rotational kinetic energy only
1 ′T ′
L = Erot = ~ω J~ω . (22)
2
Using the quaternion q as coordinates and with the constraint C = qT q = 1,
Lagrangian dynamics gives

11
d ∂L ∂L ∂C
− = Fq + λ . (23)
dt ∂ q̇ ∂q ∂q
Fq is the 4-vector of generalized forces which will be expressed in term of
applied torque later. λ is the Lagrangian multiplier used to satisfy the constraint
C.

1.6.1 Derivatives of L
Note the following reminder

∂Ax = A
∂x
∂aT x = ∂xT a = a
∂x ∂x
∂xT Ax = (AT + A)x if A=A T
= 2Ax
∂x
(written as column vectors)

(AB)T = B T AT .

We will now derive each term of the left side of (23). First, let us rewrite L
in two different ways
1 ′T ′
L= ω J~
~ ω = 2(Gq̇)T J(Gq̇) = 2(Ġq)T J(Ġq)
2
and grouping around J
1 ′T ′
L= ω = 2q̇T (GT JG)q̇ = 2qT (ĠT J Ġ)q.
ω J~
~
2
Because J is symmetric, (GT JG) and (ĠT J Ġ) are also symmetric. So we
have
∂L
= 4ĠT J Ġq = 2ĠT J (2Ġq) = −2ĠT J~ω ′ , (24)
∂q | {z }
−~
ω′

∂L
= 4GT JGq̇ = 2GT J (2Gq̇) = 2GT J~ω ′
∂ q̇ | {z }
ω
~′

and
d ∂L d
= (2GT J~ω ′ ) = 2ĠT J~ω ′ + 2GT J ~ω˙ ′ . (25)
dt ∂ q̇ dt

12
1.6.2 Generalized Forces
A way to find the generalized force Fc relative to the coordinates c is to identify
it in

δW = Fc · δc.
(A simple example is the case of a pure translation δ~x of a particle, on which
a force F~ is applied. The work is then δW = F~x · δ~x = F~ · δ~x. So the generalized
force F~x is simply F~ in this case.)

For a rotation of a rigid body by an angle δϕ around an axis ~n with an


applied torque T~ ′ , the work can be written as

δW = (~n · T~ ′ )δϕ |~n| = 1. (26)


This small attitude change can be represented on one side as a small variation
δq of the coordinate quaternion q and, on the other side, as a rotation quaternion
qδ operating from the current attitude represented by q (i.e. a composition).
That is

q + δq = q ◦ qδ
|q| = 1 |qδ | = 1 |δq| ≪ 1.

We do not need to consider the fact that the variation δq has to preserve the
norm of q, because it will automatically be satisfied by introducing a constraint
in the Lagrange formulation.

On one side we can write

q + δq = q ◦ qδ
q̄ ◦ q +q̄ ◦ δq = q̄ ◦ q ◦qδ
|{z} |{z}
(1,~0) (1,~0)
| {z }

⇒ qδ = (1, ~0) + q̄ ◦ δq. (27)


On the other side
δϕ δϕ
qδ = (cos , sin ~n).
2 2
Looking at the imaginary part

~ q̄ ◦ δq = sin δϕ ~n ≈ δϕ ~n
 
~ qδ = Im
Im
2 2

13
comparing with (26)

~ q̄ ◦ δq · T~ ′
⇒ δW = 2 Im
and from (20)


~ q̄ ◦ δq = Gδq
Im
⇒ δW = 2(Gδq) · T~ ′ = 2T~ ′T (Gδq) = 2(GT T~ ′ )T δq = 2(GT T~ ′ ) ·δq
| {z }
Fq

⇒ Fq = 2GT T~ ′ . (28)

1.6.3 Dynamics
We have now everything to write the dynamics

d ∂L ∂L ∂C
− = Fq + λ
dt ∂ q̇ ∂q ∂q
T ′ T ˙′ T ~′
4Ġ J~ω + 2G J ~ω = 2G T + λq.

Left-multiplying by G

4G ω ′ + 2 |GG
ĠT} J~ T ˙′ T ~′
| {z {z } J ~ω = 2 |GG
{z } T + λ |{z}
Gq
2Ω′ Id Id ~0
′ ′
Ω J~ω + J ~ω = T ˙′ ~′
~ ′ × J~ω ′ + J ~ω˙ ′ = T~ ′
ω
J ~ω˙ ′ = T~ ′ − ω
~ ′ × J~ω ′ .

This last relation is nothing else than the Euler equation of motion for ro-
tating body. Together with (18) we obtain the complete dynamics

~˙ ′
ω = J −1 T~ ′ − J −1 (~ω ′ × J~ω ′ )
(29)
1 T ′
q̇ = 2G ~
ω.

14
A Derivatives and Quaternions
A.1 Quadratic Form Derivative by a Quaternion
In order to be able to derive the Lagrangian by the components of q for a
non-inertial quaternion model, one needs to perform things like

∂(~v T Rw)
~ ∂(~v T RT w)
~
,
∂q ∂q
and also

∂(~uT RJRT ~u)


.
∂q
But because R = EGT and
   
−q1 q0 −q3 q2 −q1 q0 q3 −q2
E =  −q2 q3 q0 −q1  G =  −q2 −q3 q0 q1 
−q3 −q2 q1 q0 −q3 q2 −q1 q0
the matrix of the quadratic form to be derived is not constant in q. This
implies that these operations are no more trivial. However, thanks to the partic-
ular form of the dependance of R in the components of q, higher order tensors
can be avoided, as shown in the following.

A.1.1 ”Single R” Quadratic Form


By computing the quadratic form and taking the partial derivatives we get
(placing them in a column vector)
 
∂(~v T Rw)
~ ∂(~v T Rw)
~
= =
∂q ∂qi i
0 1
w1 v1 q0 + w1 v2 q3 − w1 v3 q2 − w2 v1 q3 + w2 v2 q0 + w2 v3 q1 + w3 v1 q2 − w3 v2 q1 + w3 v3 q0
B C
B w1 v1 q1 + w1 v2 q2 + w1 v3 q3 + w2 v1 q2 − w2 v2 q1 + w2 v3 q0 + w3 v1 q3 − w3 v2 q0 − w3 v3 q1 C
B C
2B C.
B −w1 v1 q2 + w1 v2 q1 − w1 v3 q0 + w2 v1 q1 + w2 v2 q2 + w2 v3 q3 + w3 v1 q0 + w3 v2 q3 − w3 v3 q2 C
@ A
−w1 v1 q3 + w1 v2 q0 + w1 v3 q1 − w2 v1 q0 − w2 v2 q3 + w2 v3 q2 + w3 v1 q1 + w3 v2 q2 + w3 v3 q3

The vector obtained is quite ugly but one can see that it is linear in q, it
can thus be rewritten in a matrix-vector product:
0 10 1
v1 w1 + v2 w2 + v3 w3 v3 w2 − v2 w3 −v3 w1 + v1 w3 v2 w1 − v1 w2 q0
B CB C
B
B v3 w2 − v2 w3 v1 w1 − v2 w2 − v3 w3 v1 w2 + v2 w1 v1 w3 + v3 w1 C B q1
CB
C
C
2B CB C
B −v3 w1 + v1 w3 v1 w2 + v2 w1 v2 w2 − v1 w1 − v3 w3 v2 w3 + v3 w2 C B q2 C
@ A@ A
v2 w1 − v1 w2 v1 w3 + v3 w1 v2 w3 + v3 w2 v3 w3 − v1 w1 − v2 w2 q3
| {z }
∆[~v , w]
~

15
By careful inspection of ∆[~v , w],
~ we can identify a structure in the matrix
that allows a compact notation
 
w~ · ~v (w~ × ~v )T
∆[~v , w]
~ = . (30)
~ × ~v w~
w ~ v T + ~v w
~T − w ~ · ~v I3
That is

∂(~v T Rw)
~
= 2∆[~v , w]q
~ (31)
∂q
And because ~v T RT w ~ T R~v we also have
~ =w

∂(~v T RT w)
~
= 2∆[w,
~ ~v ]q (32)
∂q

A.1.2 ”Double R” Quadratic Form


We are now interested in the derivative of a quadratic form involving RJRT ,
that is, with the q dependent matrix R appearing twice. J is an inertia matrix,
therefore, J = J T . This time, the vectors on the left ant on the right are the
same, lets say ~u.

   
1 ∂ T T
 1 T ∂R T 1 T ∂RT
~u RJR ~u = ~u JR ~u + ~u RJ ~u
2 ∂q 2 ∂qi 2 ∂qi
  i i
∂R
= ~uT JRT ~u .
∂qi i

Hence
1 ∂ 
~uT RJRT ~u = 2∆[~u, JRT ~u]q (33)
2 ∂q

A.1.3 Properties
By looking at (30), one may note the following relations

∆[~v1 + ~v2 , w]
~ = ∆[~v1 , w]
~ + ∆[~v2 , w]
~ (34)

∆[~v , w
~1 + w
~ 2 ] = ∆[~v , w
~ 1 ] + ∆[~v , w
~ 2] (35)
 
n
X m
X n X
X m
∆ ~vi , ~j =
w ∆[~vi , w
~j] (36)
i=1 j=1 i=1 j=1

∆[α~v , β w]
~ = αβ∆[~v , w]
~ (37)

16
A.2 Time Derivative of R
First note that by identification, one can verify that

GT G = E T E = I4 − qqT (38)

with I4 the identity matrix in R4 . Remember also

Ω′ = 2GĠT = −2ĠGT with Ω′~v = ~ω ′ × ~v

and
~ ′ = 2Gq̇ = −2Ġq.
ω
Now observe

Ω′ RT = 2GĠT GE T
= −2ĠGT GE T
= −2Ġ(I4 − qqT )E T
= −2ĠE T − 2Ġq qT E T
| {z }
(Eq)T =~0
T T
= −2ĠE = −Ṙ .

We can finally write

ṘT = −Ω′ RT (39)


Ṙ = −RΩ′T = RΩ′ . (40)

17
B Speed Composition
Let be three referentials each designed by 0, 1 and 2. Referential 0 is inertial,
referential 1 is a rotating one and 2 is a body fixed referential.
The same vector ~x can be expressed in any of these referentials; when expressed
in 0, we will notate it as ~x0 , when expressed in 1 it will be noted ~x1 and ~x2 in
referential 2. We will also write xi the quaternion (0, ~xi ).
Moreover, three quaternions are defined: q01 describes relative attitude of refer-
ential 1 with respect to referential 0, q12 describes relative attitude of referential
2 with respect to referential 1 and q02 describes relative attitude of referential
2 with respect to referential 0.

q12

q01
2

0
q02

So we may write

x0 = q01 ◦ x1 ◦ q̄01 x1 = q12 ◦ x2 ◦ q̄12 x0 = q02 ◦ x2 ◦ q̄02


and by substitution

x0 = q01 ◦ x1 ◦ q̄01 = q01 ◦ q12 ◦ x2 ◦ q̄12 ◦ q̄01 = (q01 ◦ q12 ) ◦ x2 ◦ (q01 ◦ q12 )
we can identify q02

q02 = q01 ◦ q12 . (41)


j j
Noting =ωij (0, ~
ωij )
the rotation velocity of the reference frame j relative
j
to frame i expressed in the frame j and remembering that ωij = 2q̄ij ◦ q̇ij , we
may write

18
2
ω02 = 2q̄02 ◦ q̇02
= 2(q̄12 ◦ q̄01 ) ◦ (q̇01 ◦ q12 + q01 ◦ q̇12 )
= 2q̄12 ◦ q̄01 ◦ q̇01 ◦ q12 + 2q̄12 ◦ q̄01 ◦ q01 ◦q̇12
| {z }
Id
= q̄12 ◦ (2q̄01 ◦ q̇01 ) ◦q12 + 2q̄12 ◦ q̇12
| {z } | {z }
1 2
ω12
ω01
1 2
= q̄12 ◦ ω01 ◦ q12 + ω12
2 2
= ω01 + ω12 .

That is, we can add consecutive rotation speeds if they are expressed in the
same referential.
2
In the case of the Cubsat, ~ω02 is the satellite’s rotation velocity ~ω ′ expressed in

body coordinates in the inertial referential model; we will note it ~ωInertial here.
2 ′
On the other hand, ~ ω12 is the satellite’s rotation velocity ω~ expressed in body
coordinates in the non-inertial referential model (i.e. in orbital reference frame,

ORF); we will note it ~ωN onInertial .
1 2
ω01 is the ORF rotation velocity expressed in the ORF, that is ~ωo , while ~ω01
~
is the same vector, transformed in the body referential. This transformation is
performed by RT from the non-inertial model (q̄12 in the above developement).
In other words, we can link the ~ω ′ vector from both inertial and non-inertial
formulations (models) with
′ T ′
ω
~ Inertial = RN ωo + ~ωN
onInertial ~ onInertial . (42)
This is the speed to be used in computing the kinetic energy for the non-
inertial model.

19
C Euler Angles to Quaternions
Three rotations by the Euler angles around each axis can be written as

 
cos (ψ) − sin (ψ) 0
 
 sin (ψ)
Rψ =  cos (ψ) 0 

0 0 1

 
cos (θ) 0 sin (θ)
 
Rθ = 
 0 1 0 

− sin (θ) 0 cos (θ)

 
1 0 0
 
 0
Rφ =  cos (φ) − sin (φ) 

0 sin (φ) cos (φ)

Combined together, they define the rotation matrix

R = Rφ Rθ Rψ .

Those three rotations can also be expressed as quaternion rotations

 
1
  1
   1
 
cos φ 2 cos 2 θ cos 2 ψ
      
 sin 1 φ   0   0 
 2     
qφ =   qθ =    qψ =  .
 0   sin 1 θ   0 
   2   
1

0 0 sin 2 ψ

The resulting quaternion can then be obtained by multiplying those three


together

20
 1 1
 1
 1
 1
 1
 
cos φ cos
2 2 θ cos 2 ψ − sin 2 φ sin 2 θ sin 2 ψ
       
 cos 1 ψ cos 1 1 1 1 1
 2 2 θ sin 2 φ + cos 2 φ sin 2 θ sin 2 ψ  
q = qφ ◦qθ ◦qψ =        .
 cos 1 ψ cos 1 1 1 1 1
2 φ sin 2 θ − cos 2 θ sin 2 φ sin 2 ψ 

 2
     
cos 12 φ cos 1
2 θ sin
1
2 ψ + cos
1
2 ψ sin
1
2 φ sin
1
2 θ

Note: that this result depends on the convention used in the order and choice
of the Euler angles and rotation axes! [5]

21
References
[1] Quaternion, Finite Rotation and Euler Parameters
Arend L. Schwab
http://tam.cornell.edu/˜als93/quaternion.pdf
[2] Quaternion based dynamics - Single Turbine Aircraft - Lagrange and Hamil-
tonian approaches
S. Gros
LA, EPFL.
[3] Classical Mechanics
Herbert Goldstein.
[4] Lagrangian Dynamics
Dare A. Wells
Schaum’s Outline Series.
[5] http://www.mathworks.com/access/helpdesk/help/toolbox/aeroblks/index.html?
/access/helpdesk/help/toolbox/aeroblks/euleranglestoquaternions.html

22

You might also like