36
computer graphics & visualization Simulation and Animation Key frame Interpolation

Simulation and Animation

  • Upload
    admon

  • View
    31

  • Download
    0

Embed Size (px)

DESCRIPTION

Simulation and Animation. Key frame Interpolation. Keyframe Animation. Draw one keyframe after another  Results in “rough” animation instead of a smooth transition from frame to frame. Keyframe Interpolation. Keyframe Interpolation. Keyframe Interpolation. Simple Translations. - PowerPoint PPT Presentation

Citation preview

Page 1: Simulation and Animation

computer graphics & visualization

Simulation and Animation

Key frame Interpolation

Page 2: Simulation and Animation

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: Simulation and Animation

computer graphics & visualization

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

Keyframe Interpolation

Page 4: Simulation and Animation

computer graphics & visualization

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

Keyframe Interpolation

Page 5: Simulation and Animation

computer graphics & visualization

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

Keyframe Interpolation

Page 6: Simulation and Animation

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?

1000000000000

)(z

y

x

ttt

tR

1000

)(z

y

x

tihgtfedtcba

tR

Page 7: Simulation and Animation

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: Simulation and Animation

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 a

coscos

1||

PABA

P

BAP

sinsin

sin)sin(

Page 9: Simulation and Animation

computer graphics & visualization

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

Quaternion Power Operator

[ cos(/2), sin( /2) * A] a [cos(a/2), sin(a /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: Simulation and Animation

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: Simulation and Animation

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: Simulation and Animation

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: Simulation and Animation

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

11

11

n

n

n

nn

nn

nn

nn

nnn

nn

nn

yy

yy

cc

cc

xxxxxx

xxxxxx

Vandermonde Matrix

Page 14: Simulation and Animation

computer graphics & visualization

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

Polynomial for approximation

211)(x

xf

Page 15: Simulation and Animation

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: Simulation and Animation

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

dddcccbbbaaa

C

1,,, 23 tttT

Page 17: Simulation and Animation

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

dddcccbbbaaa

C

zyx

zyx

zyx

zyx

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

Page 18: Simulation and Animation

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: Simulation and Animation

computer graphics & visualization

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

Hermite interpolation

2

1

2

1

RRPP

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

RRPP

0123010011111000

2

1

2

1

GMttttztytxtQ 1,,,,, 23

xxx

xxxx

ctbtatx

dtctbtatx

23)(

)(2

23

Page 20: Simulation and Animation

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

RRPP

0123010011111000

2

1

2

1

0001010012331122

HM

2

1

2

1

23

0001010012331122

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

RRPP

ttttztytxtQ

Page 21: Simulation and Animation

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: Simulation and Animation

computer graphics & visualization

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

Hermite interpolation• Example:

Page 23: Simulation and Animation

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: Simulation and Animation

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

)( cp Basis

Control points

nnnnn

n

n ttt

ttt

c

cc

a

aa

1

0

2

0200

1

0

1

1 3 components per entry

Page 25: Simulation and Animation

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

nnn

bbpbbp

bpbp

cubic Bézier-Curve

Example: cubic Bezier-Curve

Page 26: Simulation and Animation

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

bbbb

pppp

G

3

2

1

0

1000330000330001

)1()1()0()0(

Geometry vectorfor Bézier

Matrix forBézier to Hermite

BMBTM

BHBMHTM

HMHTMt

GMBGMMB

GMBp

)(

0001003303631331

MBMwith

Page 27: Simulation and Animation

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

in

t

)1()(B

)!(!!ini

nin

with

Page 28: Simulation and Animation

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: Simulation and Animation

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

bbbbbbbb

bbbp

tt

tttttttttttttt

ttttt

iterated linear interpolation

Page 30: Simulation and Animation

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: Simulation and Animation

computer graphics & visualization

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

Bezier Interpolation of Quaternions

De Casteljau

Page 32: Simulation and Animation

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: Simulation and Animation

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: Simulation and Animation

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: Simulation and Animation

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: Simulation and Animation

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