greg humphreys cs445: intro graphics university of virginia, fall 2003 parametric curves &...

27
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring 2002

Upload: blaze-roberts

Post on 19-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Greg Humphreys

CS445: Intro Graphics

University of Virginia, Fall 2003

ParametricCurves & Surfaces

Greg Humphreys

University of Virginia

CS 445, Spring 2002

Page 2: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Overview

Today: Curves

Next Time: Surfaces

Przemyslaw Prusinkiewicz

Page 3: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Curves• Splines: mathematical way to express curves

• Motivated by “loftsman’s spline” Long, narrow strip of wood/plastic Used to fit curves through specified data points Shaped by lead weights called “ducks” Gives curves that are “smooth” or “fair”

• Have been used to design: Automobiles Ship hulls Aircraft fuselage/wing

Page 4: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Many applications in graphics

•FontsABC

• Animation paths

• Shape modeling

• etc…

Animation(Angel, Plate 1)

Shell(Douglas Turnbull)

Page 5: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Goals• Some attributes we might like to have:

Predictable control Local control Versatility Continuity

• We’ll satisfy these goals using: Piecewise Parametric Polynomials

Page 6: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Parametric curves

A parametric curve in the plane is expressed as:

x = x(u)y = y(u)

Example: a circle with radius r centered at origin:

x = r cos uy = r sin u

In contrast, an implicit representation is:

x2 + y2 = r2

Page 7: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Parametric polynomial curves• A parametric polynomial curve is:

• Advantages of polynomial curves Easy to compute Easy differentiation

n

i

iiuaux

0

)(

n

i

iiubuy

0

)(

Page 8: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Piecewise parametric polynomials• Use different polynomial functions

on different parts of the curve

Provides flexibility How do you guarantee continuity/smoothness

at join points (called knots)?

• In the rest of this lecture, we’ll look at:

Bézier curves: general class of polynomial curves Splines: ways of putting these curves together

Page 9: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Bézier curves• Developed independently in 1960s by

Bézier (at Renault) deCasteljau (at Citroen)

• Curve Q(u) is defined by nested interpolation:

Vi’s are control points{V0, V1, …, Vn} is control polygon

V0

V1V2

V3

Q(u)

Page 10: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Basic properties of Bézier curves• Endpoint interpolation:

• Convex hull: Curve is contained within convex hull of control polygon

• Transformational invariance

• Symmetry

0)0( VQ

nVQ )1(

},...,{by defined )1( },...,{by defined )( 00 VVuQVVuQ nn

Page 11: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Explicit formulation• Let’s indicate level of nesting with superscript j:

• An explicit formulation of Q(u) is given by:

11

1)1(

ji

ji

ji uVVuV

00V

01V

02V

03V

30V

10V

11V

12V

20V

21V

Page 12: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Explicit formulation• Let’s indicate level of nesting with superscript j:

• An explicit formulation of Q(u) is given by:

• Case n=2 (quadratic):

11

1)1(

ji

ji

ji uVVuV

02

201

00

2

02

01

01

00

11

10

20

)1(2)1(

])1[(])1)[(1(

)1(

)(

VuVuuVu

uVVuuuVVuu

uVVu

VuQ

Page 13: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

More properties• General case: Bernstein polynomials

• Degree: polynomial of degree n

• Tangents:

)()1('

)()0('

1

01

nn VVnQ

VVnQ

inin

ii uu

i

nVuQ

)1( )(

0

Page 14: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Display

Q: How would you draw it using line segments?

A: Recursive subdivision!

When do you stop?

V0

V1V2

V3

Page 15: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Flatness

Q: How do you test for flatness?

A: Compare the length of the control polygon to the length of the segment between endpoints

1

||

||||||

03

231201

VV

VVVVVV

V0

V1V2

V3

(…or, compare dot products…)

Page 16: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Cubic curves

• From now on, let’s talk about cubic curves (n=3)

• In CAGD, higher-order curves are often used

• In graphics, piecewise cubic curves will do Specified by points and tangents Allows specification of a curve in space

• All these ideas generalize to higher-order curves

Page 17: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Hermite Curves• Given: two points and two tangent vectors

Similarity to cubic Bézier curves Other two Bézier control points along those tangents

• Call the points P1 and P2, and the tangents R1 and R2

• So given two points and vectors, find the coefficients of and

• Hermite curves pass through all the points, and they have C1 continuity

012

23

3)( atatatatx 012

23

3)( btbtbtbty

Page 18: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Hermite Curves (Cont.)• Finding those coefficients is pretty straightforward.

Just write down what we know so far:

3 2 1

3 2 1 0 0

3 2 1

3 2 1 0 3 2 1 0

2 1

3 2 1 1

2 1

3 2 1 3 2 1

(0) 0 0 0

(1) 1 1 1

(0) 3 0 2 0 1

(1) 3 1 2 1 1 3 2

x a a a a a

x a a a a a a a a

x a a a a

x a a a a a a

Page 19: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Hermite Curves (Cont.)• What’s going on here? Write:

• Stuff from last slide gives:

(0) 0 0 0 1

(1) 1 1 1 1

(0) 0 0 1 0

(1) 3 2 1 0

x

x

x

x

x C

x C

x C

x C

3

23 2

1

0

( ) 1

a

ax t t t t

a

a

Page 20: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

The Hermite Matrix• Put it all into a matrix and invert it to solve!

1

2

1

2

1

2

1

2

0 0 0 1

1 1 1 1

0 0 1 0

3 2 1 0

2 2 1 1

3 3 2 1

0 0 0 1

1 0 0 0

x

x

x

x

x

x

x

x

x

x

P

PC

T

T

P

PC

T

T

Page 21: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Splines• For more complex curves, piece together cubics

• We want continuity across joints: Positional (C0) continuity Derivative (C1) continuity

• Q: How would you satisfy continuity constraints?

• Q: Why not just use higher-order Bézier curves?

• A: Splines have several of advantages:

• Numerically more stable

• Easier to compute

• Fewer bumps and wiggles

Page 22: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Catmull-Rom splines• Properties

Interpolate control points Have C0 and C1 continuity

• Derivation Start with joints to interpolate Build cubic Bézier between each joint Endpoints of Bézier curves are obvious

• What should we do for the other Bézier control points?

Page 23: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Catmull-Rom Splines• Catmull & Rom use:

half the magnitude of the vector between adjacent CP’s

• Many other formulations work, for example: Use an arbitrary constant times this vector Gives a “tension” control Could be adjusted for each joint

Page 24: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Properties• Catmull-Rom splines have these attributes:

C1 continuity

Interpolation

Locality of control

No convex hull property

(Proof left as an exercise.)

Page 25: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

B-splines• We still want local control

• Now we want C2 continuity

• Give up interpolation

• Constraints: Three continuity conditions at each joint j

» Position of two curves same» Derivative of two curves same» Second derivatives same

Local control» Each joint affected by 4 CPs

Page 26: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Matrix formulation for B-splines• Grind through some messy math to get:

x

x

x

x

P

P

P

P

Cx

4

3

2

1

0141

0303

0363

1331

6

1

Page 27: Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Parametric Curves & Surfaces Greg Humphreys University of Virginia CS 445, Spring

Assignment 6 Demo