object 3d(2)

59
Graphics cgvr.korea.ac.kr Graphics Lab @ Korea University Parametric Curves 고고고고고 고고고 고고고고 고고고

Upload: hiteshjain007

Post on 13-Jan-2015

670 views

Category:

Education


5 download

DESCRIPTION

Computer Graphics topic: Object 3d(2)

TRANSCRIPT

Page 1: object 3d(2)

Graphics

cgvr.korea.ac.kr Graphics Lab @ Korea University

Parametric Curves

고려대학교 컴퓨터 그래픽스 연구실

Page 2: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Overview

Introduction to mathematical splines Bezier curves Continuity conditions (C0, C1, C2, G1, G2) Creating continuous splines

C2-interpolating splines B-splines Catmull-Rom splines

Page 3: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Introduction

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

Such splines have been used for designing: Automobiles Ship hulls Aircraft fuselages and wings

Page 4: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Requirements

Here are some requirements we might like to have in our mathematical splines: Predictable control Multiple values Local control Versatility Continuity

Page 5: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Mathematical Splines

The mathematical splines we’ll use are: Piecewise Parametric Polynomials

Let’s look at each of these terms…

Page 6: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Parametric Curves

In general, a “parametric” curve in the plane is expressed as:

Example: A circle with radius r centered at the origin is given by:

By contrast, an “implicit” representation of the circle is:

trx cos try sin

222 ryx

tXx tYy

Page 7: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Parametric Polynomial Curves

A parametric “polynomial” curve is a parametric curve where each function x(t), y(t) is described by a polynomial:

Polynomial curves have certain advantages Easy to compute Infinitely differentiable

n

i

iitax

0

n

i

iitby

0

Page 8: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Piecewise Parametric Polynomial Curves

A “piecewise” parametric polynomial curve uses different polynomial functions for different parts of the curve Advantage: Provides flexibility Problem: How do you guarantee smoothness at the j

oints? (Problem known as “continuity”)

In the rest parts of this lecture, we’ll look at: Bezier curves – general class of polynomial curves Splines – ways of putting these curves together

Page 9: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Bezier Curves

Developed simultaneously by Bezier (at Renault) and by deCasteljau (at Citroen), circa 1960

The Bezier Curve Q(u) is defined by nested interpolation:

Vis are “control points” {V0, …, Vn} is the “control polygon”

niuuBuBuB ninini 1 ,1 1,11,,

iii

ii uBuB 1 , ,0,

10 ,0

,

uuBVuQn

inii

Page 10: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Example: Bezier Curves

uBVuBVuQn 1,111,00 ,1

uVuV 10 1 uBVuBVuBVuQn 2,222,112,00 ,2

222,11

20 1 uVuBVuV

iii uB ,

ii uB 1,0

uuBuBuuB 1,01,12,1 1

uuBuBuB ninini 1,11,, 1

221

20 121 uVuuVuV

10 ,0

,

uuBVuQn

inii

Page 11: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Bezier Curves: Basic Properties

Bezier Curves enjoy some nice properties: Endpoint interpolation:

Convex hull: The curve is contained in the convex hull of its control polygon

Symmetry: Q(u) is defined by {V0, …, Vn}

≡ Q(1-u) is defined by {Vn, …, V0}

00 VQ nVQ 1

Page 12: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Example: 2D Bezier Curves

Page 13: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Bezier Curves: Explicit Formulation

Let’s give Vi a superscript Vij to indicate the level

of nesting An explicit formulation Q(u) is given by the recur

rence:

11

11

ji

ji

ji uVVuV

Page 14: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Explicit Formulation (cont.)

For n=2, we have:

In general:

20VuQ

0

220

10

02

02

01

01

00

11

10

121

111

1

VuVuuVu

uVVuuuVVuu

uVVu

n

i

inii uui

nVuQ

01 uBni

is the i ‘th Bernstein polynomial of degree n

uBni

Page 15: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Example: Explicit Formulation

30VuQ

21

201 uVVu

12

11

11

10 111 uVVuuuVVuu

0

30

20

20

1

02

01

01

00

111

1111

uVVuuuVVuuu

uVVuuuVVuuu

03

302

201

200

3 13131 VuVuuuVuVu

03

333

02

223

01

213

00

303 111

,3For

VuCVuuCVuuCVuCuQ

n

n

i

inii uui

nVuQ

01

Page 16: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Bezier Curves: More Properties

Here are some more properties of Bezier curves

Degree: Q(u) is a polynomial of degree n Control points: How many conditions must we specify

to uniquely determine a Bezier curve of degree n

n

i

inii uui

nVuQ

01

Page 17: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

More Properties (cont.)

Tangent:

k ‘th derivatives: In general, Q(k)(0) depends only on V0, …, Vk

Q(k)(1) depends only on Vn, …, Vn-k

At intermediate points , all control points are involved every derivative

010 VVnQ

11 nn VVnQ

Page 18: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Explanation

nn

nnnn

nnn

nn

n

n

i

inii

VuCVuuCVuuCVuC

uui

nVuQ

11

111

100

0

111

1

n

nnnn

nnnn

nnn

nn

nn

nn

VuCnVuCVuuCn

VuuCnVuCVuCnuQ1

11

112

1

12

111

101

0

11

1111

10

10

11

101

0 01010

VVn

nVnV

VCVCnQ nn

nn

1

1

11

11 111

nn

nn

nn

nnnn

nn

VVn

nVnV

VCnVCQ

Page 19: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Cubic Curves

For the rest of this discussion, we’ll restrict ourselves to piecewise cubic curves In CAGD, higher-order curves are often used

Gives more freedom in design Can provide higher degree of continuity between pieces

For Graphics, piecewise cubic lets you do about anything

Lowest degree for specifying points to interpolate and tangents

Lowest degree for specifying curve in space

All the ideas here generalize to higher-order curves

Page 20: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Matrix Form of Bezier Curves

Bezier curves can also be described in matrix form:

3

2

1

0

23

3

2

1

0

23

33

22

12

03

3

0

3

1

0001

0033

0363

1331

1

13131

13

V

V

V

V

uuu

V

V

V

V

uuu

VuVuuVuuVu

uui

VuQ

Bezier

i

iii

M

Page 21: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Display: Recursive Subdivision

Q: Suppose you wanted to draw one of these Bezier curves – how would you do it?

A: Recursive subdivision

Page 22: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Display (cont.)

Here’s pseudo code for the recursive subdivision display algorithm

Procedure DisplayDisplay({V0, …, Vn})

if {V0, …, Vn} flat within e then

Output line segment V0Vn

else

Subdivide to produce {L0, …, Ln} and {R0, …, Rn}

DisplayDisplay({L0, …, Ln})

DisplayDisplay({R0, …, Rn})

end if

end procedure

Page 23: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Splines

To build up more complex curves, we can piece together different Bezier curves to make “splines”

For example, we can get: Positional (C0) Continuity:

Derivative (C1) Continuity:

Q: How would you build an interactive system to satisfy these conditions?

01 ,10 11 nnnn QQQQ

01 ,10

01 ,10

11

11

nnnn

nnnn

QQQQ

QQQQ

Page 24: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Advantages of Splines

Advantages of splines over higher-order Bezier curves: Numerically more stable Easier to compute Fewer bumps and wiggles

Page 25: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Tangent (G1) Continuity

Q: Suppose the tangents were in opposite directions but not of same magnitude – how does the curves appear?

This construction gives “tangent (G1) continuity” Q: How is G1 continuity different from C1?

01 ,10

01 ,10

1211

11

nnnn

nnnn

QkQQkQ

QQQQ

Page 26: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Explanation

Positional (C0) continuity

Derivative (C1) continuity

Tangent (G1) continuity

Qn(u)

Qn(u)

Qn(u)

Qn+1(u)

Qn+1(u)

Qn+1(u)

Page 27: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Curvature (C2) Continuity

Q: Suppose you want even higher degrees of continuity – e.g., not just slopes but curvatures – what additional geometric constraints are imposed?

We’ll begin by developing some more mathematics.....

01 ,10

01 ,10

01 ,10

11

11

11

nnnn

nnnn

nnnn

QQQQ

QQQQ

QQQQ

Page 28: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Operator Calculus

Let’s use a tool known as “operator calculus” Define the operator D by:

Rewriting our explicit formulation in this notation gives:

Applying the binomial theorem gives:

1 ii VDV

n

ii

ini Vuui

nuQ

01

n

ii

inin

ii

ini VuuDi

nVDuu

i

n

000 11

01 VuuDuQ n

Page 29: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Taking the Derivative

One advantage of this form is that now we can take the derivative:

What’s (D-1)V0? Plugging in and expanding:

This gives us a general expression for the derivative Q’(u)

1

001

111n

ii

ini VVDuui

nnuQ

01 11 VDuuDnuQ n

Page 30: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Specializing to n=3

What’s the derivative Q’(u) for a cubic Bezier curve?

Note that: When u=0: Q’(u) = 3(V1-V0) When u=1: Q’(u) = 3(V3-V2)

Geometric interpretation:

So for C1 continuity, we need to set:

02 113 VDuuDuQ

02

0

131

130

VDDQ

VDQ

0123 33 WWVV

Q’(1)Q’(0)

V0V1

V2 V3

W0

W1

W2

W3

Page 31: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Taking the Second Derivative

Taking the derivative once again yields:

What does (D-1)2 do?

022 111 VDuuDnnuQ n

Page 32: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Second-Order Continuity

So the conditions for second-order continuity are:

Putting these together gives:

Geometric interpretation

01121223

0123

WWWWVVVV

WWVV

321112232

230231

442

2

VVVWVVVVW

VVWVVW

30 VW

Q’’(1)

Q’’(0)

Q’(0)Q’(1)

V0

V1

V2V3

Page 33: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3

Page 34: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3 W0

W1 W2

W3

30 VW

Page 35: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3 W0

W1 W2

W3

30 VW

231 2 VVW

Page 36: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3 W0

W1

W2

W3

30 VW

231 2 VVW

3212 44 VVVW

Page 37: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3

30 VW

231 2 VVW

3212 44 VVVW

01233 6128 VVVVW W0

W1

W2W3

Page 38: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C3 Continuity

Summary of continuity conditions C0 straightforward, but generally not enough C3 is too constrained (with cubics)

033 1121 VDuuDnnnuQ n

V0

V1 V2

V3

30 VW

231 2 VVW

3212 44 VVVW

01233 6128 VVVVW W0

W1

W2W3

Page 39: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Creating Continuous Splines

We’ll look at three ways to specify splines with C1 and C2 continuity C2 interpolating splines B-splines Catmull-Rom splines

Page 40: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C2 Interpolating Splines

The control points specified

by the user, called “joints”,

are interpolated by the spline For each of x and y, we needed to specify 3 con

ditions for each cubic Bezier segment. So if there are m segments, we’ll need 3m-1 co

nditions Q: How many these constraints are determined

by each joint?

joint

Page 41: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

In-Depth Analysis

At each interior joint j, we have: Last curve ends at j Next curve begins at j Tangents of two curves at j are equal Curvature of two curves at j are equal

The m segments give: m-1 interior joints 3 conditions

The 2 end joints give 2 further constraints: First curve begins at first joint Last curve ends at last joint

Gives 3m-1 constraints altogether

Page 42: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

End Conditions

The analysis shows that specifying m+1 joints for m segments leaves 2 extra degree of freedom

These 2 extra constraints can be specified in a variety of ways: An interactive system

Constraints specified as user inputs

“Natural” cubic splines Second derivatives at endpoints defined to be 0

Maximal continuity Require C3 continuity between first and last pairs of curves

Page 43: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

C2 Interpolating Splines

Problem: Describe an interactive system for specifying C2 interpolating splines

Solution:1. Let user specify first four Bezier control points

2. This constraints next 2 control points – draw these in.

3. User then picks 1 more

4. Repeat steps 2-3.

Page 44: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Global vs. Local Control

These C2 interpolating splines yield only “global control” – moving any one joint (or control point) changes the entire curve!

Global control is problematic: Makes splines difficult to design Makes incremental display inefficient

There’s a fix, but nothing comes for free. Two choices: B-splines

Keep C2 continuity Give up interpolation

Catmull-Rom Splines Keep interpolation Give up C2 continuity – provides C1 only

Page 45: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

B-Splines

Previous construction (C2 interpolating splines): Choose joints, constrained by the “A-frames”

New construction (B-splines): Choose points on A-frames Let these determine the rest of Bezier control points

and joints

The B-splines I’ll describe are known more precisely as “uniform B-splines”

Page 46: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Explanation

C2 interpolating spline

B-splines

V0V1

V2

B0

B1

B2

B3

V0

V1V2 V3

Page 47: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

B-Spline Construction

uBuu

uuuB

uu

uuuB

uuuuB

dkkdk

dkdk

kdk

kdk

kkk

1,11

1,1

,

11, otherwise,0

if,1

n+1 control points

12 , , maxmin0

,

nduuuuBpuPn

kdkk

polynomials of degree d-1

Page 48: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

B-Spline Construction

The points specified by the user in this construction are called “deBoor points”

uBuu

uuuB

uu

uuuB

uuuuB

dkkdk

dkdk

kdk

kdk

kkk

1,11

1,1

,

11, otherwise,0

if,1

n+1 control points

12 , , maxmin0

,

nduuuuBpuPn

kdkk

polynomials of degree d-1

Page 49: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

B-Spline Properties

Here are some properties of B-splines: C2 continuity

Approximating Does not interpolate deBoor points

Locality Each segment determined by 4 deBoor points Each deBoor point determine 4 segments

Convex hull Curves lies inside convex hull of deBoor points

Page 50: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Algebraic Construction of B-Splines

V1 = (1 - 1/3)B1 + 1/3 B2

V2 = (1- 2/3)B1 + 2/3 B2

V0 = ½ [(1- 2/3)B0 + 2/3 B1] + ½ [(1 - 1/3)B1 + 1/3 B2]

= 1/6 B0 + 2/3 B1 + 1/6 B2

V3 = 1/6 B1 + 2/3 B2 + 1/6 B3

3

3,323

3,2

223,1

33,0

6

1,1333

6

1

,4636

1,1

6

1

uuFuuuuF

uuuFuuF

uFBuFBuFBuFB

uFBuPk

kk

3,333,223,113,00

3

03,

Page 51: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Algebraic Construction of B-Splines (cont.)

Once again, this construction can be expressed in terms of a matrix:

3

2

1

0

3

2

1

0

1410

0420

0240

0141

6

1

B

B

B

B

V

V

V

V

Page 52: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Drawing B-Splines

Drawing B-splines is therefore quite simple

Procedure Draw-B-Spline Draw-B-Spline ({B0, …, Bn})

for i=0 to n-3 do

Convert Bi, …, Bi+3 into a Bezier control p

olygon V0, …, V3

DisplayDisplay({V0, …, Vn})

end for

end procedure

Page 53: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Multiple Vertices

Q: What happens if you put more than one control point in the same place?

Some possibilities: Triple vertex Double vertex Collinear vertices

Page 54: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

End Conditions

You can also use multiple vertices at the endpoints Double endpoints

Curve tangent to line between first distinct points

Triple endpoints Curve interpolates endpoint Start out with a line segment

Phantom vertices Gives interpolation without line segment at ends

Page 55: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Catmull-Rom Splines

The Catmull-Rom splines Give up C2 continuity Keep interpolation

For the derivation, let’s go back to the interpolation algorithm. We had a conditions at each joint j: 1. Last curve end at j 2. Next curve begins at j 3. Tangents of two curves at j are equal 4. Curvature of two curves at j are equal

If we… Eliminate condition 4 Make condition 3 depend only on local control points

… then we can have local control!

Page 56: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Derivation of Catmull-Rom Splines

Idea: (same as B-splines) Start with joints to interpolate Build a cubic Bezier curve between successive points

The endpoints of the cubic Bezier are obvious:

Q: What should we do for the other two points?23

10

BV

BV

B1=V3=V0

B3B0

B2

Page 57: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Derivation of Catmull-Rom (cont.)

A: Catmull & Rom use half the magnitude of the vector between adjacent control points:

Many other choices work – for example, using an arbitrary constant t times this vector gives a “tension” control

B1=V3=V0

B3B0

B2

Page 58: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Matrix Formulation

The Catmull-Rom splines also admit a matrix formulation:

Exercise: Derive this matrix

3

2

1

0

3

2

1

0

0600

1610

0161

0060

6

1

B

B

B

B

V

V

V

V

Page 59: object 3d(2)

cgvr.korea.ac.kr

CGVR

Graphics Lab @ Korea University

Properties

Here are some properties of Catmull-Rom splines: C1 continuity Interpolating Locality NoNo convex hull property