Top Banner
Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005
35

Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Dec 18, 2015

Download

Documents

Britney Watson
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: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Curves

CSE169: Computer Animation

Instructor: Steve Rotenberg

UCSD, Winter 2005

Page 2: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Polynomial Functions

Linear:

Quadratic:

Cubic:

dctbtattf

cbtattf

battf

23

2

Page 3: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Vector Polynomials (Curves)

Linear:

Quadratic:

Cubic:

We usually define the curve for 0 ≤ t ≤ 1

dcbaf

cbaf

baf

tttt

ttt

tt

23

2

Page 4: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bezier Curves

Bezier curves can be thought of as a higher order extension of linear interpolation

p0

p1

p0

p1p2

p0

p1

p2

p3

Page 5: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bezier Curve Formulation

There are lots of ways to formulate Bezier curves mathematically. Some of these include: de Castlejau (recursive linear interpolations) Bernstein polynomials (functions that define the influence

of each control point as a function of t) Cubic equations (general cubic equation of t) Matrix form

We will briefly examine ALL of these! In practice, matrix form is the most useful in

computer animation, but the others are important for understanding

Page 6: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bezier Curve

p0

p1

p2

p3

Find the point x on the curve as a function of parameter t:

x(t)•

Page 7: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

de Casteljau Algorithm

The de Casteljau algorithm describes the curve as a recursive series of linear interpolations

This form is useful for providing an intuitive understanding of the geometry involved, but it is not the most efficient form

Page 8: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

de Casteljau Algorithm

p0

q0

p1

p2

p3

q2

q1

322

211

100

,,

,,

,,

ppq

ppq

ppq

tLerp

tLerp

tLerp

Page 9: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

de Casteljau Algorithm

q0

q2

q1

r1

r0

211

100

,,

,,

qqr

qqr

tLerp

tLerp

Page 10: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

de Casteljau Algorithm

r1x

r0•

10 ,, rrx tLerp

Page 11: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bezier Curve

x•

p0

p1

p2

p3

Page 12: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Recursive Linear Interpolation

322

211

100

,,

,,

,,

ppq

ppq

ppq

tLerp

tLerp

tLerp

211

100

,,

,,

qqr

qqr

tLerp

tLerp

10 ,, rrx tLerp

3

2

1

0

p

p

p

p

baba tttLerp 1,,

Page 13: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Expanding the Lerps

3221

211010

3221211

2110100

32322

21211

10100

111

1111,,

111,,

111,,

1,,

1,,

1,,

pppp

pppprrx

ppppqqr

ppppqqr

ppppq

ppppq

ppppq

ttttttt

ttttttttLerp

tttttttLerp

tttttttLerp

tttLerp

tttLerp

tttLerp

Page 14: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bernstein Polynomial Form

3

32

23

123

023

33

22

12

03

3221

2110

33

363133

13131

111

1111

pp

ppx

ppppx

pppp

ppppx

ttt

tttttt

tttttt

ttttttt

ttttttt

Page 15: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Bernstein Polynomials

33

3

2332

2331

2330

3332

321

310

30

33

223

123

023

33

363

133

33

363133

ttB

tttB

ttttB

ttttB

tBtBtBtB

ttt

tttttt

ppppx

pp

ppx

Page 16: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bernstein Polynomials

B33B0

3

B13 B2

3

Page 17: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bernstein Polynomials

1

!!

!1

122

12

33

363

133

11

10

222

221

220

333

2332

2331

2330

tB

ini

n

i

ntt

i

ntB

ttB

ttB

ttB

tttB

tttB

ttB

tttB

ttttB

ttttB

ni

iinni

Page 18: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bernstein Polynomials

n

ii

ni

iinni

tBt

tti

ntB

0

1

px

Bernstein polynomial form of a Bezier curve:

Page 19: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Bernstein Polynomials

We start with the de Casteljau algorithm, expand out the math, and group it into polynomial functions of t multiplied by points in the control mesh

The generalization of this gives us the Bernstein form of the Bezier curve

This gives us further understanding of what is happening in the curve: We can see the influence of each point in the control

mesh as a function of t We see that the basis functions add up to 1, indicating

that the Bezier curve is a convex average of the control points

Page 20: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Equation Form

133

36333

33

363133

010

2210

33210

33

223

123

023

ppp

pppppppx

pp

ppx

t

tt

ttt

tttttt

Page 21: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Equation Form

0

10

210

3210

23

010

2210

33210

33

363

33

133

36333

pd

ppc

pppb

ppppa

dcbax

ppp

pppppppx

ttt

t

tt

Page 22: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Equation Form

If we regroup the equation by terms of exponents of t, we get it in the standard cubic form

This form is very good for fast evaluation, as all of the constant terms (a,b,c,d) can been precomputed

The cubic equation form obscures the input geometry, but there is a one-to-one mapping between the two and so the geometry can always be extracted out of the cubic coefficients

Page 23: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Matrix Form

0

10

210

3210

23

33

363

33

pd

ppc

pppb

ppppa

dcbax

ttt

3

2

1

0

23

0001

0033

0363

1331

1

p

p

p

p

d

c

b

a

d

c

b

a

x ttt

Page 24: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Cubic Matrix Form

zyx

zyx

zyx

zyx

ppp

ppp

ppp

ppp

ttt

ttt

333

222

111

000

23

3

2

1

0

23

0001

0033

0363

1331

1

0001

0033

0363

1331

1

x

p

p

p

p

x

Page 25: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Matrix Form

Ctx

GBtx

x

BezBez

zyx

zyx

zyx

zyx

ppp

ppp

ppp

ppp

ttt

333

222

111

000

23

0001

0033

0363

1331

1

Page 26: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Matrix Form

We can rewrite the equations in matrix form

This gives us a compact notation and shows how different forms of cubic curves can be related

It also is a very efficient form as it can take advantage of existing 4x4 matrix hardware support…

Page 27: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Derivatives

Finding the derivative (tangent) of a curve is easy:

cbax

dcbax ttdt

dttt 23 223

d

c

b

a

x

d

c

b

a

x 01231 223 ttdt

dttt

Page 28: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Form

Let’s look at an alternative way to describe a cubic curve

Instead of defining it with the 4 control points as a Bezier curve, we will define it with a position and a tangent (velocity) at both the start and end of the curve (p0, p1, v0, v1)

Page 29: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Curve

v1

p1

p0

v0

Page 30: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Curves

We want the value of the curve at t=0 to be x(0)=p0, and at t=1, we want x(1)=p1

We want the derivative of the curve at t=0 to be v0, and v1 at t=1

cbacbavx

ccbavx

dcbadcbapx

ddcbapx

23 1213 1

0203 0

111 1

000 0

21

20

231

230

Page 31: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Curves

cbav

cv

dcbap

dp

231

0

1

0

Page 32: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Curves

d

c

b

a

v

v

p

p

cbav

cv

dcbap

dp

0123

0100

1111

1000

23

1

0

1

0

1

0

1

0

Page 33: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Matrix Form of Hermite Curve

1

0

1

0

1

0

1

0

1

0001

0100

1233

1122

0123

0100

1111

1000

v

v

p

p

d

c

b

a

v

v

p

p

d

c

b

a

Page 34: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Matrix Form of Hermite Curve

Ctx

GBtx

x

HrmHrm

zyx

zyx

zyx

zyx

vvv

vvv

ppp

ppp

ttt

111

000

111

000

23

0001

0100

1233

1122

1

Page 35: Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.

Hermite Curves

The Hermite curve is another geometric way of defining a cubic curve

We see that ultimately, it is another way of generating cubic coefficients

We can also see that we can convert a Bezier form to a Hermite form with the following relationship:

HrmHrmBezBez GBGBC