Quaternions in Interactive Computer Graphics | CS 418, Study notes of Computer Graphics

Material Type: Notes; Class: Interactive Computer Graphics; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2009;

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-plu
koofers-user-plu 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Quaternions
Quaternions are 4-D numbers
q = s + xi + yj + zk
Hamilton Math Inst.,
Trinity College
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Quaternions in Interactive Computer Graphics | CS 418 and more Study notes Computer Graphics in PDF only on Docsity!

Quaternions Quaternions are 4-D numbers

q^ =

s^

+^ x

i^ +

y j^

+^ z

k

Hamilton Math Inst.,Trinity College

Quaternions Complex numbers Quaternions are essentially generalized complex numbers

-^ a scalar part + a vector part — 1 real and 3 imaginary parts •^ norm •^ basic quaternion operation is multiplication

,^

c^

a^

b =^

+^

i^

i

=^

=^

+^

+^

x y z ]) =

( , [

q^

s^

s^

s^

x^

y^

z

v^

i^

j^

k

=^

+^

+^

+^

+^

+^

=^

−^

⋅^

×^

+^

'^

(^

'^

'^

'^ )

(^

'^

',^

'^

'^

'^ )

qq

s^

x^

y^

z^

s^

x^

y^

z

ss^

s^

s

i^

j^

k^

i^

j^

k

v v

v^

v^

v^

v

2

2

2

2

||^

|| q

w^

x^

y^

z

=^

+^

+^

1,^

,^

=^

=^

=^

=^

2

2

2

i^

j^

k^

ij^

k^

jk^

i^

ki^

j

Rotations With Quaternions Rotations in a 2D plane using complex numbers Given a point

p^ and an axis

u

-^ construct the unit quaternion •^ compute the product •^ the resulting point

p ′^

is^ p

rotated by

θ^ about

u θ^

θ

=^

2

2

(cos

,

sin

)

q^

u −^1

0

=^

0

( ,

')

( ,

) q^

q

p^

p

(^

)

[^

]^

,^

cos

sin

'^

cos(

)^

sin(

)

[ cos(

)^

sin(

)]

i^

i

i^ i^

i

c^

a b

a^

b^

re^

d^

e

c^

cd^

re e

re^

r^

r

r^

r

φ

θ

φ^ θ

φ^ θ

θ^

θ φ^

θ

φ^

θ

φ^

θ

φ^

θ

=^

=^

+^

=^

=^

+^

=

=^

=^

=^

=^

+^

+^

=^

+^

i^

i

i

u p

q^ p

-1 q cos

sin 2

2

q

θ^

θ

=^

+^ u

Quaternion-Matrix Conversion Quaternion can also be converted to equivalent rotation matrix

q

y^

z^

xy^

wz

xz^

wy

xy^

wz^

x^

z^

yz^

wx

xz^

wy

yz^

wx

x^

y

2

2

2

2

2

2

⎡^

1− 2

− 2

2

− 2^

2

  • 2^

0

⎢^

2

  • 2^

1− 2

− 2

2

− 2^

0

⎢^

= ⎢^

2

− 2^

2

  • 2^

1− 2

− 2

0

⎢^

0

0

0

1

⎣^

M

T^

T^

( ,^

)^

cos

(^

)^ (sin

)

θ

θ

θ

=^

+^

−^

R^

u^

uu

I^

uu

u

θ^

θ

=^

=^

2

2

])

(^

, [^

(cos

,

sin

)

q^

w^

x^

y^

z^

u

Looking At Quaternions Quaternions have a big advantage over Euler angles

-^ can interpolate between rotations much more nicely •^ using scheme called Spherical Linear Interpolation (SLERP)^ –

walk along great circle connecting two points on 4-D unit sphere But interpolating multiple rotations is more complicated Quaternions have some other nice advantages too

-^ more compact than rotation matrices •^ can compose rotations by quaternion multiplication •^ but they can be easily converted to matrices if needed

1

1

2

1

1

2

Slerp(

,^

;^

)^

(^

where

(cos

,sin

)^

(cos

,sin

q^

q^

q^

q^

q

α α

θ^

=^

≤^

u^

u

SLERP Exponential map^ q

= exp(

u ) = cos

θ/2 + sin

u

The base orientation consisting of a zerodegree rotation is represented by the unitquaternion

1 + 0

i^ + 0

j^ + 0

k

We can interpolate from the base orientationto a given orientation (

θ , u

) as

q ( t

) = cos

t^ θ/2 +

u^

sin

t^ θ/2 =

t ( e θ/2)

u

To interpolate from

q^1

to^ q

we can 2 ,

interpolate from the base

q ( t

q^1

( q^1

-1 q

t ) 2