DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a...

32
C. Wassgren, Purdue University 1 DEM Modeling: Lecture 13 3D Rotations

Transcript of DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a...

Page 1: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 1

DEM Modeling: Lecture 13

3D Rotations

Page 2: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 2

3D Rotations• Newton’s 2nd Law:

• Easiest to put the rotational eqns of motion

in a body-fixed frame of reference (FOR)

aligned with the particle’s principle axes

– in a body-fixed FOR, the moments of inertia

don’t change due to changes in orientation

– aka Euler’s rotational eqns of motion

( )

( )

( )

( )

1

1

1

1

B B B B

B B B B

x x y z yy zz

xx

B B B B

y y z x zz xx

yy

B B B B

z z x y xx yy

zz

T I II

T I II

T I II

ω ω ω

ω ω ω

ω ω ω

− = ⋅ − × ⋅

= + −

= + −

= + −

ω I T ω I ωɺ

ɺ

ɺ

ɺ

where

• Ixx, Iyy, and Izz are the

principle moments of inertia

for the particle

• ωωωωB is the rotational speed of the particle in a body-fixed

FOR

• TB is the net torque acting

on the particle in the body-

fixed FOR

xG

yG

zG

zB

xB

yB

ωBx, T

Bnet,x

ωBy, T

Bnet,y

ωBz, T

Bnet,z

( )G Gd

dt⋅ =I ω T

Page 3: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 3

3D Rotations…

• How should we describe the orientation of an object in

3D space?

• Three common methods

– direction cosines

– Euler angles

– quaternions

xG

yG

zG

zB

xB

yB

superscript “B” = body-fixed FOR

superscript “G” = global FOR

Page 4: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 4

Direction Cosines

• Use the cosines of the angles that the body-fixed axes

make with respect to the global axes to describe the

orientation of the object

xG

yG

zG

xBB Gx yθ

B Gx xθB Gx z

θ

ˆ ˆ ˆ ˆcos cos cosB G B G B GB G G Gx x y zx x x y x z

θ θ θ= + +e e e e

cos cos cosˆ ˆ

ˆ ˆcos cos cos

ˆ ˆcos cos cos

B G B G B G

B G B G B G

B G B G B G

BG

B Gx x x y x zx x

B G

y yy x y y y zB G

z zz x z y z z

R

θ θ θ

θ θ θ

θ θ θ

=

=

e e

e e

e e

���������������

RBG ≡ rotation matrix from the Global to the Body FOR

Page 5: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 5

Direction Cosines…

• The rotation matrix RBG is orthonormal

– the basis vectors forming the rows and columns of the matrix are

mutually perpendicular

– the magnitude of the basis vectors formed by these rows and

columns have a magnitude of one

– ⇒ RGB = (RBG)-1 = (RBG)T

– although the matrix RGB has nine terms, only three are

independent

ˆ ˆ

ˆ ˆ

ˆ ˆ

G B

x x

G GB B

y y

G B

z z

R

=

e e

e e

e e

Page 6: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 6

Direction Cosines…

• Example

– The unit vectors for the body-fixed FOR written in terms of the

global FOR are:

– Sketch both the body-fixed and global FOR axes. Let the global

and body-fixed FORs share the same origin.

– Write the rotation matrix for the transformation from the body-

fixed FOR to the global FOR.

– Express the vector vB = (0, 1, 0) which is given in the body-fixed

FOR in terms of the global FOR using the rotation matrix

determined in the previous part.

ˆ ˆ

ˆ ˆ

ˆ ˆ

B Gx y

B Gy z

B Gz x

=

=

=

e e

e e

e e

Page 7: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 7

Direction Cosines…

• Solution

( ) ( )1

cos cos cos 0 1 0

cos cos cos 0 0 1

1 0 0cos cos cos

0 0 1

1 0 0

0 1 0

B G B G B G

B G B G B G

B G B G B G

x x x y x z

BG

y x y y y z

z x z y z z

TGB BG BG

R

R R R

θ θ θ

θ θ θ

θ θ θ

= =

= = =

zG

xG

yB

yG

xB

zB

0 0 1 0

1 0 0 1

0 1 0 0

G GB BR=

=

v v

zG

xG

yB

yG

xB

zBv 0

0

1

G

∴ =

v

Page 8: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 8

Euler Angles

• Decompose the orientation into three successive

rotations about various coordinate axes (e.g. the 1-2-3

sequence shown below)

x0, x1

y0

z0

η

z1

y1

η

η

λ

y2

x2

z2, z3

x3

y3

λλ

x0

y0

z0

x0

y0

z0

z3

x3

y3

x1

ξ

z1z2

x2

ξ

ξ

y1, y2

Page 9: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 9

Euler Angles…

• The full sequence of rotations may be expressed as a

single rotation matrix

1 10 0 0

1 0 0

0 cos sin

0 sin cos

R η ηη η

= = −

a a a

2 21 1 1

cos 0 sin

0 1 0

sin 0 cos

R

ξ ξ

ξ ξ

− = =

a a a

3 32 2 2

cos sin 0

sin cos 0

0 0 1

R

λ λλ λ

= = −

a a a

3 30 0 32 21 10 0R R R R= =a a a

30

c c c s s s c s s c s c

c s c c s s s s c c s s

s s c c c

R

ξ λ η λ η ξ λ η λ η ξ λξ λ η λ η ξ λ η λ η ξ λξ η ξ η ξ

+ − = − − + −

Page 10: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 10

Euler Angles…

• There are twelve possible Euler angle sequences that

could be used:. 1-2-1 (e.g. x0y1x2), 1-3-1, 2-1-2, 2-3-2, 3-

1-3, 3-2-3, 1-2-3, 2-3-1, 3-1-2, 3-2-1, 2-1-3, and 1-3-2.

• The rotation matrix is orthonormal.

• The Euler angles used to achieve a final orientation are

not unique. For example, the rotation matrix is identical

for (η, ξ, λ) = (135°, 135°, 135°) and (η, ξ, λ) = (-45°, 45°, -45°).

Page 11: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 11

Euler Angles…

• Example

– A vector vB = (0, 1, 0) is expressed in FOR B. The

Euler angles for converting from FOR A to FOR B are

(η, ξ, λ)BA = (90°, 90°, 0°). Sketch FORs A and B and the vector v. Find vector v’s components in FOR A.

Page 12: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 12

Euler Angles…

• Solution

xA

yA

zAz1

y1

x1

ηBA = 90°z2

x2

y1z1

y2

x1ξBA = 90°

λBA = 0°z2

x2

yBy2

xB

zB

v

zA

xA

yB

yA

xB

zB

Page 13: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 13

Euler Angles…

• Solution...

( ) ( )1 TB BA A A BA B BA BR R R

−= ⇒ = =v v v v v

c c c s s s c s s c s c

c s c c s s s s c c s s

s s c c c

0 1 0

0 0 1

1 0 0

BA BA BA BA BA BA BA BA BA BA BA BA

BA BA BA BA BA BA BA BA BA BA BA BA BA

BA BA BA BA BA

R

ξ λ η λ η ξ λ η λ η ξ λξ λ η λ η ξ λ η λ η ξ λξ η ξ η ξ

+ −

= − − + −

=

( )�

0 0 1 0

1 0 0 1

0 1 0 0

BTBA

A

x

y

z

R

v

v

v

==

=

v

�����

0

0

1

A

xA

y

z

v

v

v

∴ = =

v

Page 14: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 14

Euler Angles…

• Euler angle rate of change

– consider a small rotation about each

of the Euler angle sequence axes

– express the rate at which the rotation,

∆θθθθ, occurs in terms of the body-fixed FOR (frame 3)

1 20 ˆˆˆzyx ξη λ∆ = + +∆ ∆∆ e eeθ

3

2 3 3

1 2 2

2

3 3

0

2

1

ˆ

ˆ ˆ ˆsin cos

ˆ ˆ ˆcos sin

ˆ ˆ ˆcos sin

ˆ

ˆ

ˆ

x

z

y x y

x x z

x x y

y

z

λ λ

ξ ξ

λ λ

=

= = +

= = +

= −

e

e e e

e e e

e e

e

e

e

e

x0, x1

y0

z0

η

z1

y1

η

η

λ

y2

x2

z2, z3

x3

y3

λλ

x1

ξ

z1z2

x2

ξ

ξ

y1, y2

Page 15: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 15

Euler Angles…

• Euler angle rate of change…

( ) ( ) ( )3 3 3 3ˆ ˆ ˆcos cos sin cos sin cos sinx y zη ξ λ ξ λ η ξ λ ξ λ η ξ λ∆ = ∆ + ∆ + −∆ + ∆ + ∆ + ∆θ e e e

� � � � � � �3

33 3 3ˆ ˆ ˆcos cos sin cos sin cos sinx y z

d d d d d d d

dt dt dt dt dt dt dtη η ηξ ξ λ

η ξ η ξ η λξ λ λ ξ λ λ ξ

= = == = ==

= + + − + + +

ω

θe e e

ɺ ɺ ɺɺ ɺ ɺ

3

3

3

cos sin 0cos cos

sin cos 0

tan cos tan sin 1

x

y

z

λ λη ωξ ξξ λ λ ωλ ξ λ ξ λ ω

− ∴ = −

ɺ

ɺ

ɺ

3

3

3

cos cos sin 0

cos sin cos 0

sin 0 1

x

y

z

ω ξ λ λ ηω ξ λ λ ξω ξ λ

= −

ɺ

ɺ

ɺ

• if ξ → π/2 or 3π/2, then cosξ → 0

• The Euler angle formulation is not

well posed for all Euler angles.

• Other Euler angle sequences (e.g.

1-2-1) will also have singularities at

particular angles.

• This behavior is sometimes referred

to as “gimbal lock.”

Page 16: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 16

Quaternions

• Describe an orientation using a single

rotation about a unit vector

θ

yG

xG

zG

ˆ Gn

xB

yB

zB

• Unlike direction cosines and

Euler angles, a quaternion

uses four quantities to

describe the orientation: (θ, nxG, ny

G, nzG). One of the

quantities is not independent.

• An Euler angle rotation

sequence can be thought of

as a sequence of three

quaternion rotations.

Page 17: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 17

Quaternions…

• Consider a complex number

( ) ( )1 1 1 1 1 1 1, cos , sinz x y r rθ θ= = =v

y2 2

1tan

r x y

y

xθ −

= +

= x

r1θ1

( )2 2 2cos ,sinz θ θ=

( )( )( ) ( )( )

1 2 1 1 1 1 2 2

1 1 2 1 1 2

cos , sin cos ,sin

cos , sin

z z r r

r r

θ θ θ θ

θ θ θ θ

′ = =

= + +

v

We can rotate the vector v about the origin by an angle θ2 by multiplying z1 by the complex number z2 as given below.

Let the 2D vector v be represented by the

complex number z1

v

y

xθ1

vv’θ2

∴∴∴∴2D rotations may be performed using complex numbers

Page 18: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 18

Quaternions…

• (Unit) quaternions are “hypercomplex” numbers

that can be used to perform 3D rotations

– originally proposed by Hamilton (1843)

( ) ( )( ) ( ) ( ) ( )

0 1 2 3

2 2

1 2 32 2 2 2

ˆ

ˆcos , sin

cos sin sin sin

q q i q j q k

n i n j n k

θ θ

θ θ θ θ

= + + +

=

= + + +

q

n

2 2 2 1i j k

ij ji k

jk kj i

ki ik j

= = = −

= − =

= − =

= − =

i

jk+

i

jk–

θ yG

xG

zG

ˆGn

xB

yB

zB

Page 19: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 19

Quaternions…

• Some handy quaternion properties

2 2 2 2

0 1 2 3

ˆ

q q q q= + + +

=

q

qq

q

[ ][ ] [ ]( )( )( ) ( )( ) ( )

0 1 2 3 0 1 2 3

0 0 1 1 2 2 3 3 0 1 1 0 2 3 3 2

0 2 1 3 2 0 3 1 0 3 1 2 2 1 3 0

, , ,s t st s t

a ia ja ka b ib jb kb

a b a b a b a b i a b a b a b a b

j a b a b a b a b k a b a b a b a b

= = − ⋅ + + ×

= + + + + + +

= − − − + + + − +

− + + + + − +

ab u v u v v u u v

( ) ( )( ) ( )

, in general

+ = +

+ + = + +

=

a b b a

a b c a b c

a bc ab c

ab ba

Page 20: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 20

Quaternions…

• Some handy quaternion properties…

[ ][ ] ( ) [ ] ( )

( )

1

10 1 2 3 0 1 2 3

11 1

1,

if , , , , , then , , , ,s q q q q s q q q q

−− −

=

= = = − = − − −

=

qq 0

q v q v

p q qp

[ ] [ ] ( ) ( ) ( )1

ˆA vector rotated about unit vector by an angle is given by:

ˆ ˆ ˆ ˆ ˆ0, 0, 0, cos sin 1 cos

θ

θ θ θ−′ = = + × + ⋅ −

v n

v q v q v n v v n n

[ ] ( )[ ]( )1 2

1 1

2 1 1 2

ˆ ˆTwo successive rotations (first rotate using then rotate using ):

ˆ ˆ ˆ ˆ0, 0, − −′′ =

q q

v q q v q q [ ] [ ]( )12 1

ˆ ˆ ˆ ˆ ˆequivalent to 0, 0, where −′′ = =v r v r r q q

Page 21: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 21

Quaternions…

• Some handy quaternion properties…

[ ] [ ]

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

1

2 2

2 3 0 3 1 2 0 2 1 3

2 2

0 3 1 2 1 3 0 1 2 3

2 2

0 2 1 3 0 1 2 3 1 2

ˆ ˆ0, 0,

1 2 2 2

where 2 1 2 2

2 2 1 2

R

q q q q q q q q q q

R q q q q q q q q q q

q q q q q q q q q q

−′ ′= ⇒ =

− + − + + = + − + − + − + + − +

v q v q v v

Page 22: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 22

Quaternions…

• Example

– A vector v = (1, 0, 0) is rotated about the y-

axis by an angle of 90º. Determine the (unit)

quaternion encoding this rotation and show

that the rotated vector is v’ = (0, 0, -1). Also

find the rotation matrix corresponding to the

quaternion.

Page 23: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 23

Quaternions…

• Solutiony

x

z

θ = 90°

v’

v

( ) ( ) ( )

( )2 2

1 1

2 2

ˆ ˆ ˆcos ,sin where =90 , 0,1,0

ˆ ,0, ,0

θ θ θ = =

⇒ =

q n n

q

[ ] [ ] ( ) ( ) ( )

( ) ( ) ( ) ( ){ }( )

( )

1

0

ˆ ˆ ˆ ˆ ˆ0, 0, 0, cos sin 1 cos

0, 0,1,0 1,0,0 1,0,0 0,1,0 0,1,0

0, 0,0, 1

θ θ θ−

=

′ = = + × + ⋅ −

= + × + ⋅

= −

v q v q v n v v n n

0�������

( )0,0, 1′∴ = −v

Page 24: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 24

Quaternions…

• Solution

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

2 2

2 3 1 2 0 3 0 2 1 3

2 2

0 3 1 2 1 3 0 1 2 3

2 2

0 2 1 3 0 1 2 3 1 2

1 2 2 2

2 1 2 2

2 2 1 2

q q q q q q q q q q

R q q q q q q q q q q

q q q q q q q q q q

− + − + = + − + − + − + + − +

0 0 1

0 1 0

1 0 0

R

∴ = −

1

2

3

0 0 1 1 0

0 1 0 0 0

1 0 0 0 1

R

v

v

v

==

′ ′ = = ′ − −

v

�����

Note: (same result as before)

Page 25: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 25

Quaternions…

• Using quaternions to change FORs

– Let qGB be the unit quaternion that rotates FOR G to FOR B.

– Since the vector v does not rotate with the FOR, it’s as if v

rotates in the opposite sense of qGB (imagine the movement of

v if standing in FOR B).

– Thus, to express v in FOR B, rotate vG using the inverse

quaternion qBG = (qGB)-1.

( ) ( )( ) ( )

1

1

ˆ ˆ0, 0,

ˆ ˆ0,

B BG G BG

GB G GB

=

=

v q v q

q v q

xG

yG

zG

zB

yB xB

v

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

2 2

2 3 0 3 1 2 0 2 1 3

2 2

1 2 0 3 1 3 0 1 2 3

2 2

0 2 1 3 0 1 2 3 1 2

1 2 2 2

where 2 1 2 2

2 2 1 2

B GB G

GB GB GB GB GB GB GB GB GB GB

GB GB GB GB GB GB GB GB GB GB GB

GB GB GB GB GB GB GB GB GB GB

R

q q q q q q q q q q

R q q q q q q q q q q

q q q q q q q q q q

=

− + + − +

= − − + + + − + − +

v v

Page 26: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 26

Quaternions…

• Example

– A vector vG = (0, 1, 0) is expressed in FOR G.

FOR B is found by rotating FOR G about the

vector (1, 0, 0)G (expressed in FOR G) by an

angle of 180°. Determine the (unit) quaternion encoding the rotation from FOR G

to FOR B. Express the vector v in FOR B.

Page 27: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 27

Quaternions…

• Solution

yG

xG

zGθ = 180°

vxB

yB

zB

( ) ( ) ( )2 2

ˆ ˆcos ,sin 0,1,0,0GB Gθ θ = = q n

( ) ( ){ }( ) ( )( ){ }( )( )( )

1

ˆ ˆ0, 0,

0, 1,0,0 0,0,1,0 0,1,0,0

0, 1,0,0 0,0,0, 1

0,0, 1,0

B GB G GB−

=

= −

= − −

= −

v q v q

( )0, 1,0B∴ = −v

Page 28: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 28

Quaternions…• Quaternion rate of change

– consider a rotation about the body-fixed axes over a short time ∆t

– ωωωωB(t) is the rate of rotation about the body-fixed axes at time t– qGB(t) is the unit quaternion to go from FOR B to FOR B at time t

– the new quaternion may be found by multiplying the old quaternion by the

quaternion describing the incremental rotation

( )( ) ( )

( )( )

( )ˆ ˆcos , sin2 2

G GG

GB GB

G

t t t ttt t t

t

∆ ∆ + ∆ =

ω ωωq q

ω

( ) ( ) ( )1

2ˆ 0,GB GB Bt t t ∴ = q q ωɺ

• there is no singularity in the quaternion rate of change (recall that there was

using Euler angles)

• only unit quaternions encode rotations so the quaternion should be

normalized after it has been updated to prevent numerical “drift” resulting

from numerical precision errors

Note: ( ) ( ) 1

ˆ ˆ0, 0,G GB B GB−

= ω q ω q

Page 29: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 29

Quaternions…

• Example

– A cylinder’s body-fixed FOR (see below for the orientation of the

body-fixed FOR) is found in the global FOR using the quaternion

qGB = (0, 1/sqrt(2), 0, 1/sqrt(2)). The cylinder rotates about its

body-fixed axes with speed ωωωωB = (0, 0, 1). Sketch the cylinder’s orientation in the global FOR and determine the rate of change

of the cylinder’s quaternion at this instant in time.

yG

xG

zG

xB

yB

zB

Page 30: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 30

Quaternions…

• Solution

yG

xG

zG

zB

yB

xB

Determine the orientation of the body-fixed z-axis

[ ] ( ) ( ) ( )( ) ( )( ){ }( )( )( )

1

1 1 1 1

2 2 2 2

1 1 1 1

2 2 2 2

1 1 1 12 2 2 2

ˆ ˆ0, 0, 0,0,1

0, ,0, 0,0,0,1 0, ,0,

0, ,0, ,0, ,0

0, ,0,

GB GB−

′ =

= − −

= −

= + − +

z q q

( )1,0,0′∴ =z the body-fixed z axis points along the

global x axis

Perform a similar analysis for the body-fixed x-axis

[ ] ( ) ( ) ( )( ) ( )( ){ }( ) ( )( )

1

1 1 1 1

2 2 2 2

1 1 1 1

2 2 2 2

1 1 1 12 2 2 2

ˆ ˆ0, 0, 1,0,0

0, ,0, 0,1,0,0 0, ,0,

0, ,0, ,0, ,0

0, ,0,

GB GB−

′ =

= − −

=

= − +

x q q

( )0,0,1′∴ =x

( )

( )1 1

2 2

ˆNote: 180 and 1,0,1

ˆ 0, ,0,

Gθ = =

⇒ =

n

q

ˆGnθ = 180º

Page 31: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 31

Quaternions…

• Solution…

yG

xG

zGzB

yB

xB

( )( )12

1 1 12 2 2

ˆ0,

0,0,0, 0, ,0,

GB B GB =

=

q ω qɺ

( )1 1

2 2 2 2,0, ,0GB∴ = −qɺ

ωωωωB

Page 32: DEM Modeling: Lecture 13 3D Rotations - Pharmahub...Quaternions •Describe an orientation using a single rotation about a unit vector θ yG xG zG nˆG xB yB zB • Unlike direction

C. Wassgren, Purdue University 32

Summary

• 3D orientations and rotations are more complex

than their 2D counterparts

• Euler angles suffer from “gimbal lock” at

particular angles – shouldn’t use for modeling

rotational motion

• Quaternions have many advantages and are

commonly used in DEM applications

– don’t suffer from gimbal lock

– easy to correct for numerical drift

– multiple rotations can be represented by quaternion

multiplication