11/26/02(c) university of wisconsin last time bsplines

31
11/26/02 (C) University of Wiscons in Last Time • BSplines

Upload: charla-harvey

Post on 06-Jan-2018

213 views

Category:

Documents


0 download

DESCRIPTION

11/26/02(C) University of Wisconsin Non-Uniform B-Splines Uniform B-splines are a special case of B-splines Each blending function is the same A blending functions starts at t=-3, t=-2, t=-1,… Each blending function is non-zero for 4 units of the parameter Non-uniform B-splines can have blending functions starting and stopping anywhere, and the blending functions are not all the same

TRANSCRIPT

Page 1: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Last Time

• BSplines

Page 2: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Today

• More B-splines• Surface patches

Page 3: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Non-Uniform B-Splines

• Uniform B-splines are a special case of B-splines• Each blending function is the same• A blending functions starts at t=-3, t=-2, t=-1,…• Each blending function is non-zero for 4 units of the

parameter• Non-uniform B-splines can have blending functions starting

and stopping anywhere, and the blending functions are not all the same

Page 4: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

B-Spline Knot Vectors• Knots: Define a sequence of parameter values at which the blending

functions will be switched on and off• Knot values are increasing, and there are n+d+1 of them, forming a

knot vector: (t0,t1,…,tn+d) with t0 t1 … tn+d

• Curve only defined for parameter values between td-1 and tn+1

• These parameter values correspond to the places where the pieces of the curve meet

• There is one control point for each value in the knot vector• The blending functions are recursively defined in terms of the knots and

the curve degree

Page 5: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

otherwise 0 1 1

1,kk

k

ttttB

B-Spline Blending Functions

• The recurrence relation starts with the 1st order B-splines, just boxes, and builds up successively higher orders

• This algorithm is the Cox - de Boor algorithm– Carl de Boor is a professor here

tBtttt

tBtt

tttB

dkkdk

dk

dkkdk

kdk

1,11

1,1

,

Page 6: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Uniform Cubic B-splines• Uniform cubic B-splines arise when the knot vector is of the form (-3,-

2,-1,0,1,…,n+1)• Each blending function is non-zero over a parameter interval of length 4• All of the blending functions are translations of each other

– Each is shifted one unit across from the previous one– Bk,d(t)=Bk+1,d(t+1)

• The blending functions are the result of convolving a box with itself d times, although we will not use this fact

Page 7: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bk,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

t

B2,

1(t)

B 3,1

0

0.2

0.4

0.6

0.8

1

1.2

t

B3,

1(t)

B 1,1

0

0.2

0.4

0.6

0.8

1

1.2

t

B1,

1(t)

Page 8: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bk,2

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

t

B1,

2(t)

B 2,2

0

0.2

0.4

0.6

0.8

1

1.2

t

B2,

2(t)

12 123 3

)(2,0 tttt

tB

Page 9: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bk,3

B 0,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

B0,

3(t)

B 1,3

00.10.20.30.40.50.60.70.8

t

B1,

3(t)

01

12 36223 3

21)(

2

2

2

3,0

ttttttt

tB

Page 10: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

B0,4

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)

Page 11: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

B0,4

10 101 1333

12 52115323 3

61)(

3

23

23

3

4,0

tttttttttttt

tB

Note that the functions given on earlier slides are translates of this function obtained by using (t-1), (t-2) and (t-3) instead of just t, and then selecting only a sub-range of t values for each function

Page 12: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Interpolation and Continuity• The knot vector gives a user control over interpolation and continuity• If the first knot is repeated three times, the curve will interpolate the

control point for that knot– Repeated knot example: (-3,-3,-3, -2, -1, 0, …)– If a knot is repeated, so is the corresponding control point

• If an interior knot is repeated, continuity at that point goes down by 1• Interior points can be interpolated by repeating interior knots• A deep investigation of B-splines is beyond the scope of this class

Page 13: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Rendering B-splines

• Same basic options as for Bezier curves– Evaluate at a set of parameter values and join with lines

• Hard to know where to evaluate, and how pts to use– Use a subdivision rule to break the curve into small pieces, and then

join control points• What is the subdivision rule for B-splines?

• Instead of subdivision, view splitting as refinement:– Inserting additional control points, and knots, between the existing

points– Useful not just for rendering - also a user interface tool– Defined for uniform and non-uniform B-splines by the Oslo algorithm

Page 14: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Refining Uniform Cubic B-splines• Basic idea: Generate 2n-3 new control points:

– Add a new control point in the middle of each curve segment: P’0,1, P’1,2, P’2,3 , …, P’n-2,n-1

– Modify existing control points: P’1, P’2, …, P’n-2

• Throw away the first and last control

• Rules:

• If the curve is a loop, generate 2n new control points by averaging across the loop

• When drawing, don’t draw the control polygon, join the X(i) points

11, 681' ,

21

iiiijiji PPPPPPP

Page 15: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Rational Curves

• Each point is the ratio of two curves– Just like homogeneous coordinates:

– NURBS: x(t), y(t), z(t) and w(t) are non-uniform B-splines

• Advantages:– Perspective invariant, so can be evaluating in screen space– Can perfectly represent conic sections: circles, ellipses, etc

• Piecewise cubic curves cannot do this

)()(,

)()(,

)()()](),(),(),([

twtz

twty

twtxtwtztytx

Page 16: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Parametric Surfaces• Define points on the surface in terms of two parameters• Simplest case: bilinear interpolation

s

t

s

x(s,t)

P0,0

P1,0

P1,1P0,1

x(s,0)

x(s,1)

1

0

1

0,,,

,1,0

,1,0

1,11,0

0,10,0

)()(),(

,1

,1

)1,()0,()1(),(

)1()1,(

)1()0,(

i jtjsiji

tt

ss

tFsFPtsx

tFtF

sFsF

stxsxttsx

sPPssx

sPPssx

Page 17: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Tensor Product Surface Patches

• Defined over a rectangular domain– Valid parameter values come from within a rectangular region in

parameter space: 0s<1, 0t<1

• Use a rectangular grid of control points to specify the surface– 4 points in the bi-linear case on the previous slide, more in other

cases

• Surface takes the form:– For some functions Fi,s and Fj,t

s td

i

d

jtjsiji tFsFts

0 0,,, )()(),( Px

Page 18: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Patches

• As with Bezier curves, Bin(s) and

Bjm(t) are the Bernstein polynomials

of degree n and m respectively• Most frequently, use n=m=3: cubic

Bezier patch– Need 4x4=16 control points, Pi,j

n

i

m

j

mj

niji tBsBts

0 0,, Px

Page 19: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Patches (2)• Edge curves are Bezier curves• Any curve of constant s or t is a Bezier curve• One way to think about it:

– Each row of 4 control points defines a Bezier curve in s– Evaluating each of these curves at the same s provides 4 virtual control points– The virtual control points define a Bezier curve in t– Evaluating this curve at t gives the point x(s,t)

x(s,t)

Page 20: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Properties of Bezier Patches• Which vertices, if any, does the patch interpolate? Why?• What can you say about the tangent plane at each corner? Why?• Does the patch lie within the convex hull of its control vertices?

Page 21: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Properties of Bezier Patches• The patch interpolates its corner points

– Comes from the interpolation property of the underlying curves• The tangent plane at each corner interpolates the corner vertex and the

two neighboring edge vertices– The tangent plane is the plane that is perpendicular to the normal vector at a

point– The tangent plane property derives from the curve tangent properties and

the way to compute normal vectors• The patch lies within the convex hull of its control vertices

– The basis functions sum to one and are positive everywhere

Page 22: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Patch Matrix Form

• Note that the 3 matrices stay the same if the control points do not change

– The middle product can be pre-computed, leaving only:

10001003303631331

0001003303631331

1),(

),(

2

3

3,32,31,30,3

3,22,21,20,2

3,12,11,10,1

3,02,01,00,0

23

ttt

PPPPPPPPPPPPPPPP

ssstsx

PBTBStsx TT

1

1),(2

3

3,32,31,30,3

3,22,21,20,2

3,12,11,10,1

3,02,01,00,0

23

ttt

MMMMMMMMMMMMMMMM

ssstsx

Page 23: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Patch Meshes• A patch mesh is just many patches joined together along their edges

– Patches meet along complete edges– Each patch must be a quadrilateral

OKOK Not OK Not OK

Page 24: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Mesh Continuity• Just like curves, the control points must satisfy rigid constraints to

ensure parametric continuity– How do we ensure C0 continuity along an edge?– How do we ensure C1 continuity along an edge?– How do we ensure C2 continuity along an edge?

• For geometric continuity, constraints are less rigid• What can you say about the vertices around a corner if there must be C1

continuity at the corner point?

Page 25: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Bezier Mesh Continuity• Just like curves, the control points must satisfy rigid

constraints to ensure parametric continuity– C0 continuity along an edge? Share control points at the edge– C1 continuity along an edge? Control points across edge are collinear

and equally spaced– C2 continuity along an edge? Constraints extent to points farther

from the edge• For geometric continuity, constraints are less rigid

– Still collinear for G1, but can be anywhere along the line• What can you say about the vertices around a corner if there

must be C1 continuity at the corner point?– They are co-planar (not the interior points, just corner and edge)

Page 26: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Rendering Bezier Patches

• Option 1: Evaluate at fixed set of parameter values and join up with triangles– Can’t use quadrilaterals because points may not be co-planar– Ideal situation for triangle strips– Advantage: Simple, and OpenGL has commands to do it for you– Disadvantage: No easy way to control quality of appearance

• Option 2: Subdivide– Allows control of error in the triangle approximation– Defined much like curve subdivision, but done once in each

parametric direction

Page 27: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Midpoint Subdivision• Repeatedly join midpoints to find new control vertices

– Do it first for each row of original control points: 4x4 -> 4x7– Then do it for each column of new control points:4x7 -> 7x7

Page 28: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

A Potential Problem• One (good) way to subdivide, is:

– If a control mesh is flat enough – draw it– Else, subdivide into 4 sub-patches and recurse on each

• Problem: Neighboring patches may not be subdivided to the same level– Cracks can appear because join edges have different control meshes– This can be fixed by adding extra edges

Crack

Page 29: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

Computing Normal Vectors• The partial derivative in the s direction is one tangent vector• The partial derivative in the t direction is another• Take their cross product, and normalize, to get the surface normal

vector

n

i

m

j

mj

s

ni

jits

tBds

dBs 0 0

,,

Px

n

i

m

j t

mjn

ijits dt

dBsB

t 0 0,

,

Px

nnn xxn

ˆ ,, tsts ts

Page 30: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

B-Spline Surfaces

• Defined just like Bezier surfaces:

• Continuity is automatically obtained everywhere• BUT, the control points must be in a rectangular grid

m

j

n

kdkdjkj tBsBPtsX

0 0,,, )(,

OK Not OK

Page 31: 11/26/02(C) University of Wisconsin Last Time BSplines

11/26/02 (C) University of Wisconsin

How to Choose a Spline

• Hermite curves are good for single segments where you know the parametric derivative or want easy control of it

• Bezier curves are good for single segments or patches where a user controls the points

• B-splines are good for large continuous curves and surfaces• NURBS are the most general, and are good when that

generality is useful, or when conic sections must be accurately represented (CAD)