csce 441: keyframe animation/smooth curves (cont.) jinxiang chai

77
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Upload: damon-bell

Post on 08-Jan-2018

224 views

Category:

Documents


0 download

DESCRIPTION

Key-frame Interpolation Given parameter values at key frames, how to interpolate parameter values for inbetween frames. t θ

TRANSCRIPT

Page 1: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

CSCE 441: Keyframe Animation/Smooth

Curves (Cont.)Jinxiang Chai

Page 2: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Key-frame Interpolation

• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.

θ

t

Page 3: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Key-frame Interpolation

• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.

t

θ

Page 4: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Key-frame Interpolation

• Given parameter values at key frames, how to interpolate parameter values for inbetween frames.

t

θ

Nonlinear interpolation

Page 5: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Natural cubic cruves

)(23 tQdtctbta xxxxx

Page 6: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Natural cubic cruves

)(23 tQdtctbta xxxxx

)(123 tQ

dcba

ttt x

x

x

x

x

Page 7: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Natural cubic cruves

)(23 tQdtctbta xxxxx

)(123 tQ

dcba

ttt x

x

x

x

x

)()()()(

1111

4

3

2

1

424

34

323

33

222

32

121

31

tQtQtQtQ

dcba

tttttttttttt

x

x

x

x

x

x

x

x

)()()()(

1111

4

3

2

1

1

424

34

323

33

222

32

121

31

tQtQtQtQ

tttttttttttt

dcba

x

x

x

x

x

x

x

x

Page 8: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Natural cubic curves

)()()()(

1111

11)(

4

3

2

1

1

424

34

323

33

222

32

121

31

2323

tQtQtQtQ

tttttttttttt

ttt

dcba

ttttQ

x

x

x

x

Properties:- Go through four control points

- not good for local control

Page 9: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

P1

R1 P4

R4

P1: start position

P4: end position

R1: start derivative

R4: end derivative

Page 10: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

P1

R1 P4

R4

Page 11: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

P1

R1 P4

R4

Herminte basis matrix

Page 12: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Herminte basis matrix

Page 13: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Page 14: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Page 15: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Page 16: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Page 17: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

Hermite basis functions

Page 18: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0.16

0 20 40 60 80 100 120-0.16

-0.14

-0.12

-0.1

-0.08

-0.06

-0.04

-0.02

0

basis function 1 basis function 2 basis function 3 basis function 4

Page 19: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Hermite Curves

4

1

4

1

23

0001010012331122

1)(

RRpp

ttttQ

4

1

4

1

23232323 232132

RRPP

ttttttttt

P1

R1 P4

R4

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.02

0.04

0.06

0.08

0.1

0.12

0.14

0.16

0 20 40 60 80 100 120-0.16

-0.14

-0.12

-0.1

-0.08

-0.06

-0.04

-0.02

0

)()2()32()132( 234

231

234

231 ttRtttRttPttP

*P1 *P4*R1 *R4+ + +=

Page 20: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Bezier Curves

34

01

232

011

)(3)(3

vPvP

vvRvvR

Page 21: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Bezier Curves

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

Page 22: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Bezier Curves

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

3232323 33363133

vvvv

ttttttttt

Page 23: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Bezier Curves

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

3232323 33363133

vvvv

ttttttttt

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0 20 40 60 80 100 1200

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Page 24: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Review: Bezier Curves

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

33

232

231

230 )33()363()133( tvttvtttvtttv

3

2

1

0

3232323 33363133

vvvv

ttttttttt

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 20 40 60 80 100 1200

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0 20 40 60 80 100 1200

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

*v0*v1 *v2 *v3+ + +=

Page 25: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

• Cubic curves:

• Hermite curves:

• Bezier curves:

Review: Different basis functions

4

3

2

1

23

0001003303631331

1)(

PPPP

ttttQ

4

1

4

1

23

0001010012331122

1)(

RRPP

ttttQ

)()()()(

1111

11)(

4

3

2

1

1

424

34

323

33

222

32

121

31

2323

tQtQtQtQ

tttttttttttt

ttt

dcba

ttttQ

x

x

x

x

Page 26: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Complex curves

Suppose we want to draw or interpolate a more complex curve

Page 27: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Complex curves

• Suppose we want to draw or interpolate a more complex curve

How can we represent this curve?

Page 28: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Complex curves

• Suppose we want to draw a more complex curve

• Idea: we’ll splice together a curve from individual segments that are cubic Béziers

Page 29: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Complex curves

• Suppose we want to draw or interpolate a more complex curve

• Idea: we’ll splice together a curve from individual segments that are cubic Béziers

Page 30: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Splines

• A piecewise polynomial that has a locally very simple form, yet be globally flexible and smooth

Page 31: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Splines

• There are three nice properties of splines we’d like to have

- Continuity - Local control - Interpolation

Page 32: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity

• C0: points coincide, velocities don’t

• C1: points and velocities coincide

• What’s C2? - points, velocities and accelerations coincide

Page 33: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity

• Cubic curves are continuous and differentiable

• We only need to worry about the derivatives at the endpoints when two curves meet

Page 34: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Local control

• We’d like our spline to have local control - that is, have each control point affect some well-defined

neighborhood around that point

Page 35: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Local control

• We’d like our spline to have local control - that is, have each control point affect some well-defined

neighborhood around that point

Page 36: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Local control

• We’d like our spline to have local control - that is, have each control point affect some well-defined

neighborhood around that point

Page 37: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Interpolation• Bézier curves are approximating - The curve does not (necessarily) pass through

all the control points - Each point pulls the curve toward it, but other

points are pulling as well - the curve is always located within the convex

hull based on control points.

• Instead, we may prefer a spline that is interpolating

- That is, that always passes through every control point

Page 38: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

B-splines

• We can join multiple Bezier curves to create B-splines

• Ensure C2 continuity when two curves meet

Page 39: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

Page 40: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

Page 41: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

3

2

1

0

0001003303631331

0026)(

vvvv

ttQ

Page 42: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

Page 43: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

3

2

1

0

0001003303631331

0026)(

vvvv

ttQ

3

2

1

0

2

0001003303631331

010*20*3)0(

vvvv

Q

)(3 01 vv

3

2

1

0

0001003303631331

0020*6)0(

vvvv

Q

)2(6 210 vvv

Page 44: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Derivatives at end points

3

2

1

0

23

0001003303631331

1)(

vvvv

ttttQ

3

2

1

0

2

0001003303631331

0123)(

vvvv

tttQ

3

2

1

0

0001003303631331

0026)(

vvvv

ttQ

)2(6)1(

)2(6)0(

)(3)1(

)(3)0(

123

210

23

01

vvvQ

vvvQ

vvQ

vvQ

Page 45: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

Page 46: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

)0()1( wv QQ

Page 47: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

)0()1(

)0()1(

)0()1(

wv

wv

wv

QQ

QQ

QQ

Page 48: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

)2(6)2(6)(3)(3

210123

1223

03

wwwvvvwwvv

wv

)0()1(

)0()1(

)0()1(

wv

wv

wv

QQ

QQ

QQ

Page 49: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

)2(6)2(6)(3)(3

210123

1223

03

wwwvvvwwvv

wv

Page 50: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

• Suppose we want to join two Bezier curves (V0, V1, V2,V3) and (W0, W1, W2, W3) so that C2 continuity is met at the joint

)2(6)2(6)(3)(3

210123

1223

03

wwwvvvwwvv

wv

2312

231

30

442

vvvwvvw

vw

Page 51: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Continuity in B splines

What does this derived equation mean geometrically?

- What is the relationship between a, b and c, if a = 2b - c? b is the middle point of a and c.

w2=v1+4v3-4v2

Page 52: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

de Boor points• Instead of specifying the Bezier

control points, let’s specify the corners of the frames that forms a B-spline

• These points are called de Boor points and the frames are called A-frames

Page 53: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

de Boor points

• What is the relationship between Bezier control points and de Boor points?

Verify this by yourself!

Page 54: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

B spline basis matrix

Page 55: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Building complex splines

• Constraining a Bezier curve made of many segments to be C2 continuous is a lot of work

- for each new segment we have to add 3 new control point - only one of the control points is really free

• B-splines are easier (and C2) - First specify 4 vertices (de Boor points), then one per segment

Page 56: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

B splines properties

√ Continuity

√ Local control

x Interpolation

Page 57: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

• If we are willing to sacrifice C2 continuity, we can get interpolation and local control.

• If we set each derivative to be a constant multiple of the vector between the previous and the next control points, we get a Catmull-Rom spline

Page 58: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

Page 59: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)()1(

)()0(

)1()0(

24

13

3

2

ppQ

ppQ

pQpQ

)( 13 pp

The segment is controlled by p1,p2,p3,p4

)( 24 pp

0.5

Page 60: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)()1(

)()0(

)1()0(

24

13

3

2

ppQ

ppQ

pQpQ

)( 13 pp

The segment is controlled by p1,p2,p3,p4

)( 24 pp

Page 61: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

The effect of t: how sharply the curve bends at the control points

Page 62: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)()1(

)()0(

)1()0(

24

13

3

2

ppQ

ppQ

pQpQ

)( 13 pp

)( 24 pp

The segment is controlled by p1,p2,p3,p4

4

3

2

1

000001000010

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

pppp

QQQQ

Page 63: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

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

0001010012331122

1)( 23

QQQQ

ttttQ

From Hermite curves

Page 64: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

4

3

2

1

000001000010

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

pppp

QQQQ

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

0001010012331122

1)( 23

QQQQ

ttttQ

From Hermite curves

Page 65: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

4

3

2

1

000001000010

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

pppp

QQQQ

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

0001010012331122

1)( 23

QQQQ

ttttQ

4

3

2

1

23

000001000010

0001010012331122

1)(

pppp

ttttQ

From Hermite curves

Page 66: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

4

3

2

1

23

000001000010

0001010012331122

1)(

pppp

ttttQ

4

3

2

1

23

001000

233222

1

pppp

ttt

Page 67: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

4

3

2

1

23

000001000010

0001010012331122

1)(

pppp

ttttQ

4

3

2

1

23

001000

233222

1

pppp

ttt

Page 68: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 13 pp

)( 24 pp

4

3

2

1

23

000001000010

0001010012331122

1)(

pppp

ttttQ

4

3

2

1

23

001000

233222

1

pppp

ttt

What do we miss?

Page 69: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

?

?

Page 70: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

)( 01 pp

)( 34 pp

Page 71: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

• Catmull-Rom splines have C1 continuity (not C2 continuity)

• Do not lie within the convex hull of their control points.

Page 72: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines

• Catmull-Rom splines have C1 continuity (not C2 continuity)

• Do not lie within the convex hull of their control points.

Page 73: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Catmull-Rom splines properties

X Continuity (C2)

√ Local control

√ Interpolation

Page 74: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Outline• Process of keyframing• Key frame interpolation• Hermite and bezier curve• Splines• Speed control

Page 75: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Speed control

• Time warping function to control speed - positive - monotonic; you cannot reverse the time

s=f(t)

Page 76: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Speed control

• Simplest form is to have constant velocity along the path

s=f(t)

Page 77: CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai

Speed control

• Assume that the motion slows down at the beginning and end of the motion curve

s=f(t)