37
Curves Toni Sellarès Universitat de Girona 2 Curves Many objects we want to model are not straight. Ex. Text, sketches, etc. How can we represent a curve? A large number of points on the curve. Approximate with connected line segments. “piecewise linear approximation”

Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

Curves

Toni SellarèsUniversitat de Girona

2

Curves

• Many objects we want to model are not straight.

– Ex. Text, sketches, etc.

• How can we represent a curve?

– A large number of points on the curve.

– Approximate with connected line segments.• “piecewise linear approximation”

Page 2: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

3

Accuracy/Space Trade-off

Problem

• Piecewise linear approximations require many pieces to look good (realistic, smooth, etc.).

• Set of individual curve points would take large amounts of storage.

Solution

• Higher-order formulae for coordinates on curve.

• If a simple formula won’t work, subdivide curve into pieces that can be represented by simple formulae.

• May still be an approx., but uses much less storage.

• Downside: harder to specify and render.

4

Curve Representations• Explicit: y = f(x)

• Example: y = x2

• The curve must be a function (only one value of y for each x)

• Parametric: (x(t),y(t)) = (f(t),g(t))

• Example: (x(t), y(t)) = (cos t, sin t)

• Easy to specify, modify, control

• Easy to join curve segments smoothly

• Implicit: F(x,y) = 0

• Example: x2-y2-r2=0

• Could exist several values of y for each x

• Need constraints to model just one part of a curve

•Joining curves together smoothly is difficult

• Hard to specify, modify, control

Page 3: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

5

• Two Ways to Define a Circle

Parametric:

x(u) = r cos (u)y(u) = r sin (u)

Implicit:

F(x,y) = x² + y² - r² = 0

Curve examples

6

Parametric Equations

CTtQ )(

Cubic preferred

Balance between flexibility and complexity in specifying and computing shape.

Matricial expression

Q(t)=(x(t),y(t),z(t))

x(t) = axt3 + bxt2 + cxt + dx

y(t) = ayt3 + byt2 + cyt + dy

z(t) = azt3 + bzt2 + czt + dz

123 tttT

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

CWhere:

t [0,1]

Page 4: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

7

Joining Curve Segments

G0 geometric continuity: Two curve segments join together.

G1 geometric continuity: The direction of the two segments’ tangent vectors are equal at the join point.

C0 continuity: Curves share the same point where they join.

C1 continuity: Tangent vectors of the two segments are equal in magnitude and direction (share the same parametric derivatives).

C2 continuity: Curves share the same parametric second derivatives where they join.

C1 G1, unless tangent vector = [0, 0, 0].

8

Joining Examples

C0

C1

C2

TV2

TV3

TV1

P1

P2

P3

Q1

Q2

Q3

Q1 and Q2 are C1 continuous because their tangents, TV1and TV2, are equal. Q1 and Q3 are only G1 continuous.

Join point

S joins C0, C1, and C2 with C0, C1, and C2 continuity, respectively.

Page 5: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

9

Continuity examples

Continuous in position

Continuous in position and tangent vector

Continuous in position, tangent, and curvature

10

Curve Fitting: Interpolation and Approximation

Interpolation

curve must pass through control points

Approximation

curve is influenced by control points

Page 6: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

11

Curve representations: polynomial bases

• Polynomials are easy to analyze, derivatives remain polynomial, etc.

• Monomial basis {1, x, x2, x3, …}.

– Coefficients are geometrically meaningless.

– Manipulation is not robust.

• Number of coefficients = polynomial rank.

12

Polynomial Interpolation

• An n-th degree polynomial fits a curve to n+1 points.

– Example: fit a second degree curve to three points:

• x(u)= au2 + bu + c.

• control points to interpolate: (u1, x1), (u2, x2), (u3, x3).

• solve for coefficients (a, b, c): 3 linear eqns, 3 unknowns.

– called Lagrange Interpolation.

– result is a curve that changes to any control point affects entire curve (non-local) [this method is poor].

• We usually want the curve to be as smooth as possible:

– minimize the wiggles.

– high-degree polynomials are bad.

Page 7: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

13

Lagrange Interpolation

The Lagrange interpolating polynomial is the polynomial of degree n-1 that passes through the n points,

(x1, y1), (x2, y2), …, (xn, yn),

and is given by:

2 1 31 2

1 2 1 2 1 2 3 2

1

1 1

1

P x

n n

n n

nn

n n

nj

ii j i i j

x x x x x x x x x xy y

x x x x x x x x x x

x x x xy

x x x x

x xy

x x

14

Splines

A spline is a parametric curve defined by control points:

– term “spline” dates from engineering drawing, where a spline was a piece of flexible wood used to draw smooth curves.

– control points are adjusted by the user to control shape of curve.

– wood splines:

• have second-order continuity,

• pass through the control points.

Drawing curves with wood splines

Page 8: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

15

Spline Curve Families

• Hermite cubic

– Defined by its 2 endpoints and tangent vectors at endpoints.– Interpolates all its control points.– Special case of Bezier and B-Spline.

• Bezier

– Interpolates first and last control points.– Curve is tangent to first and last segments of control polygon.– Easy to subdivide.– Curve segment lies within convex hull of control polygon.

• B-Spline

– Not guaranteed to interpolate control points.– Curve segment lies within convex hull of control polygon.– Greater local control than Bezier.

0

1

2

3

5

4

6

7

89

16

Linear Interpolation

• Linear interpolation (Lerp) is a common technique for generating a new value that is somewhere in between two other values.

• By interpolating between two points p0 and p1 by some parameter t we obtain a segment:

p0

p1

t=1.

. 0<t<1t=0

Page 9: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

17

Three ways of writing a segment:

1. Weighted average of the control points: Q(t) = (1-t)p0 + tp1 .

Basis Functions:

B0(t)=1-t; B1(t)=t

B0(t)+B1(t)=1

Q(t) = B0(t)p0 + B1(t)p1

2. Polynomial in t: Q(t) = (p1-p0 )t + p0

3. Matrix form:

pp

tQ t1

0

01

111)(

Linear Interpolation

18

Hermite Curve Examples

P0P1

R1

R0

The set of Hermite curves that have the same values for the endpoints P0 and P1, tangent vectors R0 and R1 of the same direction, but with different magnitudes for R0. The magnitude of R1 remains fixed.

Page 10: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

19

Hermite Curve Examples

All tangent vector magnitudes are equal, but the direction of the left tangent vector varies.

20

p

qDp

DqP(t) = at3 + bt2 +ct +d

t in [0,1]

P(0) = p

P(1) = q

P'(0) = Dp

P'(1) = Dq

Is a cubic curve for which the user provides:

The endpoints of the curve: p, q;The parametric derivatives of the curve at the endpoints: Dp, Dq.

Hermite Cubic Curves

Page 11: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

21

Hermite Coefficients

For each coordinate, we have 4 linear equations in 4 unknowns

22

Boundary Constraint Matrix

Page 12: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

23

Hermite Matrix

2 2 1 1

3 3 2 1

0 0 1 0

1 0 0 0

a

b

c

d

p

q

Dp

Dq

MH = (NH)-1 GH

P(t) = T MH GH

24

Hermite Basis Functions

0 1 2 3t H t H t H t H t P p q Dp Dq

Page 13: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

25

23

3

232

231

230

2

32

132

tttH

ttttH

tttH

tttH

H0(t) H1(t)

Hermite Basis Functions

- Functions:

are called Hermite Basis or Blending Functions.

- Observe that: H0(t)+H1(t)+H2(t)+H3(t) 1.

- An Hermite cubic curve can be thought as a higher order extension of linear interpolation:

P(t)=H0(t)p + H1(t)q+H2(t)Dp+H3(t)Dq

26

• Hermite curves are difficult to use because we usually have control points but not derivatives.

• However, Hermite curves are the basis of the Bezier curves.

• Bezier curves are more intuitive, since we only need to specify control points.

From Hermite to Bezier curves

Displaying Hermite curves

• Evaluate the curve at a fixed set of parameter values and join the points with straight lines.

Page 14: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

27

• Bezier curve is an approximation of given control points.

• Bezier curve of degree d is defined over d+1 control points {Pi}i=0,...,d.

• Have two formulations:

– Algebraic (higher order extension of linear interpolation).

– Geometric.

Bezier Curves of degree d

28

Bezier Curves: Algebraic Formulation

• The user supplies d+1 control points:

pi ; i=0, … , d.

• Write the curve of degree d as:

• The functions Bid(t) are the Bernstein basis polynomials or Bezier

blending functions of degree d.

pi

d

i

di tBtQ

0

ididi tt

i

dtB

1

0

0 )!!*(/!

otherwise

diwhenidid

i

d

Page 15: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

29

Bezier Curves: Algebraic Formulation

• Q(0)=p0 and Q(1)=pd, that means the Bézier curve lies on p0 and pd .

• Q‘(0)=d(p1 - p0) and Q‘(1)=d(pd - pd-1) (tangents in start and end points).

pi

d

i

di tBtQ

0

=

=(1-t)d p0 + t(1-t)d-1p1+ …+td-1(1-t)pd-1+tdpd.

30

d

i

d

i

di

iid

d

tBtti

d

tt

0 0)(1

11

0,1t 1)(0

d

i

di tB

Proof:

• They are all positive in interval [0,1],

• Their sum is equal to 1:

• Symmetry:

• Recursion:

Bernstein Basis Polynomials

)1()( tBtB did

di

)()1()()( 11 tBttBttB id

idi

di

Page 16: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

31

Bezier Curves

32

Some cubic Bezier curves

For cubic Bezier curves, two control points define endpoints, and two control the tangents at the endpoints in a geometric way.

Cubic Bezier Curves (d=3)

Page 17: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

33

Bernstein Basis Polynomials for d=3

)1()(33

0 ttB

ttB33

3 )(

)1(3)(23

1 tttB

)1(3)( 23

2 tttB

)(3

0 tB )(3

3 tB

)(3

1 tB )(3

2 tB

34

zyx

zyx

zyx

zyx

ppp

ppp

ppp

ppp

ttttQ

333

222

111

000

23

0001

0033

0363

1331

1)(

Q(t) = T MB GB

)(3010

ppDp

)(3233

ppDp

Bézier Matrix for d=3

From:

We can deduce:

MB GB

Page 18: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

35

Bezier Cubic Curves Properties

• The first and last control points are interpolated,

• The tangent to the curve at the first control point is along theline joining the first and second control points,

• The tangent at the last control point is along the line joining the second last and last control points,

• The curve lies entirely within the convex hull of its control points:

– Every point on curve is a linear combination of the control points,

– The weights of the combination are all positive,

– The sum of the weights is 1,

– Therefore, the curve is a convex combination of the control points.

• By specifying multiple coincident points at a vertex, we pull the curve in closer and closer to that vertex.

36

The properties of the Bernstein polynomials ensure that all Bezier curves lie in the convex hull of their control points.

Convex Hull Property

Page 19: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

37

De Casteljau Algorithm

• Describes the curve as a recursive series of linear interpolations.

• Is useful for providing an intuitive understanding of the geometry involved.

• Provides a means for evaluating Bezier curves.

38

De Casteljau Algorithm

Q (1/3)

We take points 1/3 of the way

);(:)(

);()()1(:)(

do to:=For

do to1:For

;:)( do to0:For

][

]1[]1[1

][

]0[

tPtQ

ttPtPttP

nji

nj

PtPni

nn

ji

ji

ji

ii

Select t[0,1] value. Then:

d

d

);(][ tP dd

d

Page 20: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

39

p0

q0

p1

p2

p3

q2

q1

322

211

100

,,

,,

,,

ppq

ppq

ppq

tLerp

tLerp

tLerp

De Casteljau Algorithm for d=3

tqptqptLerp 1,,Where:

We start with our original set of points p0, p1, p2 and p3.

40

q0

q2

q1

r1

r0

211

100

,,

,,

qqr

qqr

tLerp

tLerp

De Casteljau Algorithm

Page 21: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

41

10 ,,)( rrtLerptQ

De Casteljau Algorithm

r1Q(t)r0 •

Q(t)•

p0

p1

p2

p3

Bezier curve

42

Recursive Linear Interpolation

322

211

100

,,

,,

,,

ppq

ppq

ppq

tLerp

tLerp

tLerp

211

100

,,

,,

qqr

qqr

tLerp

tLerp

10 ,,)( rrtLerptQ

3

2

1

0

p

p

p

p

2

1

0

q

q

q

1

0

r

r)(tQ

3

2

1

0

p

p

p

p

Page 22: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

43

Expanding the Lerps

3221

211010

3221211

2110100

32322

21211

10100

111

1111,,)(

111,,

111,,

1,,

1,,

1,,

pppp

pppprr

ppppqqr

ppppqqr

ppppq

ppppq

ppppq

ttttttt

ttttttttLerptQ

tttttttLerp

tttttttLerp

tttLerp

tttLerp

tttLerp

44

Bernstein Polynomial Form

33

22

12

03

3221

2110

13131)(

111

1111)(

pppp

pppp

pppp

tttttttQ

ttttttt

ttttttttQ

Page 23: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

45

Animations from Wikipedia

De Casteljau Algorithm

d=1

d=2

46

De Casteljau Algorithm

d=3

d=4

Animations from Wikipedia

Page 24: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

47

Drawing Algorithms

Evaluate points and draw lines.

Possibilities:

1. Evaluate recursively Bernstein Polynomials.

2. Compute the geometric matrix.

3. Use the recursive algorithm of De Casteljau.

48

• Are hard to control and hard to work with.

• The intermediate points don’t have obvious effect on shape.

• For large sets of points – curve deviates far from the points.

• Degree corresponds to number of control points.

• Changing any control point can change the whole curve:

– We want local support: each control point only influences nearby portion of curve.

Bezier Curves Drawbacks

Page 25: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

49

Piecewise Curves

• A single cubic Hermite o Bezier curve can only capture a small class of curves:

– At most 2 inflection points.

• One solution is to raise the degree:

– Allows more control, at the expense of more control points and higher degree polynomials.

– Control is not local, one control point influences entire curve.

• Alternate, most common solution is to join pieces of cubic curve together into piecewise cubic curves:

– Total curve can be broken into pieces, each of which is cubic.

– Local control: each control point only influences a limited part of the curve.

– Interaction and design is much easier.

50

Piecewise Bezier Curves

“knot”P0,0

P0,1 P0,2

P0,3

P1,0

P1,1

P1,2

P1,3

If complicated curves are to be generated, they can be formed

by piecing together several Bézier sections.

The curve segments join at knots.

Page 26: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

51

Achieving Continuity

• For Hermite curves:

– the user specifies the derivatives, so C1 is achieved simply by sharing points and derivatives across the knot.

• For Bezier curves:

– They interpolate their endpoints, so C0 is achieved by sharing control points.

– The parametric derivative is a constant multiple of the vector joining the first/last 2 control points.

– So C1 is achieved by setting P0,3=P1,0=P, and making P0,2 and P and P1,1 collinear, with P-P0,2=P1,1-P.

– C2 comes from further constraints on P0,1 and P1,2

C0 continuity

52

Why more curves?

• Bezier and Hermite curves have global influence:

– One could create a Bezier curve that required 15 points to define the curve…

• Moving any one control point would affect the entire curve.

– Piecewise Bezier or Hermite don’t suffer from this, but they don’t enforce derivative continuity at join points.

• B-Splines consist of curve segments whose polynomial coefficients depend on just a few control points:

– Local control

Page 27: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

53

Cubic B-Spline: Geometric Definition• Approximates n+1 control points: P0, P1, … , Pn, n >= 3.

• Consists of n –2 cubic polynomial curve segments: Q3, Q4, … , Qn.

• Defined using a non-decreasing sequence of n-1 parameters: t3,… ,tn+1(knots).

• It is uniform if the elements of the knot sequence are uniformly spaced: ti+1-ti=c , i=3,…,n (without loss of generality, we can assume t3=0 and ti+1-ti =1), otherwise it is non-uniform.

• Curve segment Qi is defined by the control points Pi-3, Pi-2, Pi-1 and Pi over the knot interval [ti,ti+1) (there exist local control).

P0

P1

P2

P3

P5

P4

P6

P7

P8P9

Q3

Q4

Q5

Q6

Q7

Q8

Q9

54

Uniform Cubic B-Splines

Page 28: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

55

Uniform Cubic B-Splines

To determine the equation of the curve segment Q3(t), t in [t3,t4):

• Each control point affects 4 curve segments.

• Formulate 16 equations to solve the 16 unknowns, that correspond to 4 polynomial of degree 3.

• The 16 equations enforce the C0, C1, and C2 continuity between adjoining curve segments.

We obtain:

33

232

132

032

3

04,3

6

13331

6

1364

6

1331

6

1

)()(

PtPtttPttPttt

PtBt kk

kQ

for t in [t3 ,t4).

56

Uniform Cubic B-Splines

33

232

132

10

32

3

04,3

6

13331

6

1364

6

1331

6

1

)()(

PtPtttPttPttt

PtBt kk

kQ

From:

We obtain the matricial expression:

3

2

1

0

233

0141

0303

0363

1331

6

11

P

P

P

P

ttttQ

Page 29: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

57

3

4,3

32

4,2

32

14,1

32

4,0

6

1)(

33316

1)(

3646

1)(

3316

1)(

tt

tttt

ttt

tttt

B

B

B

B

Uniform Cubic B-Splines

Basis or blending cubic functions for curve segment Q3(t):

0

0,1

0,2

0,3

0,4

0,5

0,6

0,7

0 0,1

0,2

0,3

0,4

0,5

0,6

0,7

0,8

0,9 1

t

B0,4

B1,4 B2,4

B3,4

Basis functions for Q3(t), t in [t3,t 4]=[0,1].

58

Uniform Cubic B-Splines

It is not difficult to see that for the curve segment Qi(t),

t in [ti,ti+1), i=3,…,n, we have:

i

ikkki

tBPtQ3

4, )()(

where:

Bi,4(t)=B0,4(t-i).

Page 30: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

59

• The blending functions sum to one, and are positive everywhere.

• The curve lies inside the convex hull of the control points.

• The curve does not interpolate its endpoints.

• Uniform B-splines are C2.

• Moving a control point has a local effect.

Uniform Cubic B-Splines

60

i

n

idi PtBtQ

0

,

Uniform B-Splines: Algebraic Definition

A B-spline curve Q(t), is defined by:

where:

• The Pi, i = 0,1,...,n are the n+1 control points.

• d is the order of the polynomial segments of the B-Spline curve. That means that the curve is made up of piecewise polynomial segments of degree d-1.

• The order d is independent of the number of control points (n+ 1).

• Bi,d are the uniform B-Spline basis or blending functions of degree d-1.

Page 31: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

61

B-Spline Basis FunctionsGiven a non-decreasing knot sequence of n+d+1 parameterst0, … , tn+d , we define:

otherwise 0

1 11,

iii

ttttB

tBtt

tttB

tt

tttB di

idi

didi

kdi

idi 1,1

11,

1,

for d >1 and t in [td-1,n+1).

If the denominator terms on the right hand side of the last equation are zero or the subscripts are out of the range of the summation limits, then the associated fraction is not evaluated and the term becomes zero (avoiding 0/0 expressions).

We will concentrate in uniform B-splines and, without loss of generality, we will assume t0= -3 and ti+1-ti =1.Observe that for a cubic (d=4) B-Spline now we have n+5 parameters: t0, … , tn+4 .

62

B-Splines Basis Functions Computation

B0,0(t) B1,0(t) B2,0(t) B3,0(t) …

B0,1(t) B1,1(t) B2,1(t)

B0,2(t) B1,2(t)

B0,3(t)

t0 t1 t2 t3 t4 …

Page 32: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

63

Bi,1(t)

Bi,1(t) has support (is non zero) on interval [i-3,i-2).

Bi,1(t) is a constant function.

Bi+1,1(t) is just Bi,1 (t) shifted one unit to the right, because the uniform election of parameter knots. We can write: Bi,1(t)=B0,1(t-i).

Blending functions for d=1

B 0,1

0

0,2

0,4

0,6

0,8

1

1,2

-3

-2,8

-2,6

-2,4

-2,2 -2

-1,8

-1,6

-1,4

-1,2 -1

-0,8

-0,6

-0,4

-0,2 0

0,2

0,4

0,6

0,8 1

t

B0

,1(t

)

B 2,1

0

0,2

0,4

0,6

0,8

1

1,2

-3-2 ,8 -2 ,6 -2 ,4 -2 ,2 -2

-1 ,8 -1 ,6 -1 ,4 -1 ,2 -1-0 ,8 -0 ,6 -0 ,4 -0 ,2 0

0 ,2 0 ,4 0 ,6 0 ,8 1

t

B2

,1(t

)

B 3,1

0

0,2

0,4

0,6

0,8

1

1,2

-3-2 ,8 -2 ,6 -2 ,4 -2 ,2 -2

-1 ,8 -1 ,6 -1 ,4 -1 ,2 -1-0 ,8 -0 ,6 -0 ,4 -0 ,2 0

0 ,2 0 ,4 0 ,6 0 ,8 1

t

B3

,1(t

)

B 1,1

0

0,2

0,4

0,6

0,8

1

1,2

-3-2 ,8 -2 ,6 -2 ,4 -2 ,2 -2

-1 ,8 -1 ,6 -1 ,4 -1 ,2 -1-0 ,8 -0 ,6 -0 ,4 -0 ,2 0

0 ,2 0 ,4 0 ,6 0 ,8 1

t

B1

,1(t

)

64

Bi,2(t)B 0,2

0

0,2

0,4

0,6

0,8

1

1,2

-3

-2,8

-2,6

-2,4

-2,2 -2

-1,8

-1,6

-1,4

-1,2 -1

-0,8

-0,6

-0,4

-0,2 0

0,2

0,4

0,6

0,8 1

t

B0

,2(t

)

B 1,2

0

0,2

0,4

0,6

0,8

1

1,2

-3

-2,8

-2,6

-2,4

-2,2 -2

-1,8

-1,6

-1,4

-1,2 -1

-0,8

-0,6

-0,4

-0,2 0

0,2

0,4

0,6

0,8 1

t

B1,

2(t)

B 2,2

0

0,2

0,4

0,6

0,8

1

1,2

-3-2

,8-2

,6-2

,4-2

,2 -2-1

,8-1

,6-1

,4-1

,2 -1-0

,8-0

,6-0

,4-0

,2 00,2 0,4 0,6 0,8 1

t

B2

,2(t

)

12 1

23 3)(2,0 tt

tttB

Blending functions for d=2

Bi,2(t) has support on interval [i-3,i-1).

Bi,2(t) is piecewise linear, made up of two linear segments joined continuously.

We have: Bi,2(t)=B0,2(t-i).

Page 33: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

65

Bi,3(t) B 0,3

0

0,1

0,2

0,3

0,4

0,5

0,6

0,7

0,8

-3

-2,8

-2,6

-2,4

-2,2 -2

-1,8

-1,6

-1,4

-1,2 -1

-0,8

-0,6

-0,4

-0,2 0

0,2

0,4

0,6

0,8 1

t

B0,

3(t)

B 1,3

00,10,20,30,40,50,60,70,8

-3-2 ,8 -2 ,6 -2 ,4 -2 ,2 -2

-1 ,8 -1 ,6 -1 ,4 -1 ,2 -1-0 ,8 -0 ,6 -0 ,4 -0 ,2 0

0,2 0,4 0,6 0,8 1

t

B1,

3(t)

01

12 362

23 3

2

1)(

2

2

2

3,0

tt

ttt

tt

tB

Blending functions for d=3

Bi,3(t) has support on interval [i-3,i).

Bi,3(t) is a piecewise quadratic curve made up of three parabolic segments that are joined continuously.

We have: Bi,3(t)=B0,3(t-i).

66

10 1

01 1333

12 521153

23 3

6

1)(

3

23

23

3

4,0

tt

tttt

tttt

tt

tB

Blending functions for d=4 (cubic)

Bi,4(t) has support on interval [i-3,i+1).

Bi,4(t) is a piecewise cubic curve made up of four cubic segments that are joined continuously.

B 0,4

0

0,1

0,2

0,3

0,4

0,5

0,6

0,7

-3

-2,8

-2,6

-2,4

-2,2 -2

-1,8

-1,6

-1,4

-1,2 -1

-0,8

-0,6

-0,4

-0,2 0

0,2

0,4

0,6

0,8 1

t

B0

,4(t

)

B0,4(t)

Page 34: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

67

Uniform Cubic B-spline Blending Functions

0

0,1

0,2

0,3

0,4

0,5

0,6

0,7

-3 -2,5 -2 -1,5 -1 -0,5 0 0,5 1 1,5 2 2,5 3 3,5 4 4,5 5

t

B0,4 B1,4 B2,4 B3,4 B4,4 B5,4 B6,4

We have: Bi,4(t)=B0,4(t-i).

Observe that at interval [0,1) justfour of the functions are non-zero: B0,4(t), B1,4(t), B0,4(t) and B1,4(t).

They are the four functions that determine the curve segment Q3.

68

Example of Uniform Cubic B-Spline (n=6)

0

0,05

0,1

0,15

0,2

0,25

-3

-2,7

-2,3 -2

-1,6

-1,3

-0,9

-0,6

-0,2 0,1

0,5

0,8

1,2

1,5

1,9

2,2

2,6

2,9

3,3

3,6 4

4,3

4,7

t

Pi

n

ii tBtQ

0

4,

B0,4P0

B1,4P1B2,4P2

B3,4P3

B4,4P4

B5,4P5

B6,4P6

The curve can’t start until there are 4 basis functions active.

Page 35: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

69

Uniform Cubic B-spline at Arbitrary t

• The interval from an integer parameter value i to i+1 is essentially the same as the interval from 0 to 1:

– The parameter value is offset by i.– A different set of control points is needed.

• To evaluate a uniform cubic B-spline at an arbitrary parameter value t:

– Find the greatest integer less than or equal to t: i = floor(t)– Evaluate:

• Valid parameter range: 0 t <n-3, where n is the number of control points

kik

k PitBtQ

3

04,

70

Closed curve

• To obtain a closed curve, repeat the control points P0, P1, P2 at the end of the sequence: P0, P1, P2, ... , P0, P1, P2.

Point interpolation

• On can force the curve pass through a control point by giving that point a multiplicity 3: Pi = Pi+1 = Pi+2 (however, tangent discontinuity may result).

• In particular, to force endpoints interpolation, let: P0 = P1 = P2 and Pn-2 = Pn-1 = Pn.

Cubic B-Splines Shape Modification Using Control Points

Page 36: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

71

NURBS: Non-Uniform Rational B-Splines

NURBS are defined as:

where every point control point has associated a weight .iP

)(

)()(

0,

0,

tBw

PtBwtQ n

jdjj

n

iidii

i

72

NURBS can be made to pass arbitrarily far or near to a control point by

changing the corresponding weight.

All conic sections (a circle for example) can be modelled exactly:

Constructing a 2D-circle with NURBS

NURBS

NURBS inherit all advantages of B-Splines (locality, ...) while extending the liberty of modelling.

Page 37: Curves - UdGima.udg.edu/~sellares/MEG/CurvesMEG09.pdf · • Bezier curves are more intuitive, since we only need to specify control points. From Hermite to Bezier curves Displaying

73

• If all wi are set to the value 1, we obtain standard B-Splines.

• A Bezier curve is a special case of a B-Spline, so NURBS can also represent Bezier curves.

• Today NURBS are standard for modelling.

NURBS

Curves

Toni SellarèsUniversitat de Girona