parametric curves - university of washington

53
1 Parametric Curves

Upload: others

Post on 16-Oct-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Parametric Curves - University of Washington

1

Parametric Curves

Page 2: Parametric Curves - University of Washington

2

Reading

w  Foley, Section 11.2 Optional w  Bartels, Beatty, and Barsky. An Introduction to Splines

for use in Computer Graphics and Geometric Modeling, 1987.

w  Farin. Curves and Surfaces for CAGD: A Practical Guide, 4th ed., 1997.

Page 3: Parametric Curves - University of Washington

3

Curves before computers

The “loftsman’s spline”:

w  long, narrow strip of wood or metal w  shaped by lead weights called “ducks” w  gives curves with second-order continuity, usually

Used for designing cars, ships, airplanes, etc.

Page 4: Parametric Curves - University of Washington

4

Motivation for curves

What do we use curves for?

w  building models

w  movement paths

w  animation

Page 5: Parametric Curves - University of Washington

5

Mathematical curve representation

w  Explicit y=f(x) •  what if the curve isn’t a function?

w  Implicit f(x,y) = 0 •  hard to work with

w  Parametric (f(u),g(u)) x(u) = cos 2πu y(u) = sin 2πu

2 2 2 0x y R+ − =

Page 6: Parametric Curves - University of Washington

6

Parametric polynomial curves

We’ll use parametric curves where the functions are all polynomials in the parameter.

Advantages:

w  easy (and efficient) to compute w  infinitely differentiable

( )0

( )0

kk

kk

nx u

kn

y uk

a u

b u

∑==

∑==

Page 7: Parametric Curves - University of Washington

7

Cubic curves

Fix n=3 For simplicity we define each cubic function within the range

[ ]

3 2

3 2

3 2

3 2

( )( ) ( ) ( ) ( ) or ( )

( )or

( ) 1

x x x x x

y y y y y

z z z z z

x y z

x y z

x y z

x y z

Q t a t b t c t dt x t y t z t Q t a t b t c t d

Q t a t b t c t d

a a ab b b

t t t tc c cd d d

= + + +

= = + + +

= + + +

⎡ ⎤⎢ ⎥⎢ ⎥ ⎡ ⎤= ⎣ ⎦⎢ ⎥⎢ ⎥⎣ ⎦

Q

Q

0 1t≤ ≤

Page 8: Parametric Curves - University of Washington

8

Compact representation

[ ]

( )

3 2

3 2

2

1

( ) ( ) ( ) ( ) 1

( ) ( ) 3 2 1 0

x y z

x y z

x y z

x y z

x y z

x y z

x y z

x y z

a a ab b b

t t tc c cd d d

a a ab b b

Q t x t y t z t t t tc c cd d d

d d d dQ t Q t t tdt dt dt dt

⎡ ⎤⎢ ⎥⎢ ⎥ ⎡ ⎤= = ⎣ ⎦⎢ ⎥⎢ ⎥⎣ ⎦

⎡ ⎤⎢ ⎥⎢ ⎥⎡ ⎤= = = ⋅⎣ ⎦ ⎢ ⎥⎢ ⎥⎣ ⎦

ʹ′ ⎡ ⎤= = ⋅ = ⋅ + ⋅ = ⋅⎣ ⎦

C T

T C

T C T C T C C

Place all coefficients into a matrix

Page 9: Parametric Curves - University of Washington

9

Controlling the cubic

Q: How many constraints do we need to specify to fully determine the scalar cubic function Q(t)?

Q: How many constraints do we need to specify to fully determine the 3-vector cubic function Q(t)?

Page 10: Parametric Curves - University of Washington

10

Constraining the cubics

1 1 111 12 13 14

2 2 221 22 23 243 2

3 3 331 32 33 34

4 4 441 42 43 44

( ) 1

x y z

x y z

x y z

x y z

G G Gm m m mG G Gm m m m

t t t tG G Gm m m mG G Gm m m m

= ⋅

⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎡ ⎤= ⎣ ⎦ ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

⎣ ⎦ ⎣ ⎦= ⋅ ⋅

C M G

Q

T M G

Redefine C as a product of the basis matrix M and the ���4-element column vector of constraints or geometry vector G

Page 11: Parametric Curves - University of Washington

11

Hermite Curves

Determined by

w  endpoints P1 and P4

w  tangent vectors at the endpoints R1 and R4

So

Where

1 1 1

4 4 4

1 1 1

4 4 4

x y z

x y zh

x y z

x y z

P P PP P PR R RR R R

⎡ ⎤⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎣ ⎦

G

P4

P1

R1

R4

( ) h ht = ⋅ ⋅Q T M G

Page 12: Parametric Curves - University of Washington

12

Page 13: Parametric Curves - University of Washington

13

Computing Hermite basis matrix

The constraints on Q(0) and Q(1) are found by direct substitution:

Tangents are defined by

so constraints on tangents are:

2( ) 3 2 1 0 h hQ t t tʹ′ ⎡ ⎤= ⋅ ⋅⎣ ⎦ M G

[ ][ ]

(0) 0 0 0 1

(1) 1 1 1 1h h

h h

Q

Q

= ⋅ ⋅

= ⋅ ⋅

M G

M G

[ ][ ]

(0) 0 0 1 0

(1) 3 2 1 0h h

h h

Q

Q

ʹ′ = ⋅ ⋅

ʹ′ = ⋅ ⋅

M G

M G P4

P1

R1

R4

Q(t)

Page 14: Parametric Curves - University of Washington

14

Collecting all constraints we get

So

Computing Hermite basis matrix

1 1 1

4 4 4

1 1 1

4 4 4

0 0 0 11 1 1 10 0 1 03 2 1 0

x y z

x y zh h h

x y z

x y z

P P PP P PR R RR R R

⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥= = ⋅⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥

⎣ ⎦⎣ ⎦

G M G

10 0 0 1 2 2 1 11 1 1 1 3 3 2 10 0 1 0 0 0 1 03 2 1 0 1 0 0 0

h

−−⎡ ⎤ ⎡ ⎤

⎢ ⎥ ⎢ ⎥− − −⎢ ⎥ ⎢ ⎥= =⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

M

P4

P1

R1

R4

Q(t)

Page 15: Parametric Curves - University of Washington

15

Computing a point

Given two endpoints (P1,P4) and two endpoint tangent vectors (R1 , R4):

So

1

43 2

1

4

2 2 1 13 3 2 1

10 0 1 01 0 0

( )

0

t t t t

− ⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥− − − ⎢ ⎥⎢ ⎥⎡ ⎤= ⎣ ⎦ ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

⎣ ⎦ ⎣ ⎦

Q

PPRR

P4

P1

R1

R4

Q(t)

Page 16: Parametric Curves - University of Washington

16

Blending Functions

Polynomials weighting each element of the geometry vector

1

4

1

4

2 2 1 13 3 2 13 2 10 0

14( )

1 01 0 0

10 4

( )h

t tt t

t

⎡ ⎤−⎢ ⎥− − −⎢ ⎥⎡ ⎤

⎣ ⎦ ⎢ ⎥⎢ ⎥⎢ ⎥

⎡ ⎤⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎢ ⎥⎣⎦ ⎦⎣

⎡ ⎤⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎣ ⎦

PP

QRR

PPRR

B

1R4

1

R1

P1 P4

t

Bh(t)

Page 17: Parametric Curves - University of Washington

17

Continuity

We want our curve to have continuity. There shouldn’t be an abrupt change when we move from one segment to the next.

There are nested degrees of continuity:

C0: C1:

C2: C3, C4, …:

Page 18: Parametric Curves - University of Washington

18

Continuity of Splines

P2 =P3

P1

R1

R2

P4

R3

R4

P2 =P3

P1

R1

R2

P4 R4

P2 =P3

P1

R1

R2 = R3

P4 R4

R3

C0: points coincide, ���velocities don’t

G1: points coincide, ���velocities have same direction

C1: points and velocities ���coincide

Q: What’s C2?

Page 19: Parametric Curves - University of Washington

19

Page 20: Parametric Curves - University of Washington

20

Bézier Curves

P3

P1 P4

P2

Indirectly specify the tangent vectors ���by specifying two intermediate points

1 1 1 1

2 2 2 2

3 3 3 3

4 4 4 4

x y z

x y zb

x y z

x y z

P P PP P PP P PP P P

⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥= =⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥

⎣ ⎦⎣ ⎦

PP

GPP

1 2 1

4 4 3

3( )3( )

= −

= −

R P PR P P

Page 21: Parametric Curves - University of Washington

21

Bézier basis matrix

Establish the relation between the Hermite and Besier geometry vectors:

1 1

4 2

1 3

4 4

1 0 0 00 0 0 13 3 0 00 0 3 3

h bh b

⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥= = =

−⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥−⎣ ⎦⎣ ⎦ ⎣ ⎦

P PP P

G M GR PR P

1 2 1

4 4 3

3( )3( )

= −

= −

R P PR P P

Page 22: Parametric Curves - University of Washington

22

Bézier basis matrix

( )( )

( ) h h h hb b

h hb b b b

t = ⋅ ⋅ = ⋅ ⋅ ⋅

= ⋅ ⋅ ⋅ = ⋅ ⋅

Q T M G T M M G

T M M G T M G

1 3 3 13 6 3 03 3 0 01 0 0 0

b h hb

− −⎡ ⎤⎢ ⎥−⎢ ⎥= =−⎢ ⎥⎢ ⎥⎣ ⎦

M M M

( ) b bt = ⋅ ⋅Q T M G

Page 23: Parametric Curves - University of Washington

23

Bézier Blending Functions

a.k.a. Bernstein polynomials

1 1

2 2

3 3

4 4

( 3 1) 2

1 3 3 13 6 3 0

( )3 3 0 01 0 0 0

bt t tt t⎡ ⎤⎣ ⎦=

− −⎡ ⎤⎢ ⎥−⎢ ⎥−⎢ ⎥⎢ ⎥

⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥

⎣ ⎦⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦

Q

P PP PP PP P

B

1

B3

1

B2

B1 B4

t

Bb(t)

Page 24: Parametric Curves - University of Washington

24

Alternative Bézier Formulation

3

0

33(1( )) i

i

i it ti

Q t P=

−⎛ ⎞−⎜ ⎟=

⎝ ⎠∑

1

2

3

4

3 2 1( )

1 3 3 13 6 3 03 3 0 01 0 0 0

t t tt ⎡ ⎤⎣= ⎦

− −⎡ ⎤⎢ ⎥−⎢ ⎥−⎢ ⎥

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

⎢ ⎥⎣ ⎦

Q

PPPP

0( )) (1

n

ii

i n iQ tt Pnt

i=

−⎛⎟=⎞

−⎜⎝ ⎠

Page 25: Parametric Curves - University of Washington

25

More complex curves

Suppose we want to draw a more complex curve.

Why not use a high-order Bézier?

Instead, we’ll splice together a curve from individual segments that are cubic Béziers.

Why cubic?

There are three properties we’d like to have in our newly constructed splines…

Page 26: Parametric Curves - University of Washington

26

Local control

One problem with Béziers is that every control point affects every point on the curve (except the endpoints).

Moving a single control point affects the whole curve!

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

Page 27: Parametric Curves - University of Washington

27

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.

We’d like to have a spline that is interpolating, that is, that always passes through every control point.

Page 28: Parametric Curves - University of Washington

28

Ensuring continuity

Let’s look at continuity first.

Since the functions defining a Bézier curve are polynomial, all their derivatives exist and are continuous.

Therefore, we only need to worry about the derivatives at the endpoints of the curve.

First, we’ll rewrite our equation for Q(t) in matrix form:

0

13 2

2

3

1 3 3 13 6 3

( ) 13 31

PP

Q t t t tPP

− − ⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥− ⎢ ⎥⎢ ⎥⎡ ⎤= ⎣ ⎦ − ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

⎣ ⎦ ⎣ ⎦

Page 29: Parametric Curves - University of Washington

29

Ensuring C2 continuity

Suppose we want to join two cubic Bézier curves (V0,V1,V2,V3) and (W0,W1,W2,W3) so that there is C2 continuity at the joint.

3 0

3 2 1 0

1 2 3 0

2 1 3

2

2

1

(1) (0)

(1) (0)

(1 0 2

4

(

4

) ) 2

v w

v w

v w

W

Q Q V W

Q Q V V W W

Q Q V V V W

V V

W W

V

= ⇒ =

ʹ′ ʹ′= ⇒ − = −

ʹ′ʹ′ ʹ′ʹ′= ⇒ − +

+

=

=

+

W0

W1 W2

W3

1 0

3 2

0 1 2

1 2 3

(0) 3( )(1 ) 3( )(0) 6( 2 )(1 ) 6( 2 )

Q V VQ V VQ V V VQ V V V

ʹ′ = −

ʹ′ = −

ʹ′ʹ′ = − +

ʹ′ʹ′ = − +

Page 30: Parametric Curves - University of Washington

30

A-frames and continuity

Let’s try to get some geometrical intuition about what this last continuity equation means.

If a and b are points, what is (2a-b)?

0V

1V 2V

3 0V W=

1W

2W

1B

3W

( ) ( )1

2

2 1 3

1

2

3 2 2 1

4 42 2 2

W

W V V VV V V

B

V

W

= + −

= − − −14 2 43 14 2 431 4 4 44 2 4 4 4 43

Page 31: Parametric Curves - University of Washington

31

Building a complex spline

Instead of specifying the Bézier control points themselves, let’s specify the corners of the A-frames in order to build a C2 continuous spline.

These are called B-splines. The starting set of points are called de Boor points.

Page 32: Parametric Curves - University of Washington

32

B-splines Here is the completed B-spline.

What are the Bézier control points, in terms of the de Boor points?

0 0 1 0 1 2 1

1 1 2 1

2 0 1 0

3

1 2 1( ) ( )2 3 3

1 ( )32 ( )3

...

V B B B B B B

V B B B

V B B B

V

⎛ ⎞= + − + + −⎜ ⎟⎝ ⎠

= + −

= + −

=

Page 33: Parametric Curves - University of Washington

33

Endpoints of B-splines

We can see that B-splines don’t interpolate the de Boor points.

It would be nice if we could at least control the endpoints of the splines explicitly.

There’s a hack to make the spline begin and end at control points by repeating them.

Page 34: Parametric Curves - University of Washington

34

B-spline basis matrix

1

2

3

4

13 2 16

( )

1 3 3 13 6 3 03 0 3 01 4 1 0

t t tt ⎡= ⎤⎣ ⎦

− −⎡ ⎤⎢ ⎥−⎢ ⎥−⎢ ⎥

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

⎢ ⎥⎣ ⎦

Q

PPPP

Page 35: Parametric Curves - University of Washington

35

A third option

If we’re willing to sacrifice C2 continuity, we can get interpolation and local control.

Instead of finding the derivatives by solving a system of continuity equations, we’ll just pick something arbitrary but local.

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

Page 36: Parametric Curves - University of Washington

36

Catmull-Rom splines

The math for Catmull-Rom splines is pretty simple:

0 1 0

11 2 02

12 3 12

1

( )( )

n n n

D C CD C CD C C

D C C −

= −

= −

= −

= −

M

Page 37: Parametric Curves - University of Washington

37

Catmull-Rom basis matrix

1

2

3

4

13 2 12

( )

1 3 3 12 5 4 11 0 1 00 2 0 0

t t tt = ⎡ ⎤⎣ ⎦

− −⎡ ⎤⎢ ⎥− −⎢ ⎥

−⎢ ⎥⎢ ⎥⎣ ⎦

⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

Q

PPPP

Page 38: Parametric Curves - University of Washington

38

C2 interpolating splines

Interpolation is a really handy property to have.

How can we keep the C2 continuity we get with B-splines but get interpolation, too?

Here’s the idea behind C2 interpolating splines. Suppose we had cubic Béziers connecting our control points C0, C1, C2, …, and that we somehow knew the first derivative of the spline at each point.

What are the V and W control points in terms of Cs and Ds?

Page 39: Parametric Curves - University of Washington

39

Derivatives at the endpoints

In general, the nth derivative at an endpoint depends only on the n+1 points nearest that endpoint.

1 0

3 2

0 1 2

1 2 3

(0) 3( )(1 ) 3( )(0) 6( 2 )(1 ) 6( 2 )

Q V VQ V VQ V V VQ V V V

ʹ′ = −

ʹ′ = −

ʹ′ʹ′ = − +

ʹ′ʹ′ = − +

[ ]

0

1

2

3

1 3 3 13 6 3

( ) 6 2 0 03 31

VV

Q t tVV

− − ⎡ ⎤⎡ ⎤⎢ ⎥⎢ ⎥− ⎢ ⎥⎢ ⎥ʹ′ʹ′ =

− ⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

⎣ ⎦ ⎣ ⎦

Page 40: Parametric Curves - University of Washington

40

Finding the derivatives

Now what we need to do is solve for the derivatives. To do this we’ll use the C2 continuity requirement.

0 0

11 0 03

12 1 13

3 1

V CV C DV C DV C

=

= +

= −

=

0 1

11 1 13

12 2 23

3 2

W CW C DW C DW C

=

= +

= −

=

1 2 3 0 1 2

0 1 2 2 0

6( 2 ) 6( 2 )

4 3( )

V V V W W W

D D D C C

− + = − +

+ + = −

Page 41: Parametric Curves - University of Washington

41

Finding the derivatives, cont.

Here’s what we’ve got so far:

How many equations is this?

How many unknowns are we solving for?

0 1 2 2 0

1 2 3 3 1

2 1 2

4 3( )4 3( )

4 3( )m m m m m

D D D C CD D D C C

D D D C C− − −

+ + = −

+ + = −

+ + = −

M

Page 42: Parametric Curves - University of Washington

42

Not quite done yet

We have two additional degrees of freedom, which we can nail down by imposing more conditions on the curve.

There are various ways to do this. We’ll use the variant called natural C2 interpolating splines, which requires the second derivative to be zero at the endpoints.

This condition gives us the two additional equations we need. At the C0 endpoint, it is:

0 1 26( 2 ) 0V V V− + =

Page 43: Parametric Curves - University of Washington

43

Solving for the derivatives

Let’s collect our m+1 equations into a single linear system:

It’s easier to solve than it looks.

We can use forward elimination to zero out everything below the diagonal, then back substitution to compute each D value.

0 1 0

1 2 0

2 3 1

1 2

1

3( )2 13( )1 4 13( )1 4 1

3( )1 4 13( )1 2

m m m

m m m

D C CD C CD C C

D C CD C C

− −

−⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥ −⎢ ⎥ ⎢ ⎥⎢ ⎥

−⎢ ⎥ ⎢ ⎥⎢ ⎥=⎢ ⎥ ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥ −⎢ ⎥ ⎢ ⎥⎢ ⎥ −⎣ ⎦ ⎣ ⎦ ⎣ ⎦

M MO

Page 44: Parametric Curves - University of Washington

44

Forward elimination

2 11 4 11 4 1

1 4 11 2

2 1(1/ 2)0 7 / 2 1

1 4 1

1 4 11 2

0 0

1 1

2 2

m-1 m-1

m m

0 0 0

1 1 1 0

2 2

m-1 m-1

m m

=

== -

=

⎡ ⎤ ⎡ ⎤⎡ ⎤⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥⎢ ⎥ ⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

⎡ ⎤ ⎡⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥

⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣

D ED ED E

D ED E

D F ED F E ED E

D ED E

M MO

M MO

⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎦

First, we eliminate the elements below the diagonal:

Page 45: Parametric Curves - University of Washington

45

The resulting matrix is upper diagonal:

We can now solve for the unknowns by back substitution:

Back subsitution

UD = F

11 1m 0 0

1 1

2 2

m-1 m-1

mm m m

u … u

=

u

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦ ⎣ ⎦

D FD FD F

D FD F

O M M M

mm m m

m-1m-1 m-1 m-1m m m-1

u =u +u =

D FD D F

Page 46: Parametric Curves - University of Washington

46

C2 interpolating spline

Once we’ve solved for the real Dis, we can plug them in to find our Bézier control points and draw the final spline:

Have we lost anything?

Page 47: Parametric Curves - University of Washington

47

What if we want a closed curve, i.e., a loop?

With Catmull-Rom and B-spline curves, this is easy:

Page 48: Parametric Curves - University of Washington

48

Displaying Bézier curves

How could we draw one of these things?

It would be nice if we had an adaptive algorithm, that would take into account flatness.

DisplayBezier( V0, V1, V2, V3 )

begin if ( FlatEnough( V0, V1, V2, V3 ) ) Line( V0, V3 ); else do something smart; end;

Page 49: Parametric Curves - University of Washington

49

Subdivide and conquer

DisplayBezier( V0, V1, V2, V3 )

begin if ( FlatEnough( V0, V1, V2, V3 ) ) Line( V0, V3 ); else Subdivide(V) ⇒ L, R DisplayBezier( L0, L1, L2, L3 ); DisplayBezier( R0, R1, R2, R3 ); end;

Page 50: Parametric Curves - University of Washington

50

Testing for flatness

Compare total length of control polygon to length of line connecting endpoints:

0 1 1 2 2 3

0 3

1V V V V V V

V Vε

− + − + −< +

Page 51: Parametric Curves - University of Washington

51

Curves in Animator Project

One of the requirements is to implement “wrapping” so that the animation restarts smoothly when looping back to the beginning.

This is a lot like making a closed curve: the calculations for the θ -coordinate are exactly the same.

The t-coordinate is a little trickier: you need to create “phantom” t-coordinates before and after the first and last coordinates.

Page 52: Parametric Curves - University of Washington

52

Curves in Animator Project In the animator project, you will draw a curve on the screen: You will actually treat this curve as:

Where θ is a variable you want to animate. We can think of the result as a function:

You have to apply some constraints to make sure that θ(t) actually is a function.

( )=( ) ( ), ( )u x u y uQ

θ =

=

( ) ( )( ) ( )u y u

t u x u

θ( )t

Page 53: Parametric Curves - University of Washington

53

Summary

• Enforcing constraints on cubic functions

• The meaning of basis matrix and geometry vector

• General procedure for computing the basis matrix

• Properties of Hermite and Bézier splines

• The meaning of blending functions

• Enforcing continuity across multiple curve segments

• How to display Bézier curves with line segments.

• Meanings of Ck continuities.

• Geometric conditions for continuity of cubic splines.

• Properties of C2 interpolating splines, B-splines, and Catmull-Rom splines.