Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer...

36
Computer Graphics - Week 9 Computer Graphics - Week 9 Bengt-Olaf Schneider Bengt-Olaf Schneider IBM T.J. Watson Research Center IBM T.J. Watson Research Center © Bengt-Olaf Schneider, 1999 Computer Graphics – Week 9 Questions about Last Week ? Questions about Last Week ?

Transcript of Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer...

Page 1: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

Computer Graphics - Week 9Computer Graphics - Week 9

Bengt-Olaf SchneiderBengt-Olaf SchneiderIBM T.J. Watson Research CenterIBM T.J. Watson Research Center

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Questions about Last Week ?Questions about Last Week ?

Page 2: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Overview of Week 9Overview of Week 9

The second half of the course will be spent on studying a variety of advanced topics in computer graphics

Freeform curves and surfacesHermite curves and surfacesBézier curvesB-splines curves

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Freeform Curves and SurfacesFreeform Curves and Surfaces

Page 3: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Freeform Curves and SurfacesFreeform Curves and Surfaces

Polygons and polyhedra usually provide only crude approximations of real objects

Real objects have smooth surfaces not faceted surfacesSuch surfaces are better described by higher-order functions

Freeform curves and surfacesRepresent non-linear functionsMore compact representation than polygonsBetter control over shape, tangent direction and slope

We will look at various ways to represent freeform curves and surfaces

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Explicit FunctionsExplicit Functions

Explicit functionsCurves:

Surfaces:

Explicit functions ...do not allow for multiple values for a given argument, e.g. circles or folding surfacescannot describe vertical tangents, as infinite slopes are hard to representare not rotation-invariant, i.e. the rotated version of a curve may require different description. E.g. rotated half-circle.

z f x= ( )

z f x y= ( , )

Page 4: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Implicit FunctionsImplicit Functions

Implicit functionsUse a function that states which points are on and off the curve

We have used implicit functions to define lines and planes

Implicit functions ...do not have some of the problems of explicit functionsare hard to find for many shapes and curvesprovide no control over tangents at connection points when joining several implicit functions

f x y z( , , ) = 0

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Parametric FunctionsParametric Functions

Curves and Surfaces are defined by independent functions in a common parameter

Parametric functions ...avoid the problems of implicit and explicit functionscan provide control over tangent direction at the end points

x x t y y t z z t= = =( ) ( ) ( ) ; ; 010

1

t

x(t)

y(t)

t a

a

a

b

b b

c

c c

dd

d

ee

e

f

ff

Page 5: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

The coordinates can be defined by arbitrary functionsHere we will discuss polynomials of order n

In many cases we will only look at n=3 (cubics)Cubic polynomials allow definition of end points and tangent direction at both endpoints

Q tx t a t b t c t dy t a t b t c t dz t a t b t c t d

t

Q t T C t t t

abcd

abcd

abcd

X X X X

Y Y Y Y

Z Z Z Z

X

X

X

X

Y

Y

Y

Y

Z

Z

Z

Z

( ):( )( )( )

,

( )

= + + += + + += + + +

RS|T|

≤ ≤

= • = •

F

H

GGGG

I

K

JJJJ

3 2

3 2

3 2

3 2

0 1

1

for

c h

Cubic PolynomialsCubic Polynomials

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Tangent VectorsTangent Vectors

Tangent vectors are the derivatives at a given point

Q'(t) is the velocity of t as it moves along the curveQ''(t) is the acceleration of t along the curve

∂∂

= = ∂∂

• = •

F

H

GGGG

I

K

JJJJ=

+ ++ ++ +

F

HGGG

I

KJJJt

Q t Q tt

T C t t

abcd

abcd

abcd

a t b t ca t b t ca t b t c

TX

X

X

X

Y

Y

Y

Y

Z

Z

Z

Z

X X X

Y Y Y

Z Z Z

( ) ' ( ) 3 2 1 03 23 23 2

2

2

2

2

c h

Page 6: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Joining Parametric Curves (1)Joining Parametric Curves (1)

Curves can be defined piecewise using several parametric curve segments

At the joints, we often desire continuity

Geometric continuityG0: Curve segments meet at the jointG1: Tangents at the joint have same directionGn: N-th derivatives have same direction

Parametric continuityCn: N-th derivatives have same magnitude

∂∂

= ⋅∂∂

n

n

n

ntQ k

tP( ) ( )1 0

∂∂

= ∂∂

n

n

n

ntQ

tP( ) ( )1 0

Q k P' ( ) ' ( )1 0= ⋅

Q P( ) ( )1 0=

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Joining Parametric Curves (2)Joining Parametric Curves (2)

Q(t) Q(t)

C : Q’(1)=P’(0)1 G : Q’(1)=3 P’(0)1

t=0 t=0t=1 t=1t=0 t=0

t=1 t=1

P(t) P(t)

Parametric continuity implies geometric continuityThe reverse is not generally trueVisually geometric and parametric continuity differ only slightly

Page 7: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Computing Cubic CurvesComputing Cubic Curves

Each cubic polynomial is described by four parameters

Therefore, we need four conditions to specify those parameters

There are different sets of constraints to provide those four conditions

Hermite Curves: Start and end point, start and end tangent vectorBezier Curves: Start and end point, 2 intermediate pointsB-splines: 4 arbitrary points

We will look at all of these now ...

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Formulating the Constraints (1)Formulating the Constraints (1)

We split the coefficient matrix to express the four required conditions:

The coefficients of G are vectors with x, y, z components, i.e.

M: basis matrixG: geometry vector

Q t t t t

m m m mm m m mm m m mm m m m

GGGG

T M G( ) = •

F

H

GGGG

I

K

JJJJ•

F

H

GGGG

I

K

JJJJ= • •3 2

11 12 13 14

21 22 23 24

31 32 33 34

41 42 43 44

1

2

3

4

1c h

G

GGGG

g g gg g gg g gg g g

X Y Z

X Y Z

X Y Z

X Y Z

=

F

H

GGGG

I

K

JJJJ=

F

H

GGGG

I

K

JJJJ

1

2

3

4

1 1 1

2 2 2

3 3 3

4 4 4

Page 8: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Formulating the Constraints (2)Formulating the Constraints (2)

For instance, for x(t) we get:

Each of the terms in parentheses are cubic polynomialThe constraints giX compute a weighted sum of those four cubics.

Therefore, the functions Gi are also know as blending functions

x t m t m t m t m g

m t m t m t m g

m t m t m t m g

m t m t m t m g

X

X

X

X

( ) = + + + +

+ + + +

+ + + +

+ + +

113

212

31 41 1

123

222

32 42 2

133

232

33 43 3

143

242

34 34 4

c hc hc hc h

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Formulating the Constraints (3)Formulating the Constraints (3)

Now, all that's left is to determine the blending functions G and the basis matrix M.

For that we substitute points or tangent vectors for the blending functions Gi and then determine the coefficients of M.

The actual choice of those points and vectors determines the type of curve.

Page 9: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Curves (1)Hermite Curves (1)

Hermite Curves are defined by start and end point of the curve and the tangent vectors at those points.

(Indices are numbered 1 and 4 to be consistent with other curves that use 4 points to define a curve.)

Recall, the expressions for x(t) and x'(t):

G P P R RHT= 1 4 1 4b g

x t T M G t t t M G

x t T M G t t M G

H HX H HX

H HX H HX

( )

' ( ) '

= • • = • •

= • • = • •

3 2

2

1

3 2 1 0

c hc h

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Curves (2)Hermite Curves (2)

Substituting the start point (t=0) and end point (t=1) into this equation gives:

Substituting the tangent vectors at the start and end points gives:

x P M G

x P M GX H HX

X H HX

( )

( )

0 0 0 0 1

1 1 1 1 11

4

= = • •= = • •

b gb g

x R M G

x R M GX H HX

X H HX

' ( )

' ( )

0 0 0 1 0

1 3 2 1 01

4

= = • •= = • •

b gb g

Page 10: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Curves (3)Hermite Curves (3)

Pulling it all together:

Therefore:

PPRR

G M G

X

X

X

X

HX H HX

1

4

1

4

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

F

H

GGGG

I

K

JJJJ= =

F

H

GGGG

I

K

JJJJ• •

MH =

F

H

GGGG

I

K

JJJJ

=

−− − −F

H

GGGG

I

K

JJJJ

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

1 2 2 1 13 3 2 1

0 0 1 01 0 0 0

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Curves (4)Hermite Curves (4)

MH is the basis matrix for Hermite curves.It describes the blending functions for the geometric constraints G.We find the blending function BH as:

All blending functions have support over the entire interval [0,1].A change in any of the constraints affects the entire curve. The blending functions interpolate the starting and ending points.

Q t T M G B G

t t P t t P

t t t R t t R

H H H H( )

( ) ( )

( ) ( )

= • • = •= − + ⋅ + − + ⋅ +

− + ⋅ + − ⋅2 3 1 2 3

2

3 21

3 24

3 21

3 24

Page 11: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Curves (5)Hermite Curves (5)

The blending functions BH have the following shape

1

0.2

g1 t( )

g2 t( )

g3 t( )

g4 t( )

10 t

0 0.2 0.4 0.6 0.8

0.5

1

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Example of Hermite CurvesExample of Hermite Curves

3

1

y t 4,( )

y t 6,( )

y t 8,( )

y t 10,( )

51 x t 4,( ) x t 6,( ), x t 8,( ), x t 10,( ),1 2 3 4 5

1

2

3 P P R k k R1 4 1 41 1 5 1 0 1= = = = −b g b g b g b g Curves shown for k = 4, 6, 8, 10

Page 12: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Continuity at the joints between Hermite curves can be easily ensured by specifying tangent vectors with the same direction

For geometric continuity

For parametric continuity k = 1

Joining Hermite CurvesJoining Hermite Curves

PPRR

PP

k RR

k

1

4

1

4

4

7

4

7

0

F

H

GGGG

I

K

JJJJ ⋅

F

H

GGGG

I

K

JJJJ> and with

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bicubic Patches (1)Bicubic Patches (1)

Moving a curve through space can create a surfaceIf each of the control points itself moves along a cubic curve as the curve itself is moved, a bicubic patch is generated

P (0)1

P (1)1

P (0)2

P (1)2

P (0)3

P (1)3

P (0)4

P (1)4

t

s

Page 13: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bicubic Patches (2)Bicubic Patches (2)

To describe such patches we start from the expression for parametric, cubic curves ...

... and rename the parameter t to s:

Q t t t t

m m m mm m m mm m m mm m m m

GGGG

T M G( ) = •

F

H

GGGG

I

K

JJJJ•

F

H

GGGG

I

K

JJJJ= • •3 2

11 12 13 14

21 22 23 24

31 32 33 34

41 42 43 44

1

2

3

4

1c h

Q s s s s

m m m mm m m mm m m mm m m m

GGGG

S M G( ) = •

F

H

GGGG

I

K

JJJJ•

F

H

GGGG

I

K

JJJJ= • •3 2

11 12 13 14

21 22 23 24

31 32 33 34

41 42 43 44

1

2

3

4

1c h

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bicubic Patches (3)Bicubic Patches (3)

Q s t S M G t S M

G tG tG tG t

G t T M g T M

gggg

i i

i

i

i

i

( , ) ( )

( )( )( )( )

( )

= • • = • •

F

H

GGGG

I

K

JJJJ

= • • = • •

F

H

GGGG

I

K

JJJJ

1

2

3

4

1

2

3

4

Each of the geometric constraints Gi is itself described by a cubic polynomial

Page 14: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Transposing the expressions for the polynomials gi :

Combining this with expression for the patch Q(s,t):

Bicubic Patches (4)Bicubic Patches (4)

G t T M g g M T

g g g g M Ti i i

T T T

i i i iT T

( ) = • • = • •= • •1 2 3 4b g

Q s t S M G t S M g M T

S M

g g g gg g g gg g g gg g g g

M T

T T

T T

( , ) ( )= • • = • • • •

= • •

F

H

GGGG

I

K

JJJJ• •

11 12 13 14

21 22 23 24

31 32 33 34

41 42 43 44

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bicubic Patches (5)Bicubic Patches (5)

This is the generic description of bicubic patches

By chosing a concrete geometry matrix g, different patch types can be realized

We will first explore Hermite patches.The mechanism applies similarly to Bézier and B-spline patches

Page 15: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Patches (1)Hermite Patches (1)

Hermite patches are formed by using the Hermite basis matrix MH and a cubic Hermite geometry vector gH:

Q s t S M g M T

g

P Pt

Pt

P

P Pt

Pt

P

sP

sP

s tP

s tP

sP

sP

s tP

s tP

H H H HT T

H

( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

= • • • •

=

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂∂

∂∂∂

∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGGGGG

I

K

0 0 0 1 0 0 0 1

1 0 11 1 0 11

0 0 0 1 0 0 0 1

1 0 11 1 0 11

2 2

2 2

JJJJJJJJ

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Patches (2)Hermite Patches (2)

Each row or column of the geometry matrix gH describes a cubic polynomial

These polynomials can be interpreted as how the control points change across the patch, e.g. boundary curve for s=0

g

P Pt

Pt

P

P Pt

Pt

P

sP

sP

s tP

s tP

sP

sP

s tP

s tP

H =

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂∂

∂∂∂

∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGGGGG

I

K

JJJJJJJJ

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

0 0 0 1 0 0 0 1

1 0 11 1 0 11

0 0 0 1 0 0 0 1

1 0 11 1 0 11

2 2

2 2

s

t

P(0,0)

P(1,1)

P(1,0)

P(0,1)

Page 16: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Patches (3)Hermite Patches (3)

g

P Pt

Pt

P

P Pt

Pt

P

sP

sP

s tP

s tP

sP

sP

s tP

s tP

H =

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂∂

∂∂∂

∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGGGGG

I

K

JJJJJJJJ

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

0 0 0 1 0 0 0 1

1 0 11 1 0 11

0 0 0 1 0 0 0 1

1 0 11 1 0 11

2 2

2 2

Control points at the four patch corners

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Patches (4)Hermite Patches (4)

g

P Pt

Pt

P

P Pt

Pt

P

sP

sP

s tP

s tP

sP

sP

s tP

s tP

H =

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂∂

∂∂∂

∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGGGGG

I

K

JJJJJJJJ

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

0 0 0 1 0 0 0 1

1 0 11 1 0 11

0 0 0 1 0 0 0 1

1 0 11 1 0 11

2 2

2 2

Starting tangent vectors in both directions at the four patch corners

Page 17: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Hermite Patches (5)Hermite Patches (5)

Starting tangent vectors of the tangent vectors at the four patch corners, a.k.a. twists

The twists describe how much the corner is "twisted", i.e. how much the tangents are rotated around the corner

g

P Pt

Pt

P

P Pt

Pt

P

sP

sP

s tP

s tP

sP

sP

s tP

s tP

H =

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂

∂∂∂

∂∂∂

∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGGGGG

I

K

JJJJJJJJ

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

0 0 0 1 0 0 0 1

1 0 11 1 0 11

0 0 0 1 0 0 0 1

1 0 11 1 0 11

2 2

2 2

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Joining Hermite Patches (1)Joining Hermite Patches (1)

Similar to joining Hermite curves, patches can be joined with C1 or G1 continuity

For smooth joint, the following conditions must be met:Assuming boundary along constant tControl points along the common boundary must be the sameTangent vectors across the common boundary must match

Page 18: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Joining Hermite Patches (2)Joining Hermite Patches (2)

Patch 1

( , ) ( , )

Patch 2− − − − − − − −

∂∂

∂∂

− − − − − − − −∂∂

∂∂

∂∂∂

∂∂∂

F

H

GGGGG

I

K

JJJJJ

∂∂

∂∂

− − − − − − − −∂∂

∂∂

∂∂∂

P Pt

Pt

P

sP

sP

s tP

s tP

P Pt

Pt

P

sP

sP

s

1 1 1 1

1 1

2

1

2

1

1 1 1 1

1 1

2

1 0 11 1 0 11

1 0 11 1 0 11

1 0 11 1 0 11

1 0 11

( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , ) ( , ) ( , )

( , ) ( , )t

Ps t

P1

2

11 0 11( , ) ( , )∂

∂∂− − − − − − − −

F

H

GGGGG

I

K

JJJJJ

Patch 1

Patch 2

st s=0

s=1s=0

s=1

t=0

t=1t=0

t=1

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curves (1)Bézier Curves (1)

Bézier specify the start and end point directlyThe tangent vectors are specified indirectly using two additional points

Bézier curves interpolate first + last control pointThe other two control points are approximated

R Q P P

R Q P P1 2 1

4 4 3

0 3

1 3

= = −= = −

' ( )

' ( )

b gb g

4

0

Q t( )0 1,

40.625 Q t( )0 0,

0 2 40

2

4

4

0

Q t( )0 1,

40 Q t( )0 0,

0 2 40

2

4

Page 19: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curves (2)Bézier Curves (2)

We will first derive the basis matrix MB using the basis matrix MH for Hermite curves

The geometry vector for Bézier curves contains four points

Using the definition of tangent vectors for Bézier curves we obtain the geometry vector for Hermite curves

G P P P P TB = 1 2 3 4b g

G

PPRR

PP

P PP P

PPPP

M GH HB B=

F

H

GGGG

I

K

JJJJ=

−−

F

H

GGGG

I

K

JJJJ=

−−

F

H

GGGG

I

K

JJJJ

F

H

GGGG

I

K

JJJJ= •

1

4

1

4

1

4

2 1

4 3

1

2

3

4

33

1 0 0 00 0 0 13 3 0 0

0 0 3 3( )( )

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curves (3)Bézier Curves (3)

By substituting this expression into the formula for Hermite curves we obtain:

This gives the following expression for Q(t):

Q t T M G T M M G T M G

M M M

H H H HB B B B

B H HB

( ) = • • = • • • = • •⇒

= • =

−− − −

F

H

GGGG

I

K

JJJJ•

−−

F

H

GGGG

I

K

JJJJ=

− −−

F

H

GGGG

I

K

JJJJ

2 2 1 13 3 2 1

0 0 1 01 0 0 0

1 0 0 00 0 0 13 3 0 0

0 0 3 3

1 3 3 13 6 3 03 3 0 0

1 0 0 0

Q t t P t t P t t P t P( ) = − + − + − +1 3 1 3 131

22

23

34b g b g b g

Page 20: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bernstein Polynomials (1)Bernstein Polynomials (1)

The blending functions are known as the Bernstein polynomialsIn general, the Bernstein polynomials are defined as

n-th order polynomials

Bézier curves with n control points are defined as:

Q t P B t ti n ii

n

( ) ( ),= ⋅ ≤ ≤=∑

0

0 1 for

B tni

t tn ii n

, ( ) = FHGIKJ⋅ ⋅ − −1 1b g

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bernstein Polynomials (2): Degree 2Bernstein Polynomials (2): Degree 2

1

0

B 2 0, t,( )

B 2 1, t,( )

B 2 2, t,( )

10 t0 0.5 1

0

0.5

1

Page 21: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bernstein Polynomials (2): Degree 3Bernstein Polynomials (2): Degree 3

1

0

B 3 0, t,( )

B 3 1, t,( )

B 3 2, t,( )

B 3 3, t,( )

10 t0 0.5 1

0

0.5

1

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bernstein Polynomials (2): Degree 4Bernstein Polynomials (2): Degree 4

1

0

B 4 0, t,( )

B 4 1, t,( )

B 4 2, t,( )

B 4 3, t,( )

B 4 4, t,( )

10 t0 0.5 1

0

0.5

1

Page 22: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bernstein Polynomials (3)Bernstein Polynomials (3)

Positive over the range t in [0,1]:The Bézier curve is contained in the convex hull of the control points Pi.All control points influence the overall shape of the curve, no local support.

The sum of all Bernstein functions is always 1 in [0,1]Hence, a Bézier curve is simply a weighted average of the Pi

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curve: Properties (1)Bézier Curve: Properties (1)

The degree of the polynomial defining the curve segment is one less than the number of control points.

The more control points, the higher the degree of the polynomialThe curve becomes "wigglier" as more control points are added

The curve follows the shape of the control polygonThis makes Bézier curves intuitive to work withWith a little practice, one can predict the shape of the curve given the control polygon

The first and last points on the curve interpolate the first and last point of the control polygon

Makes it easy to join several Bézier segments

Page 23: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curve: Properties (2)Bézier Curve: Properties (2)

The tangent vectors at the curve ends have the same direction as first + last segment of the control polygon

Provides intuitive control over the tangent direction at start and end pointsMakes it easy to join several Bézier segments

The curve is contained in the convex hull of the control polygon

Facilitates clipping of Bézier curves. Perform trivial accept/reject on the control polygon before actual clipping of the curve.Makes the shape and extent of the curve predictable

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Bézier Curve: Properties (3)Bézier Curve: Properties (3)

The curve exhibits the variation diminishing property, i.e. curve does not oscillate about any straight line more often than the defining polygon

The curve follows the shape of the control polygon and does not oscillate more than indicated by the control polygon

The curve is invariant under an affine transformationThe curve can be transformed by by transforming the control polygonThe curve is not invariant under perspective transformations !

Page 24: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Joining Bézier CurvesJoining Bézier Curves

Bézier curves can be easily joined with C1 or G1 continuity

The tangent vectors (P4-P3) and (P5-P4) must be collinearFor parametric continuity they must have the same length

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

BBézier Curves: Summary of Propertiesézier Curves: Summary of Properties

The degree of the polynomial defining the curve segment is one less than the number of control points.The curve follows the shape of the control polygonThe first and last points on the curve interpolate the first and last point of the control polygonThe tangent vectors at the curve ends have the same direction as first + last segment of the control polygonThe curve is contained in the convex hull of the control polygonThe curve exhibits the variation diminishing property, i.e. curve does not oscillate about any straight line more often then the defining polygonThe curve is invariant under an affine transformation.

Page 25: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

BBézier Curves: Demoézier Curves: Demo

DesignMentor from Michigan Technological UniversityDownload from http://www.cs.mtu.edu/~shene/NSF-2/index.html

Bézier CurvesInfluence of control pointsTangent vectorsJoining Bézier curves

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

BBézier Curves: Problemsézier Curves: Problems

Bézier curves have limited utility mainly because of two reasons:

The number of control points determines the degree of the polynomial defining the curve

Adding points will automatically raise the degree of the polynomial !Adding points will automatically raise the degree of the polynomial !The only way to reduce the degree of the polynomial is to delete control points.The only way to reduce the degree of the polynomial is to delete control points.

The Bernstein polynomials have global supportChanging one control point affects the entire curveChanging one control point affects the entire curveDifficult to introduce local changes to the curveDifficult to introduce local changes to the curve

Both problems are a result of the choice of the basis functionsAnother set of basis functions can eliminate these problems: B-Splines

Page 26: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Spline CurvesSpline Curves

Splines were used to create curves in draftingSplines are long, metal strips that are bent and held into shape at certain points by "ducks"The "ducks" define the control points of the control polygonThe metal strip implements the spline function

The original splines interpolate the control pointsThe shape of the curve depends on all control points

We will look at B-splines, a different class of splines, where control points have only local influence. The curve does not interpolate, but only approximate, the control points.

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-spline Curves: Concepts (1)B-spline Curves: Concepts (1)

B-spline curves are controled by an arbitrary number of control points

B-spline curves are defined in several segments, each of which is controlled by 4 control points (for cubic B-splines)B-splines are described by m+1 control points P0, P1, P2, ... Pm

Each curve consists of m-2 curve segments Q3, Q4, ... Qm

The parameter t sequentially covers a range of 1 for every segmentThe parameter t normally ranges from 0 to m-2The segments are connected with C2 continuity (again: for cubic B-splines). This makes B-splines smoother than Hermite or Bézier curves.

Page 27: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-spline Curves: Concepts (2)B-spline Curves: Concepts (2)

P0

Q3

t3

t4

t5

t6

t7

t8

t9

Q4

Q5

Q6

Q7

Q8P1

P2

P3

P4

P5

P6

P7

P8

m= 8n = 3

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-spline Curves: Concepts (3)B-spline Curves: Concepts (3)

P0

Q3

t3

t4

t5

t6

t7

t8

t9

Q4

Q5

Q6

Q7

Q8P1

P2

P3

P4

P5

P6

P7

P8

m= 8n = 3

A segment is controlled by 4 control points

Q5: P2 ... P5

Qi: Pi-3 ... Pi

Each segment covers parameter interval of 1

Q5: t5 ... t6

Qi: ti ... ti+1

Each control point influences 4 segments

P4: Q4 ... Q7

Pn: Qn ... Qn+3

Page 28: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-Spline Curves: Concepts (4)B-Spline Curves: Concepts (4)

The joints between curve segments are called knotsThe knot vector specifies the parameter values at the knotsGenerally, the only condition for knots is that there values must increase monotonically, i.e.

Sofar we have only considered uniform knot vectors, i.e.

, e.g. (0, 1, 2, 3, 4, 5)

However, knot vectors can contained repeated knot values and knot values that are not spaced at equal intervals, e.g.(0, 0, 0, 0, 1, 2, 3, 3, 4, 4, 4, 4)

t ti i≤ + 1

t ti i− =− 1 1

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Similar to Bézier curves, B-spline curves are defined by computing the weighted sum of the control points:

The Pi are the control pointsThe functions Bi,k are the B-spline basis functions of order kB-splines of order k are generating polynomials of degree (k-1)

The order of the B-splines can be selected as neededThe maximum order of a B-spline curve is equal to the number of control points, i.e.

B-Splines Curves: Definition (1)B-Splines Curves: Definition (1)

Q t P B ti i ki

m

( ) ( ),= ⋅=∑

0

k m≤

Page 29: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

The B-spline basis functions are recursively defined as

By definition: 0 / 0 = 0

B-Splines Curves: Definition (2)B-Splines Curves: Definition (2)

B tt t t

B tt t

t tB t

t tt t

B t

ii i

i ki

i k ii k

i k

i k ii k

,

, , ,

( )

( ) ( ) ( )

11

11

11 1

10

=≤ <RST

= −−

⋅ + −−

+

+ −−

+

+ ++ −

otherwise

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-Spline Curves: Properties (1)B-Spline Curves: Properties (1)Recursive computation of the basis functions results in a triangular dependence pattern

Basis functions of order k are non-zero for k segmentsIn each of the k recursion, the order is reduced by 1. Each recursion level adds one segment because Ni,k = f(Ni,k-1, Ni+1,k-1)Therefore, for k recursion levels, k-1 segments are added

B

B

B

B B B B

i k

i k i k

i k i k i k

i i i i k

,

, ,

, , ,

, , , ,

− + −

− + − + −

+ + + −

1 1 1

2 1 2 2 2

1 1 1 2 1 1 1

B

B B

M OK

Page 30: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-Spline Curves: Properties (2)B-Spline Curves: Properties (2)

Basis functions of order k are non-zero for k segmentsTherefore, each control point has influence over only k curve segments

The basis functions are non-negativeTherefore, each segment is contained in the convex hull of its control points. Obviously, then the entire curve is also contained in the convex hull of the entire control polygon.

This is a stronger property than for Bézier curves.

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Periodic B-Spline Curves (1)Periodic B-Spline Curves (1)

Periodic B-splines have a uniform knot vector, i.e. knot values are spaced 1 apart, e.g. (0, 1, 2, 3, 4, 5)

Explicite computation of the basis functions for k=4, i.e. cubic B-splines

Recall the dependency pattern for computing the basis functions:

B

B

B

B B B B

i k

i k i k

i k i k i k

i i i i k

,

, ,

, , ,

, , , ,

− + −

− + − + −

+ + + −

1 1 1

2 1 2 2 2

1 1 1 2 1 1 1

B

B B

M OK

Page 31: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Periodic B-Spline Curves (2)Periodic B-Spline Curves (2)Expression for a B-spline curve of order 4:

Expanding this expression gives:

Q t t P B ti i ii

m

( ) ( ),− = ⋅=∑ 4

0

Q t t T M G B G

t t t

PPPP

tP

t tP

t t tP

tP

i Bs Bs Bs Bs( )− = • • = •

= •

− −−

F

H

GGGG

I

K

JJJJ•

F

H

GGGG

I

K

JJJJ

=−

⋅ + − + ⋅ + + + + ⋅ + ⋅

3 2

0

1

2

3

3

0

3 2

1

3 2

2

3

3

1

1 3 3 13 6 3 03 0 3 0

1 4 4 0

16

3 6 46

3 3 3 16 6

c h

b g

it t t

t m

i i

i

=− = =

⇒=

+

01 0

0 1

1 0 ,

Lb g

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Periodic B-Spline Curves (3)Periodic B-Spline Curves (3)

The matrix MBs is the B-spline basis matrix

The vector BBs contains the B-spline basis functions

M B

tt t

t t tt

Bs Bs=

− −−

F

H

GGGG

I

K

JJJJ= ⋅

−− +

+ + +

F

H

GGGG

I

K

JJJJ

1 3 3 13 6 3 03 0 3 0

1 4 4 0

16

13 6 4

3 3 3 1

3

3 2

3 2

3

b g

Page 32: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Periodic B-Spline Curves (3)Periodic B-Spline Curves (3)

B-spline basis functions for k=4

0.667

0

B 0 4, t,( )

B 1 4, t,( )

B 2 4, t,( )

B 3 4, t,( )

70 t0 2 4 6

0

0.2

0.4

0.6

0.8

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Open B-Spline Curves (1)Open B-Spline Curves (1)

Periodic B-spline curves do not interpolate the first and last control pointMultiple control points, e.g. Pi = Pi+1 = ... Pi+n, pull the curve closer to the control polygon.

The curve interpolates the control point for n = k-1.In those cases the curve reduces to a line segment.

Non-uniform B-splines offer another degree of flexibility in controlling the shape of the curve

For non-uniform B-splines knots are not equally spaced apartMultiple knots, e.g. ti = ti+1 = ... = ti+n, provide control over the continuity of the curve and how close the curve comes to the control polygon

Page 33: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Open B-Spline Curves (2)Open B-Spline Curves (2)

Open B-splines have k-fold knot at both ends of the knot vector,

For instance (0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4) for a cubic B-splineThe curve interpolates the first and last control point

The basis functions are not periodic any more, i.e. the control points are weighted differently and have different support.

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

B-Spline Curves: DemoB-Spline Curves: Demo

Local control over the curve shape

Uniform knot vectorPeriodic B-spline

Non-uniform knot vectors

Called clamped knot vector in DesignMentorOpen B-spline

Multiple vertices

Page 34: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Things we have not talked about ...Things we have not talked about ...

Rational Bézier and B-splines curvesAllows exact modeling of conic sections, e.g. circle or parabolaEven more flexibility for shape control

Other basis functionsSubdivision of curves and surfaces

Provides a tool to introduce local changes without complicating the entire shape

Elevation of degreeDescribe the same curve/surface with a higher-degree polynomialAnother means to provide more control over the shape

Techniques to efficiently evaluate and draw curves and surfacesRead Foley et al. and more advanced text books

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

To find out more ...To find out more ...

Study the text book

David F. Rogers and J. Alan AdamsMathematical Elements for Computer Graphics2nd edition, McGraw-Hill, 1990

Page 35: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

SummarySummary

Freeform Curves and SurfacesExplicit, implicit and parametric shapesGeometric and Parametric continuityHermite, Bézier and B-spline curves

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

HomeworkHomework

Study freeform curves and surfaces (chapter 11)

Prepare Foley et al. Chapter 12, "Solid Modeling"

Page 36: Computer Graphics - Week 9 - Columbia Universityfeiner/courses/csw4160/slides/S99-9.pdf · Computer Graphics - Week 9 Bengt-Olaf Schneider IBM T.J. Watson Research Center Computer

© Bengt-Olaf Schneider, 1999Computer Graphics – Week 9

Next Week ...Next Week ...

Solid Modeling

Introduction to Ray Tracing

Interior

Boundary

B

A

A

B

A+B

A-B

A*B

A+B

AA-B

A*B