51
CS Dept, UK 1 CS 633 Computer Animation Department of Computer Science College of Engineering University of Kentucky Fuhua (Frank) Cheng

CS 633 Computer Animation

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS 633 Computer Animation

CS Dept, UK1

CS 633 Computer Animation

Department of Computer Science

College of Engineering

University of Kentucky

Fuhua (Frank) Cheng

Page 2: CS 633 Computer Animation

CS Dept, UK2

1. Introduction

1.1 What is Computer Animation

the process of using

“continuous image” to

convey information

deals with motion

Page 3: CS 633 Computer Animation

CS Dept, UK3

1. Introduction

1.2 Applications

- motion films(https://www.youtube.com/watch?v=D0a0aNqTehM)

- television

- advertising(read Chapter 1)

Page 4: CS 633 Computer Animation

CS Dept, UK4

2. Technical Background

The display pipeline:

Object space -

World space -

Eye space –

viewing parameters

field of view

Image space -

Screen space -

Page 5: CS 633 Computer Animation

CS Dept, UK5

2. Technical Background

Ray Casting:

- act of tracing

rays through

world space

Page 6: CS 633 Computer Animation

CS Dept, UK6

2. Technical Background

Ray Casting:

- implicitly

accomplishes

the perspective

transformation

(HOW ?)

Page 7: CS 633 Computer Animation

CS Dept, UK7

2. Technical Background

Homogeneous Coordinates:

- why do we want to use homogeneous

coordinates ?

Page 8: CS 633 Computer Animation

CS Dept, UK8

2. Technical Background

Transformation Matrices:

Page 9: CS 633 Computer Animation

CS Dept, UK9

2. Technical Background

Compounding Transformations:beforeafter

Page 10: CS 633 Computer Animation

CS Dept, UK10

2. Technical Background

Basic Transformations:

Translation

Rotation

Scaling (reflection)

Page 11: CS 633 Computer Animation

CS Dept, UK11

Representing an arbitrary orientation:

Fixed angle representation

Page 12: CS 633 Computer Animation

CS Dept, UK12

Representing an arbitrary orientation:

Page 13: CS 633 Computer Animation

CS Dept, UK13

Representing an arbitrary orientation:

Page 14: CS 633 Computer Animation

CS Dept, UK14

Representing an arbitrary orientation:

Page 15: CS 633 Computer Animation

CS Dept, UK15

Representing an arbitrary orientation:

• Interpolation is difficult

Page 16: CS 633 Computer Animation

CS Dept, UK16

Representing an arbitrary orientation:

0) ,90 ,0( )90 ,45 ,90(

90

90

45

90

Direct interpolation = ((0, 90, 0) + (90, 45, 90))/2

= (45, 67.5, 45)

Page 17: CS 633 Computer Animation

CS Dept, UK17

Representing an arbitrary orientation:

0) ,90 ,0( )90 ,45 ,90(

90

90

45

90

Question: Is (45, 67.5, 45) coplanar with (0, 90, 0) and

(90, 45, 90) ?

Page 18: CS 633 Computer Animation

CS Dept, UK18

Representing an arbitrary orientation:

0) ,90 ,0( )90 ,45 ,90(

90

90

4590

Desired interpolation = (90, 67.5, 90)

5.6790

Page 19: CS 633 Computer Animation

CS Dept, UK19

Quaternions

Motivation:

multiplying complex numbers can be

interpreted as a rotation in two dimensions.

Can hyper-complex numbers be defined

so their multiplication can be viewed as

a rotation in three dimensions?

)(

21212121

iii

errerer

Page 20: CS 633 Computer Animation

CS Dept, UK20

Quaternions

Remember that a general

rotation in three dimension

is defined by four numbers:

one for rotation angle

and three

for rotation axis

Page 21: CS 633 Computer Animation

CS Dept, UK21

Quaternions: several approaches

1. 2 × 2 matrices of complex numbers

where

Page 22: CS 633 Computer Animation

CS Dept, UK22

Quaternions: several approaches

2. Four dimensional vector space

one of the bases:

where4x4 Identity matrix

Page 23: CS 633 Computer Animation

CS Dept, UK23

Quaternions: several approaches

3. Combination of a scaler and a vector

Conjugate quaternion:

Sum/difference:

Page 24: CS 633 Computer Animation

CS Dept, UK24

Quaternions: several approaches

Product:

Norm:

Inverse:

Division:

Inner product Cross product

Page 25: CS 633 Computer Animation

CS Dept, UK25

Representing rotations using quaternion:

Page 26: CS 633 Computer Animation

CS Dept, UK26

Representing rotations using quaternion:

Rotate a point P by an angle about a unit

axis u:

Page 27: CS 633 Computer Animation

CS Dept, UK27

Representing rotations using quaternion:

1. Represent the point P as

[0, r] ( or, [ 0, P ] )

2. represent the rotation by a quaternion

3. perform the rotation

Page 28: CS 633 Computer Animation

CS Dept, UK28

Representing rotations using quaternion:

1. Represent the point P as

[0, r] ( or, [ 0, P ] )

2. represent the rotation by a quaternion

3. perform the rotation

Page 29: CS 633 Computer Animation

CS Dept, UK29

Representing rotations using quaternion:

Example: Consider a rotation of point

P = (0, 1, 1) about the y-axis.

After rotation, we should get

= (1, 1, 0)

Would we?

90

P

P P’

Page 30: CS 633 Computer Animation

CS Dept, UK30

Representing rotations using quaternion:

Page 31: CS 633 Computer Animation

CS Dept, UK31

Representing rotations using quaternion:Hence,

Page 32: CS 633 Computer Animation

CS Dept, UK32

Representing rotations using quaternion:

Page 33: CS 633 Computer Animation

CS Dept, UK33

Representing rotations using quaternion:

Prove that the triple product indeed

performs a rotation of P about u.

First,

Note

that

Page 34: CS 633 Computer Animation

CS Dept, UK34

Page 35: CS 633 Computer Animation

CS Dept, UK35

Now prove that would give us

]2

sin,2

[cos ]2

sin2

cos,2

sin[

]2

sin,2

[cos

]2

sin2

sin02

cos,2

sin02

[cos

]2

sin,2

[cos],0[]2

sin,2

[cos

],0[ 1

ururru

u

ruurru

uru

qrq

Page 36: CS 633 Computer Animation

CS Dept, UK36

Now prove that would give us

]2

sin2

sin2

cos

2sin

2cos

2cos

2sin

,2

sin2

sin2

cos2

cos2

sin[

]2

sin,2

[cos ]2

sin2

cos,2

sin[

2

22

2

uruur

rururu

uruurru

ururru

Page 37: CS 633 Computer Animation

CS Dept, UK37

Now prove that would give us

]2

sin

2sin

2cos

2sin)(sin,0[

]2

sin2

sin2

cos

2sin

2cos

2cos

2sin

,2

sin2

sin2

cos2

cos2

sin[

2

222

2

22

2

uur

rrururu

uruur

rururu

uruurru

urururu

)(

0

Page 38: CS 633 Computer Animation

CS Dept, UK38

Now prove that would give us

]P,0[

],0[

]sincos,0[

)]))((2

sin2

cos2

sin2

(cos

cossin,0[

]2

sin2cossin,0[

2222

2

r

ruuurruur

uur

rru

ururru

Page 39: CS 633 Computer Animation

CS Dept, UK39

Geometric Meaning of Quaternions

Quaternions provide a clear difference

between a vector (point) and a rotation.

]sin,[cos :Rotation

],0[],0[ :orPoint/vect

uq

rP

All the operations for

vectors such as vector

addition/subtraction,

scalar multiplication hold.

2

Page 40: CS 633 Computer Animation

CS Dept, UK40

Geometric Meaning of Quaternions

Rotation is performed as: 1],0[ qPq

Why?

Let

For R(P) to be a rotation,

It must satisfy four

properties:

1],0[)( qPqPR

Page 41: CS 633 Computer Animation

CS Dept, UK41

Geometric Meaning of Quaternions

For R(P) to be a rotation, it must satisfy four

properties:

1. R(P) is a 3D vector

2. R(P) preserves length

3. R(P) is a linear

transformation

4. R(P) does not have

a reflection

component

Page 42: CS 633 Computer Animation

CS Dept, UK42

R(P) is a 3D vector

Let W(p) represent the real part of the quaternion p.

Then we need to show that W(R(P))=0

First, note that quaternion multiplication is distributive

and associative. Besides, we have

and

2/)()( pppW

pqpq

Page 43: CS 633 Computer Animation

CS Dept, UK43

R(P) is a 3D vector

Hence,

0

]0,0[

}2

],0[],0[{

2/}],0[],0[{

2/})],0[(],0[{

)],0[())((

qq

qPP

q

qPqqPq

qPqqPq

qPqWPRW

Page 44: CS 633 Computer Animation

CS Dept, UK44

R(P) preserves length

Let N(p) represent the length of the quaternion p,

2222)( then

if i.e.,

zyxwpN

kzjyixwp

]),0([

)(]),0([)(

)],0[())((

Hence,

)()()( that Note

PN

qNPNqN

qPqNPRN

qNpNpqN

Page 45: CS 633 Computer Animation

CS Dept, UK45

R(P) is a linear transformationLet a be a scalar and P, Q be 3D vectors, then

)()(

],0[)],0[(

],0[]),0[(

],0[],0[

]},0[],0{[

],0[)(

QRPaR

qQqqPqa

qQqqPaq

qQqqaPq

qQaPq

qQaPqQaPR

Page 46: CS 633 Computer Animation

CS Dept, UK46

R(P) does not have a reflection

component Consider R as a function of q for a fixed vector .

That is, R(q) = .

This function is a continuous function of q. For each q

it is a linear transformation with determinant D(q), so

the determinant itself is a continuous function of q.

Thus, , the identity function (the

limit is taken along any path of quaternions which

approach the quaternion 1) and .

By continuity, D(q) is identically 1 and R(q) does not

have a reflection component.

r

qrq ],0[

IRqRq

)1()(lim1

1)1()(lim1

DqDq

Page 47: CS 633 Computer Animation

CS Dept, UK47

is the unit rotation axisu

u

u

],0[

]cossin,sincoscossin[

]sin,][coscos,sin[

]sin,][cos,0][sin,[cos

],0[)(

22

u

uu

uu

uuu

ququR

To see that is a unit rotation axis we need only

show that is unchanged by the rotation.

Indeed,

Page 48: CS 633 Computer Animation

CS Dept, UK48

The rotation angle is 22

s and ,

ru

0 srsuru

.

and,

rus

usrsru

To see that the rotation angle is ,

let be a right-handed

set of orthonormal vectors, i.e.,

The vectors are all of unit length;

; and

The vector is rotated by an angle to the

vector , so .

u

r

s

r

qrq ],0[

)cos(],0[ qrqr

Page 49: CS 633 Computer Animation

CS Dept, UK49

The rotation angle is

A quaternion q may also be viewed as a

4D vector (w; x; y; z). The dot product of

two quaternions is

Also,

and

for any unit quaternion with zero real part.

2

)( 101010101010

qqWzzyyxxwwqq

],0[],0[ rr

1],0[ 2 p

],0[ p

Page 50: CS 633 Computer Animation

CS Dept, UK50

The rotation angle is

Hence, the rotation angle is

2

)2cos(

sincos

])sincos2,sin([cos

])sincos,0][sincos,0([

])sin,][cos,0][sin,][cos,0[(

)],0[],0([

],0[cos

22

22

uW

srsrW

ururW

qrqrW

qrqr

2

Page 51: CS 633 Computer Animation

End of

Introduction &

Technical Background

CS Dept, UK51