+ All Categories
Home > Documents > Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... ·...

Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... ·...

Date post: 07-Jan-2020
Category:
Upload: others
View: 10 times
Download: 0 times
Share this document with a friend
10
1 1 CS 536 Computer Graphics Hermite Curves, B-Splines and NURBS Week 2, Lecture 4 David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University Additional slides from Don Fussell, University of Texas 2 Outline Hermite Curves More Types of Curves – Splines – B-splines – NURBS Knot sequences Effects of the weights Hermite Curve 3 3D curve of polynomial bases Geometrically defined by position and tangents at end points No convex hull guarantees Able to tangent-continuous (C 1 ) composite curve Algebraic Representation All of these curves are just parametric algebraic polynomials expressed in different bases Parametric linear curve (in R 3 ) Parametric cubic curve (in R 3 ) Basis (monomial or power) x = a x u 3 + b x u 2 + c x u + d x y = a y u 3 + b y u 2 + c y u + d y z = a z u 3 + b z u 2 + c z u + d z x = a x u + b x y = a y u + b y z = a z u + b z P(u) = au + b P(u) = au 3 + bu 2 + cu + d u 1 [ ] u 3 u 2 u 1 [ ] D. Fussell – UT, Austin Hermite Curves 12 degrees of freedom (4 3-d vector constraints) Specify endpoints and tangent vectors at endpoints Solving for the coefficients: P(0) = d P(1) = a + b + c + d P u (0) = c P u (1) = 3a + 2b + c a = 2p(0) 2p(1) + p u (0) + p u (1) b = 3p(0) + 3p(1) 2p u (0) p u (1) c = p u (0) d = p(0) p u (u) dP du (u) p u (0) u = 0 u = 1 p(0) p(1) p u (1) D. Fussell – UT, Austin Hermite Basis Substituting for the coefficients and collecting terms gives Call the Hermite blending functions or basis functions Then P(u) = (2u 3 3u 2 +1)p(0) + (2u 3 + 3u 2 )p(1) + (u 3 2u 2 + u)p u (0) + (u 3 u 2 )p u (1) H 1 (u) = (2u 3 3u 2 + 1) H 2 (u) = (2u 3 + 3u 2 ) H 3 (u) = (u 3 2u 2 + u) H 4 (u) = (u 3 u 2 ) P(u) = H 1 (u)p(0) + H 2 (u)p(1) + H 3 (u)p u (0) + H 4 (u)p u (1) H 1 H 2 H 3 H 4 n D. Fussell – UT, Austin
Transcript
Page 1: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

1

1

CS 536 Computer Graphics

Hermite Curves, B-Splines

and NURBS Week 2, Lecture 4

David Breen, William Regli and Maxim Peysakhov Department of Computer Science

Drexel University

Additional slides from Don Fussell, University of Texas

2

Outline •  Hermite Curves •  More Types of Curves

– Splines – B-splines – NURBS

•  Knot sequences •  Effects of the weights

Hermite Curve

3

•  3D curve of polynomial bases •  Geometrically defined by position

and tangents at end points •  No convex hull guarantees •  Able to tangent-continuous (C1)

composite curve

Algebraic Representation •  All of these curves are just parametric algebraic polynomials

expressed in different bases •  Parametric linear curve (in R3)

•  Parametric cubic curve (in R3)

•  Basis (monomial or power)

x = axu3 + bxu

2 + cxu + dxy = ayu

3 + byu2 + cyu + dy

z = azu3 + bzu

2 + czu + dz

x = axu + bxy = ayu + byz = azu + bz

P(u) = au+b

P(u) = au3 +bu2 + cu+d

u 1[ ]u3 u2 u 1[ ]

D. Fussell – UT, Austin

Hermite Curves •  12 degrees of freedom (4 3-d vector

constraints) •  Specify endpoints and tangent vectors at

endpoints

•  Solving for the coefficients:

P(0) = dP(1) = a+b+ c+dPu(0) = cPu(1) = 3a+ 2b+ c

a = 2p(0)− 2p(1)+pu(0)+pu(1)b = −3p(0)+3p(1)− 2pu(0)−pu(1)c = pu(0)d = p(0)

pu(u) ≡ dPdu(u)

•pu(0)

u = 0

u = 1

p(0)

p(1)

pu(1)

D. Fussell – UT, Austin

Hermite Basis •  Substituting for the coefficients and collecting terms gives

•  Call

the Hermite blending functions or basis functions

•  Then

P(u) = (2u3 −3u2 +1)p(0)+ (−2u3 +3u2 )p(1)+ (u3 − 2u2 +u)pu(0)+ (u3 −u2 )pu(1)

H1(u) = (2u3 − 3u2 +1)H2(u) = (−2u3 + 3u2)H3(u) = (u3 − 2u2 + u)H4 (u) = (u3 − u2)

P(u) =H1(u)p(0)+H2(u)p(1)+H3(u)pu(0)+H4(u)p

u(1)

H1 H2

H3

H4

n

D. Fussell – UT, Austin

Page 2: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

2

Blending Functions

•  At u = 0: –  H1 = 1, H2 = H3 = H4 = 0 –  H1’ = H2’ = H4’ = 0, H3’ = 1

•  At u = 1: –  H1 = H3 = H4 = 0, H2 = 1 –  H1’ = H2’ = H3’ = 0, H4’ = 1

H1(u) H2(u) H3(u) H4(u)

P(0) = p0 P’(0) = T0

P(1) = p1 P’(1) = T1

P(u) = (2u3 −3u2 +1)p(0)+ (−2u3 +3u2 )p(1)+ (u3 − 2u2 +u)pu(0)+ (u3 −u2 )pu(1)

Hermite Curves - Matrix Form •  Putting this in matrix form

•  MH is called the Hermite characteristic matrix •  Collecting the Hermite geometric

coefficients into a geometry vector B, we have a matrix formulation for the Hermite curve P(u)

H = H1(u) H2(u) H3(u) H4 (u)[ ]

= u3 u2 u 1[ ]

2 −2 1 1−3 3 −2 −10 0 1 01 0 0 0

#

$

% % % %

&

'

( ( ( (

=UMH

B =

p(0)p(1)pu(0)pu(1)

!

"

#####

$

%

&&&&&

P(u) =UMHBD. Fussell – UT, Austin

Hermite and Algebraic Forms

•  MH transforms geometric coefficients (“coordinates”) from the Hermite basis to the algebraic coefficients of the monomial basis

A =

abcd

!

"

####

$

%

&&&&

P(u) =UA =UMHBA =MHBB =MH

−1A

MH−1 =

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

#

$

% % % %

&

'

( ( ( (

D. Fussell – UT, Austin

Hermite Curves

10

•  Geometrically defined by position and tangents at end points

11

Issues with Bézier Curves

•  Creating complex curves may (with lots of wiggles) requires many control points – potentially a very high-degree polynomial

•  Bézier blending functions have global support over the whole curve – move just one point, change whole curve

•  Improved Idea: link (C1) lots of low degree (cubic) Bézier curves end-to-end

12

Continuity

Two types: •  Geometric Continuity, Gi:

–  endpoints meet –  tangent vectors’ directions are equal

•  Parametric Continuity, Ci: –  endpoints meet –  tangent vectors’ directions are equal –  tangent vectors’ magnitudes are equal

•  In general: C implies G but not vice versa

Page 3: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

3

13

Parametric Continuity

•  Continuity (recall from the calculus): –  Two curves are Ci continuous at a point p iff the

i-th derivatives of the curves are equal at p

Pics/Math courtesy of Dave Mount @ UMD-CP

14

Continuity

•  What are the conditions for C0 and C1 continuity at the joint of curves xl and xr? –  tangent vectors at end points equal –  end points equal

Ql Qr 1994 Foley/VanDam/Finer/Huges/Phillips ICG

Ql (1) =Qr (0),   dQl

dt(1) = dQ

r

dt(0)

15

Continuity •  The derivative of is the parametric

tangent vector of the curve:

1994 Foley/VanDam/Finer/Huges/Phillips ICG

16

Continuity •  In 3D, compute this for each component of

the parametric function –  For the x component:

•  Similar for the y and z components.

1994 Foley/VanDam/Finer/Huges/Phillips ICG

xl xr

17

Splines

•  Popularized in late 1960s in US Auto industry (GM) –  R. Riesenfeld (1972) –  W. Gordon

•  Origin: the thin wood or metal strips used in building/ship construction

•  Goal: define a curve as a set of piecewise simple polynomial functions connected together 18

Natural Splines

•  Mathematical representation of physical splines

•  C2 continuous •  Interpolate all control

points •  Have Global control

(no local control) P0

P1

Pn

Pn-1

P2

Pn-2

Page 4: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

4

19

B-splines: Basic Ideas

•  Similar to Bézier curves – Smooth blending function times control points

•  But: – Blending functions are non-zero over only a

small part of the parameter range (giving us local support)

– When nonzero, they are the “concatenation” of smooth polynomials. (They are piecewise!)

20

B-spline: Benefits

•  User defines degree –  Independent of the number of control points

•  Produces a single piecewise curve of a particular degree – No need to stitch together separate curves

at junction points •  Continuity comes for free!

•  Defined similarly to Bézier curves – pi are the control points – Computed with basis functions (Basis-splines)

•  B-spline basis functions are blending functions – Each point on the curve is defined by the

blending of the control points (Bi is the i-th B-spline blending function)

– Bi is zero for most values of t!

∑=

=m

iidi ptBtp

0, )()(

21

B-splines

22

)()()(

otherwise,0if,1

)(

1,111

11,,

10,

tBtttttB

tttttB

ttttB

dkkdk

dkdk

kdk

kdk

kkk

−++++

++−

+

+

−+

−=

"#$ <≤

=

B-splines: Cox-deBoor Recursion

•  Cox-deBoor Algorithm: defines the blending functions for spline curves (not limited to deg 3) –  curves are weighted avgs of lower degree curves

•  Let denote the i-th blending function for a B-spline of degree d, then:

)(, tB di

23

B-spline Blending Functions •  is a step function that is 1 in the

interval •  spans two intervals and is a

piecewise linear function that goes from 0 to 1 (and back)

•  spans three intervals and is a piecewise quadratic that grows from 0 to 1/4, then up to 3/4 in the middle of the second interval, back to 1/4, and back to 0

•  is a cubic that spans four intervals growing from 0 to 1/6 to 2/3, then back to 1/6 and to 0

Pics/Math courtesy of Dave Mount @ UMD-CP

B-spline blending functions

)(0, tBk

Bk,1(t)

)(2, tBk

)(3, tBk

24

B-spline Blending Functions: Example for 2nd Degree Splines •  Note: can’t define a

polynomial with these properties (both 0 and non-zero for ranges)

•  Idea: subdivide the parameter space into intervals and build a piecewise polynomial –  Each interval gets different

polynomial function

Pics/Math courtesy of Dave Mount @ UMD-CP

Page 5: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

5

25

B-spline Blending Functions: Example for 3rd Degree Splines

•  Observe: –  in t=0 to t=1 range

just four of the functions are non-zero

–  all are >=0 and sum to 1, hence the convex hull property holds for each curve segment of a B-spline

1994 Foley/VanDam/Finer/Huges/Phillips ICG

∑=

=m

iidi ptBtp

0, )()(

26

B-splines: Knot Selection

•  Instead of working with the parameter space , use

•  The knot points –  joint points between

curve segments, Qi – Each has a

knot value – m-1 knots for

m+1 points

10 ≤≤ t max1210min ... tttttt m ≤≤≤≤≤ −

1994 Foley/VanDam/Finer/Huges/Phillips ICG

28

Uniform B-splines: Setting the Options

•  Specified by –  –  m+1 control points, P0 … Pm –  m-2 cubic polynomial curve segments, Q3…Qm –  m-1 knot points, t3 … tm+1 –  segments Qi of the B-spline curve are

•  defined over a knot interval •  defined by 4 of the control points, Pi-3 … Pi

–  segments Qi of the B-spline curve are blended together into smooth transitions via (the new & improved) blending functions

],[ 1+ii tt

3≥m

29

Example: Creating a B-spline

∑=

=m

iidi ptBtp

0, )()( •  m = 9

•  10 control points •  8 knot points •  7 segments

1994 Foley/VanDam/Finer/Huges/Phillips ICG

30

B-spline: Knot Sequences •  Even distribution of knots

–  uniform B-splines –  Curve does not interpolate end points

•  first blending function not equal to 1 at t=0

•  Uneven distribution of knots –  non-uniform B-splines –  Allows us to tie down the endpoints by repeating knot values

(in Cox-deBoor, 0/0=0!) –  If a knot value is repeated, it increases the effect (weight) of the

blending function at that point –  If knot is repeated d times, blending function converges to 1 and

the curve interpolates the control point 31

Bi,d (t)

)()()(

otherwise,0if,1

)(

1,111

11,,

10,

tBtttttB

tttttB

ttttB

dkkdk

dkdk

kdk

kdk

kkk

−++++

++−

+

+

−+

−=

"#$ <≤

=

B-splines: Cox-deBoor Recursion

•  Cox-deBoor Algorithm: defines the blending functions for spline curves (not limited to deg 3) –  curves are weighted avgs of lower degree curves

•  Let denote the i-th blending function for a B-spline of degree d, then:

Page 6: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

6

32

Creating a Non-Uniform B-spline: Knot Selection

•  Given curve of degree d=3, with m+1 control points –  first, create m+d knot values –  use knot values (0,0,0,1,2,…, m-2, m-1,m-1,m-1) (adding two extra 0’s and m-1’s) –  Note

•  Causes Cox-deBoor to give added weight in blending to the first and last points when t is near tmin and tmax

Pics/Math courtesy of G. Farin @ ASU

33

B-splines: Multiple Knots

•  Knot Vector {0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0}

•  Several consecutive knots get the same value

•  Changes the basis functions!

From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

34

B-spline Summary ∑=

=m

iidi ptBtp

0, )()(

)()()(

otherwise,0if,1

)(

1,111

11,,

10,

tBtttttB

tttttB

ttttB

dkkdk

dkdk

kdk

kdk

kkk

−++++

++−

+

+

−+

−=

"#$ <≤

=

35

Watching Effects of Knot Selection •  9 knot points (initially)

–  Note: knots are distributed parametrically based on t, hence why they “move”

•  10 control points •  Curves have as many

segments as they have non-zero intervals in u

Pics/Math courtesy of G. Farin @ ASU

degree of curve

0 0 1 2 3 4 5 6 7 8 9

36

B-splines: Local Control Property

•  Local Control –  polynomial coefficients

depend on a few points –  moving control point (P4)

affects only local curve –  Why: Based on curve

def’n, affected region extends at most 2 knot points away

1994 Foley/VanDam/Finer/Huges/Phillips ICG

37

B-splines: Local Control Property

Recorded from: http://heim.ifi.uio.no/~trondbre/OsloAlgApp.html

Page 7: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

7

39

B-splines: Convex Hull Property

•  The effect of multiple control points on a uniform B-spline curve

1994 Foley/VanDam/Finer/Huges/Phillips ICG

40

B-splines: Continuity

•  Derivatives are easy for cubics

•  Derivative: Easy to show C0 , C1 , C2

∑=

=3

0)(

kk

kcuup

2321 32)( ucuccup ++=!

41

B-splines: Setting the Options

•  How to space the knot points? – Uniform

•  equal spacing of knots along the curve

– Non-Uniform •  Which type of parametric function?

– Rational •  x(t), y(t), z(t) defined as ratio of cubic polynomials

– Non-Rational 42

NURBS

•  At the core of several modern CAD systems –  I-DEAS, Pro/E, Alpha_1

•  Describes analytic and freeform shapes

•  Accurate and efficient evaluation algorithms

•  Invariant under affine and perspective transformations

U of Utah, Alpha_1

43

Benefits of Rational Spline Curves

•  Invariant under rotation, scale, translation, perspective transformations –  transform just the control points,

then regenerate the curve –  (non-rationals only invariant under rotation, scale

and translation) •  Can precisely define the conic sections and

other analytic functions –  conics require quadratic polynomials –  conics only approximate with non-rationals

44

NURBS

Non-uniform Rational B-splines: NURBS

•  Basic idea: four dimensional non-uniform B-splines, followed by normalization via homogeneous coordinates –  If Pi is [x, y, z, 1], results are invariant wrt perspective projection

•  Also, recall in Cox-deBoor, knot spacing is arbitrary –  knots are close together,

influence of some control points increases –  Duplicate knots can cause points to interpolate –  e.g. Knots = {0, 0, 0, 0, 1, 1, 1, 1} create a Bézier curve

Page 8: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

8

45

Rational Functions

•  Cubic curve segments where are all cubic polynomials with control points specified in homogenous coordinates, [x,y,z,w]

•  Note: for 2D case,

)()()( ,

)()()( ,

)()()(

tWtZ

tztWtY

tytWtX

tx ===

)( ),( ),( ),( tWtZtYtX

0)( =tZ46

Rational Functions: Example

•  Example: –  rational function: a ratio of polynomials – a rational parameterization

in u of a unit circle in xy-plane:

– a unit circle in 3D homogeneous coordinates:

47

NURBS: Notation Alert

•  Depending on the source/reference – Blending functions are either or – Parameter variable is either u or t – Curve is either C or P or Q – Control Points are either Pi or Bi – Variables for order, degree, number of control

points etc are frustratingly inconsistent •  k, i, j, m, n, p, L, d, ….

)(, uB di )(, uN di

48

NURBS: Notation Alert

1.  If defined using homogenous coordinates, the 4th (3rd for 2D) dimension of each Pi is the weight

2.  If defined as weighted euclidian, a separate constant wi, is defined for each control point

49

NURBS

•  A d-th degree NURBS curve C is def’d as: Where – control points, – d-th degree B-spline blending functions, –  the weight, wi, for control point Pi

(when all wi=1, we have a B-spline curve)

∑∑

=

== 1

0 ,

1

0 ,

)(

)()( n

i dii

n

i idii

uBw

PuBwuC

)(, uB di

50

Observe: Weights Induce New Rational Basis Functions, R

•  Setting: Allows us to write: Where are rational basis functions – piecewise rational basis functions on – weights are incorporated into the basis fctns

( ) ( )

( )∑−

=

= 1

0,

,n

idii

diii

uBw

uBwuR

( ) ( )∑−

=

=1

0,

n

iidi PuRuC

( )uR di,

]1,0[∈u

Page 9: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

9

51

Geometric Interpretation of NURBS

•  With Homogeneous coordinates, a rational n-D curve is represented by polynomial curve in (n+1)-D

•  Homogeneous 3D control points are written as: in 4D where

•  To get , divide by wi –  a perspective transform with center at the origin

•  Note: weights can allow final curve shape to go outside the convex hull (i.e. negative w) 52

NURBS: Examples

{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0} {0.0, 1.0, 2.0, 3.75, 4.0, 4.25, 6.0, 7.0}

•  Unif. Knot Vector •  Non-Unif. Knot Vector

From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

53

NURBS: Examples

•  Knot Vector {0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0}

•  Several consecutive knots get the same value

•  Bunches up the curve and forces it to interpolate

From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

54

NURBS: Examples

•  Knot Vector {0.0, 1.0, 2.0, 3.0, 3.0, 5.0, 6.0, 7.0}

•  Several consecutive knots get the same value

•  Bunches up the curve and forces it to interpolate

•  Can be done midcurve

From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

55

The Effects of the Weights •  wi of Pi effects only the range [ui, ui+k+1) •  If wi=0 then Pi does not contribute to C •  If wi increases, point B and curve C are pulled

toward Pi and pushed away from Pj •  If wi decreases, point B and curve C are

pushed away from Pi and pulled toward Pj •  If wi approaches infinity then

B approaches 1 and Bi -> Pi , if u in [ui, ui+k+1)

56

The Effects of the Weights

•  Increased weight pulls the curve toward B3

From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

Page 10: Hermite Curves Hermite Curves, B-Splines and NURBSdavid/Classes/CS536/Lectures/L-04_BSplines... · • Hermite Curves • More Types of Curves –Splines – B-splines – NURBS •

10

57

Programming Assignment 1

•  Process command-line arguments •  Read in 3D control points •  Iterate through parameter space by du •  At each u value evaluate Bezier curve

formula to produce a sequence of 3D points

•  Output points by printing them to the console as a polyline and control points as spheres in Open Inventor format


Recommended