Docsity

Quaternions - Computer Graphics - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Quaternions - Computer Graphics - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Computer Animation III Quaternions Dynamics

Recap: Euler angles 3 angles along 3 axis Poor interpolation, lock But used in flight simulation, etc. because natural^ http://www.fho-emden.de/~hoffmann/gimbal09082002.pdf

Final project First brainstorming session on Thursday Groups of three Proposal due Monday 10/27 „ A couple of pages „ Goals „ Progression Appointment with staff

Final project Goal-based „ Simulate a visual effect „ Natural phenomena „ Small animation „ Game „ Reconstruct an existing scene Technique-based „ Monte-Carlo Rendering „ Radiosity „ Fluid dynamics

Quaternion principle A quaternion = point on unit 3-sphere in 4D = orientation. We can apply it to a point, to a vector, to a ray We can convert it to a matrix We can interpolate in 4D and project back onto sphere „ How do we interpolate? „ How do we project?

Quaternion recap 1 (wake up) 4D representation of orientation q^ = {cos(

θ/2);^ v^ sin(

θ/2)}

Inverse is

-1^ q =(s, - v ) Multiplication rule^ „^ Consistent with rotation composition

How do we apply rotations?^ How do we interpolate?

θ

v

(^ )(

)

1 2 1

2 1 2

1 2 2 1

1 2 ,

s s^ v^

v^ s v^

s v^ v^

v

q q^ =^

−^

+^ +^

×

r^ r^ r

r^

r^ r

Quaternion Algebra Two general quaternions are multiplied by a special rule:To rotate 3D point/vector

p^ by^ q , compute „^ q^ {0;^ p }^

-1 q p= (x,y,z)^

q ={ cos(θ/2), 0,0,sin(

θ/2) } = {c, 0,0,s}

q^ {0, p }= {c, 0, 0, s} {0, x, y, z}

(^ )(

1 2 1

2 1 2

1 2 2 1

1 2 ,

s s^ v^

v^ s v^

s v^ v^

v

q q^ =^

−^

+^ +^

×

r^ r^ r

r^

r^ r

= {c.0- zs,^

c p +0(0,0,s)+ (0,0,s)

×^ p } = {-zs, c^ p^ + (-sy,sx,0) }-1^ q {0, p } q^ =^ {-zs, c

p^ + (-sy,sx,0) }

{c, 0,0,-s} = {-zsc-(c p +(-sy,sx,0)).(0,0,-s),-zs(0,0,-s)+c(c

p +(-sy, sx,0))+ (c

p^ + (-sy,sx,0) ) x (0,0,-s) }

= {0,^ (0,0,zs

22 )+c p +(-csy, csx,0)+(-csy, csx, 0)+(s

22 x, s^ y, 0)}

(^2) = {0, (cx-2csy-s 22 x, cy+2csx-s

2 2+^2 y, zs^ sc)} = {0, x cos(

θ)-y sin(θ), x sin(

θ)+y cos(θ), z }

Quaternion Interpolation (velocity) The only problem with

l inear int

erp olation (lerp) of

quaternions is that it interpolates the straight line (the secant)between the two quaternions and not their spherical distance.As a result, the interpolated motion does not have smoothvelocity: it may speed up too much in some sections: S pherical

l inear int

erp olation (slerp) removes this problem by interpolating along the arc lines instead of the secant lines. q^^0

q^1

t q ( )

t q ( )

keyframes^

lerp^

slerp

(^ )

(^ )( )

(^ ) (^ ) (^0) ( )

1

0 1 1

sin^1

sin

slerp^ ,

,^

( )^

sin

where^

cos

t

t

t^ t^

q^

q

q^ q^

q q^ q

−

−^ +

=^ = ω =^0

Fun:Julia Sets in Quaternion space Mandelbrot set: Z

(^2) =Z+Zn+1 n 0

Julia set Z

(^2) =Z+Cn+1n http://aleph0.clarku.edu/~djoyce/julia/explorer.htmlDo the same with Quaternions!Rendered by Skal (Pascal Massimino) http://skal.planet-d.net/See also http://www.chaospro.de/gallery/gallery.php?cat=Anim

Images removed due to copyright considerations.

Fun:Julia Sets in Quaternion space Julia set Z=Zn+

2 +Cn Do the same with Quaternions!Rendered by Skal (Pascal Massimino) http://skal.planet-d.net/This is 4D, so we need the time dimension as well

Images removed due to copyright considerations.

Overview Interpolation of rotations, quaternions „ Euler angles „ Quaternions Dynamics „ Particles „ Rigid body „ Deformable objects

Break: movie time PixarFor the Bird

Particle A single particle in 2-D moving in a flow field „ Position „ Velocity „ The flow field function dictatesparticle velocity

x ⎡ ⎤^1 = x ⎢ ⎥x^2 ⎣ ⎦ v ⎡ ⎤d^1 ,= =⎢ ⎥vdt^2 ⎣ ⎦

x v^

v

t x (^ )

x^1

x^2

,t g x ( )

,t= v g x ( )

Vector Field The flow field^ g

( x ,t^ ) is a vector field that defines a vector for

any particle position

x^ at any time

t^.

How would a particle move in this vector field?

x^1

( x 2 ,t g x )