cs559: computer graphics lecture 19: curves li zhang spring 2008

24
CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Upload: johnathan-willis-chase

Post on 14-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

CS559: Computer Graphics

Lecture 19: CurvesLi Zhang

Spring 2008

Page 2: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Today• Continue on curve modeling

• Reading– Shirley: Ch 15.1 – 15.5

Page 3: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

More control points

p0

p1 2210)( ttt aaaf

p2

22

100 00)0( aaafp

22

101 5.05.0)5.0( aaafp

22

102 11)0.1( aaafp

2

1

0

2

1

0

111

25.05.01

001

a

a

a

p

p

p

2

1

0

a

a

a

C

2

1

0

2

1

01

2

1

0

242

143

001

p

p

p

p

p

p

C

a

a

a

2

1

021)(

a

a

a

f ttt

2

1

01

p

p

p

tC

2

1

0

p

p

p

tBBy solving a matrix equation that satisfies the constraints,we can get polynomial coefficients

Page 4: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Two views on polynomial curves

2

1

021)(

p

p

p

Bf ttt

)(1)(

2

1

02

p

p

p

Bf ttt

2210)( ttt aaaf

2

1

02 )1()(

p

p

p

Bf ttt

221100 )()()()( pppf tbtbtbt

From control points p, we can compute coefficients a

Each point on the curve is a linear blending of the control points

2

1

0

210 )()()(

p

p

p

tbtbtb

Page 5: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

What are b0(t), b1(t), …?

1

01)(p

pBf tt

1100 )()()( ppf tbtbt

1

0

1

0

11

01

p

p

a

a

Two control point case:

11

011)()( 10 ttbtb

tt10 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

b0(t) b1(t)

Page 6: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

What are b0, b1, …?

2

1

02 )1()(

p

p

p

Bf ttt

221100 )()()()( pppf tbtbtbt

Three control point case:

2

1

0

2

1

0

242

143

001

p

p

p

a

a

a

242

143

001

1)()()( 2210 tttbtbtb

222 244231 tttttt

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.2

0

0.2

0.4

0.6

0.8

1

1.2

?)()()( 210 tbtbtb 1Which is b0(t)?

Page 7: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

What are b0, b1, …?

• Why is important?– Translation-invariant interpolation

2

1

02 )1()(

p

p

p

Bf ttt

221100 )()()()( pppf tbtbtbt

Three control point case:

1)()()( 210 tbtbtb

dp

dp

dp

p

p

p

2

1

0

2

1

0 ))(())(())(()( 221100 dpdpdpf tbtbtbtnew

dppp

)()()(

)()()(

210

221100

tbtbtb

tbtbtb

df )(t for any t

Page 8: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Many control points

p0

p1

p2pn

002020100 )( paaaaf n

ntttt

3

0

)( Rtt i

n

i

ii

aaf

112121101)( paaaaf n

ntttt

nnnnnnn tttt paaaaf 2

210)(

nnnnn

n

n

tt

tt

tt

p

p

p

a

a

a

1

0

1

0

11

00

1

1

1

Straightforward, but not intuitive

Page 9: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Many control points• A shortcut

• Goal:

• Idea:

• Magic:

n

iii tbt

0

)()( pf

iit pf )(

ijtb

tb

ji

ii

0)(

1)(

n

ijj ji

ji tt

tttb

,0

)(

ni

n

ii

i

ii

i

ii

i

ii tt

tt

tt

tt

tt

tt

tt

tt

tt

tt

tt

tt

1

1

1

1

1

1

0

0

Getting bi(t) is easier!

n

ii tb

0

?)( 1 Why?

?)(0

n

iji tb nj ,1,0,1

is a polynomial of degree n

n

ii tbtB

0

)()(

Lagrange InterpolationLagrange Interpolation

If an n-degree polynomial has the same value at n+1 locations, it must be a constant polynomial

Page 10: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Lagrange Polynomial Interpolation

Page 11: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Lagrange Interpolation Demo• http://www.math.ucla.edu/~baker/java/hoefer/L

agrange.htm

• Properties:– The curve passes through all the control points– Very smooth: Cn for n control points– Do not have local control– Overshooting

Page 12: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Piecewise Cubic Polynomials

• Desired Features:– Interpolation– Local control – C1 or C2

33

2210)( tttt aaaaf

Page 13: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Natural Cubics

33

22

100 000)0( aaaafp

32

211 0302)0( aaafp

322 062)0( aafp

33

2210)( tttt aaaaf

32103 )1( aaaafp

3

2

1

0

3

2

1

0

1111

0200

0010

0001

a

a

a

a

p

p

p

p

3

2

1

0

3

2

1

0

15.011

05.000

0010

0001

p

p

p

p

a

a

a

a

Page 14: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Natural Cubics• If we have n points, how to use natural cubic to

interpolate them? – Define the first and second derivatives for the

starting point of the first segment. – Compute the cubic for the first segment– Copy the first and second derivatives for the end

point of the first segment to the starting point for the second segment

• How many segments do we have for n control points?

• n-1

Page 15: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Natutral Cubic Curves• Demo:

http://www.cse.unsw.edu.au/~lambert/splines/

Page 16: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Natural CubicsInterpolate control points

Has local control C2 continuity

Natural cubics

Page 17: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Hermit Cubics

33

22

100 000)0( aaaafp

32

211 0302)0( aaafp

3213 32)1( aaafp

33

2210)( tttt aaaaf

32102 )1( aaaafp

3

2

1

0

3

2

1

0

3210

1111

0010

0001

a

a

a

a

p

p

p

p

3

2

1

0

3

2

1

0

1212

1323

0010

0001

p

p

p

p

a

a

a

a

Page 18: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Hermite Cubic Curves• If we have n points, how to use Hermite cubic to

interpolate them? – For each pair, using the first derivatives at starting

and ending points to define the inbetween

• How many segments do we have for n controls? – n/2-1

Page 19: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Hermite CubiesInterpolate control points

Has local control C2 continuity

Natural cubics Yes No Yes

Hermite cubics

Page 20: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Catmull-Rom Cubics

1)0( pf

022

1)0( ppf

132

1)1( ppf

2)1( pf

3

2

1

0

5.005.00

0100

05.005.0

0010

)1(

)1(

)0(

)0(

p

p

p

p

f

f

f

f

3

2

1

0

3

2

1

0

p

p

p

p

B

a

a

a

a

Catmull

3

2

1

0

a

a

a

a

CHermite

Page 21: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Catmull-Rom Cubic Curves• Demo• http://www.cse.unsw.edu.au/~lambert/splines/C

atmullRom.html

• n control points define n-2 segments• Changing 1 point affects neighboring 4 segments

Page 22: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Cardinal Cubics

1)0( pf

02)0( ppf s

13)1( ppf s

2)1( pf

3

2

1

0

3

2

1

0

p

p

p

p

B

a

a

a

a

Cardinal

3

2

1

0

3

2

1

0

22

2332

00

0010

p

p

p

p

a

a

a

a

ssss

ssss

ss

s: tension control

3

2

1

0

00

0100

00

0010

)1(

)1(

)0(

)0(

p

p

p

p

f

f

f

f

ss

ss

3

2

1

0

a

a

a

a

CHermite

Page 23: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Cardinal Cubic Curves• 4 different s values

Page 24: CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008

Interpolate control points

Has local control C2 continuity

Natural cubics Yes No Yes

Hermite cubics Yes Yes No

Cardinal Cubics