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

Post on 19-Jan-2016

218 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Greg Humphreys

CS445: Intro Graphics

University of Virginia, Fall 2003

ParametricCurves & Surfaces

Greg Humphreys

University of Virginia

CS 445, Spring 2002

Overview

Today: Curves

Next Time: Surfaces

Przemyslaw Prusinkiewicz

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

Many applications in graphics

•FontsABC

• Animation paths

• Shape modeling

• etc…

Animation(Angel, Plate 1)

Shell(Douglas Turnbull)

Goals• Some attributes we might like to have:

Predictable control Local control Versatility Continuity

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

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

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

)(

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

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)

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

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

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

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

Display

Q: How would you draw it using line segments?

A: Recursive subdivision!

When do you stop?

V0

V1V2

V3

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…)

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

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

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

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

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

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

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?

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

Properties• Catmull-Rom splines have these attributes:

C1 continuity

Interpolation

Locality of control

No convex hull property

(Proof left as an exercise.)

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

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

Assignment 6 Demo

top related