Top Banner
computer graphics & visualization Simulation and Animation Key frame Interpolation
36

Computer graphics & visualization Key frame Interpolation.

Dec 18, 2015

Download

Documents

Kerrie Caldwell
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation

Key frame Interpolation

Page 2: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Keyframe AnimationDraw one keyframe after another

Results in “rough” animation instead of a smooth transition from frame to frame

Page 3: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Keyframe Interpolation

Page 4: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Keyframe Interpolation

Page 5: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Keyframe Interpolation

Page 6: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Simple TranslationsLinear Interpolation is fine here

But what about rotations?

1000

000

000

000

)(z

y

x

t

t

t

tR

1000

)(z

y

x

tihg

tfed

tcba

tR

Page 7: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Linear Interpolation of Rotations

K = (1-a) A + a B (linear interpolation: lerp)

Introduces non linear behavior on the arc

Page 8: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

SLERPApproach by means of slerp = spherical linear interpolation

with

it follows

AP

BBAP

cos

cos

1||

PA

BA

P

BAP

sin

sin

sin

)sin(

Page 9: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Quaternion Power Operator

[ cos(q/2), sin(q /2) * A] a

[cos(aq/2), sin(aq /2) * A] q a rotates to q orientation as a goes

from 0 to 1

=

Quaternions: q = (qbqa-1) a qa (slerp)

q = slerp(qa,qb, a)

Page 10: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Curves• So far: smooth linear interpolation along a line

(or along an arc on the circle)

• Now extend the idea so that interpolation follows a given path, a curve

• In the following: description of curves

Page 11: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Consider the following:Data is sampled at discrete data pointsWant to know data values at an arbitrary position within the domain

Page 12: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

The simple way• From n+1 known data samples construct a n-

dimensional polynomial• n+1 Samples → n+1 knows• n-dimensional polynomial has n+1

unknowns

011

1)( cxcxcxcxp nnn

nn

leads to system of n+1 linear equations

Page 13: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

The simple way (cont.)• system of equations can be rewritten as matrix

1

2

1

1

2

1

11

11

1

21

22

11

11

1

1

1

1

n

n

n

n

nn

nnn

nn

nnn

nn

nn

y

y

y

y

c

c

c

c

xxx

xxx

xxx

xxx

Vandermonde Matrix

Page 14: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Polynomial for approximation

21

1)(

xxf

Page 15: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

How to handle multiple x values?

• do not use a single approximation function but use n (=dimension of the domain) functions and a new parameter t from 0 to 1

• x(t)=x, y(t)=y, z(t)=z …

x

yy(t)

x(t)

Page 16: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

multiple x-values (cont.)leads to multiple polynomials

zzzz

yyyy

xxxx

dtctbtatz

dtctbtaty

dtctbtatx

23

23

23

)(

)(

)(

can be rewritten in matrix form

CTtztytxtQ ,,

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

C

1,,, 23 tttT

Page 17: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Matrix notation

C can be split up into M (basis matrix)G (geometry matrix)

GM

ddd

ccc

bbb

aaa

C

zyx

zyx

zyx

zyx

M is fixed for a given approachG depends on the specific curve to fit

Page 18: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Building M• derive a Matrix M for the Hermite approach • Hermite uses polynomials of degree 3 to a fit 2

points• it is an interpolation

→ 2 conditions• derivatives at the endpoints are given

→ 2 conditions

Page 19: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Hermite interpolation

2

1

2

1

R

R

P

P

GxH

x

x

x

x

Hhx

Hhx

Hhx

Hhx

GMRx

GMRx

GMPx

GMPx

0,1,2,3)1(

0,1,0,0)0(

1,1,1,1)1(

1,0,0,0)0(

2

1

2

1

with

xx HHH GMG

R

R

P

P

0123

0100

1111

1000

2

1

2

1

GMttttztytxtQ 1,,,,, 23

xxx

xxxx

ctbtatx

dtctbtatx

23)(

)(2

23

Page 20: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Hermite interpolation (cont.)

223

123

223

123 1232132)( RttRtttPttPtttx

xx HHH GMG

R

R

P

P

0123

0100

1111

1000

2

1

2

1

0001

0100

1233

1122

HM

2

1

2

1

23

0001

0100

1233

1122

1,,,)(),(),()(

R

R

P

P

ttttztytxtQ

Page 21: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Hermite interpolation• Cubic Hermite-Polynoms:

30H

33H

31H

32H

233

232

231

230

)23()(H

)1()(H

)1()(H

)21()1()(H

ttt

ttt

ttt

ttt

Charles Hermite (1822-1901)

Page 22: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Hermite interpolation• Example:

Page 23: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Hermite interpolation• Properties:– Neither affine invariant with respect to control

points nor with respect to vectors – No local control– Difficult to find tangent vectors– Curve segments can be attached continuously – Interpolation between points with tangents, e.g. for

Keyframe-Animation with given position and velocity

Page 24: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Monom interpolation• Approach: Monom-Basis: {ti | i=0…n}

• From p(ti) = ai the system of equations is derived:

Vandermond Matrix

n

i

ii tt

0

)( cpBasis

Control points

nnnnn

n

n ttt

ttt

c

c

c

a

a

a

1

0

2

0200

1

0

1

1 3 components per entry

Page 25: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves• Idea: tangent vectors defined by first and last two points:

– b0 and bn will be interpolated

– bi will be approximated– Relation to Hermite-Interpolation:

b0

b2b1

b3(degree)3with)()1(

)()0(

)1(

)0(

23

01

3

0

nn

n

bbp

bbp

bp

bp

cubic Bézier-Curve

Example: cubic Bezier-Curve

Page 26: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves• … and Hermite-Interpolation

• And for the curve:

BHBH GM

b

b

b

b

p

p

p

p

G

3

2

1

0

1000

3300

0033

0001

)1(

)1(

)0(

)0(

Geometry vectorfor Bézier

Matrix forBézier to Hermite

BMBTM

BHBMHTM

HMHTMt

GMB

GMMB

GMBp

)(

0001

0033

0363

1331

MBMwith

Page 27: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves • The cubic Bézier-Curve:

• Bernstein-Polynoms of degree n:

with domain [0,1]

3with)(B

)1(3)1(3)1()(

0

33

22

12

03

nt

ttttttt

i

n

i

ni b

bbbbp

Bézier-Control-PointsBernstein-Polynoms

inini tt

i

nt

)1()(B

)!(!

!

ini

n

i

n

with

Page 28: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves• Cubic Bernstein-Polynoms:

30B 3

3B

31B

32B

333

232

231

330

)(B

)1(3)(B

)1(3)(B

)1()(B

tt

ttt

ttt

tt

Page 29: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves• Of degree n = 1: linear interpolation

• Of degree n = 2:

10101

110

10 )1()(B)(B)( bbbbbp ttttt

222

21

220 )(B,)1(2)(B,)1()(B ttttttt

20

11

10

2110

2110

22

102

)1(

))1(())1)((1(

)1()1()1)(1(

)1(2)1()(

bbb

bbbb

bbbb

bbbp

tt

tttttt

tttttttt

ttttt

iterated linear interpolation

Page 30: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Curves• Iterated linear interpolation for degree 2:

20

11

10)1()( bbbp ttt

0b

1b

2b

10b

11b

20b

Example fort = 0,4

http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/

Page 31: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bezier Interpolation of Quaternions

De Casteljau

Page 32: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

p1 slerp(qn ,an, 13)p2 slerp(an ,bn1, 13)p3 slerp(bn1,qn1, 13)p12 slerp(p1, p2, 13)p23 slerp(p2, p3, 13)pslerp(p12, p23, 13)

Spherical Linear Interpolation

Page 33: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

For u = 1/4

tempslerp(qn ,an, 12)qn anp1 slerp(qn ,temp, 12)qn temptempslerp(an ,bn1, 12)an bn1p2 slerp(qn , temp, 12)qn temptempslerp(bn1,qn1, 12)bn1 qn1p3 slerp(bn1,temp, 12)bn1 temptempslerp(p1, p2, 12)p1 p2p12 slerp(p1, temp, 12)p1 temptempslerp(p2, p3, 12)p2 p3p23 slerp(p2,temp, 12)p2 temptempslerp(p12, p23, 12)p12 p23p23 slerp(p12,temp, 12)p12 temp

Repeated mid-point interpolation

Page 34: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Spline-Curves• Problem so far: polynom degree depends on number

of control points• Idea: – Multiple segments with low degree instead of one segment

of high degree– Segments can be of arbitrary type:

• Hermite-Curves• Quadrics• Bézier-Curves

– Important is smooth transition between segments

Page 35: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Spline-Curves• Spline: – A thin flexible rod used for the construction of ships– Deutsch: Straklatte, Strakfunktionen– A spline of n-th degree consists of polynomial

segments of max degree n – A cubic Spline describes the shape of a thin rod that

is fixed at start and end point

Page 36: Computer graphics & visualization Key frame Interpolation.

computer graphics & visualization

Simulation and Animation – SS 07Jens Krüger – Computer Graphics and Visualization Group

Bézier-Splines• Spline-Segments i:

• Spline s(u) ist sum of segments

n

jji

nji ut

0,)(B)( bs

bi,3 = bi+1,0

ui

ui+1bi,0

bi,1bi,2

bi+1,1