• BSplines
11/26/02 (C) University of Wisconsin
• More B-splines
• Surface patches
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• 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 : (t
0
,t
1
,…,t n+d
) with t
0
t
1
… t n+d
• Curve only defined for parameter values between t d-1 and t n+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
11/26/02 (C) University of Wisconsin
B k , 1
1
0 t k
t
t k
1 otherwise
B k , d
t k t
d
1 t
k t k t k
d
d
t k t
1 t k
B k
B k , d
1
1 , d
1
• 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
11/26/02 (C) University of Wisconsin
• 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
–
B k,d
(t)=B k+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
11/26/02 (C) University of Wisconsin
B 0,1
0.6
0.4
0.2
0
1.2
1
0.8
t
B 2,1
1.2
1
0.8
0.6
0.4
0.2
0
-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
11/26/02 (C) University of Wisconsin
B k,1
B 1,1
1.2
1
0.8
0.6
0.4
0.2
0
-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
t
0
0.
2
0.
4
0.
6
0.
8 1
B 3,1
1.2
1
0.8
0.6
0.4
0.2
0
-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
t
0
0.
2
0.
4
0.
6
0.
8 1
B 0,2
1.2
1
0.8
0.6
0.4
0.2
0 t
B 2,2
0.6
0.4
0.2
0
1.2
1
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
t
0
0.
2
0.
4
0.
6
0.
8 1
B k,2
B 1,2
1.2
1
0.8
0.6
0.4
0.2
0
-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
t
0
0.
2
0.
4
0.
6
0.
8 1
B
0 , 2
( t )
t
3
3
t
2
1
t
2
t
1
11/26/02 (C) University of Wisconsin
0.3
0.2
0.1
0
0.8
0.7
0.6
0.5
0.4
11/26/02
B k,3
B 0,3 B 1,3
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-3
-2
.8
-2
.6
-2
.4
-2
.2
-2
-1
.8
-1
.6
-1
.4
-1
.2
-1
-0
.8
t
-0
.6
-0
.4
-0
.2
0
0.
2
0.
4
0.
6
0.
8 1 t
B
0 , 3
( t )
1
2
t t
2 t
2
2
3
2
6 t
3
1
3
2
t t t
0
2
1
(C) University of Wisconsin
11/26/02
B
0,4
B 0,4
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0 t
(C) University of Wisconsin
B
0,4
B
0 , 4
( t )
1
t
3 t
3
3
3
15 t
2
21 t
5
3
2
t t
2
1
6
3 t
1
3
3 t
2
3 t
3
1
0
1
t t
1
0
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
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• Basic idea: Generate 2 n -3 new control points:
– Add a new control point in the middle of each curve segment: P’
P’
1,2
, P’
2,3
, …, P’ n -2, n -1
0,1
,
– Modify existing control points: P ’
1
, P ’
2
, … , P ’ n -2
• Throw away the first and last control
• Rules:
P i
, j
1
2
P i
P j
, P i
'
1
8
P i
1
6 P i
P i
1
• If the curve is a loop, generate 2 n new control points by averaging across the loop
• When drawing, don’t draw the control polygon, join the
X(i) points
11/26/02 (C) University of Wisconsin
• Each point is the ratio of two curves
– Just like homogeneous coordinates:
[ x ( t ), y ( t ), z ( t ), w ( t )]
x w
(
( t t )
)
, y ( t w ( t )
)
, z ( t ) w ( t )
– 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
11/26/02 (C) University of Wisconsin
• Define points on the surface in terms of two parameters
• Simplest case: bilinear interpolation s
P
0,1 x ( s , 0 )
( 1
s ) P
0 , 0
sP
1 , 0 x ( s , 1 ) x ( s , t )
( 1
s ) P
0 , 1
sP
1 , 1
( 1
t ) x ( s , 0 )
tx ( s , 1 ) x ( s,1 ) x ( s , t ) t
F
0 , s
F
0 , t
1
s , F
1 , s
1
t , F
1 , t
s
t
P
0,0 x ( s , t )
1 1 i
0 j
0
P i , j
F i , s
( s ) F j , t
( t ) s x ( s,0 )
P
1,1
P
1,0
11/26/02 (C) University of Wisconsin
• Defined over a rectangular domain
– Valid parameter values come from within a rectangular region in parameter space: 0
s<1, 0
t<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: x ( s , t )
– For some functions
F i,s and F j,t
i d d s t
0 j
0
P i , j
F i , s
( s ) F j , t
( t )
11/26/02 (C) University of Wisconsin
x
i m n
0 j
0
P i , j
B i n
j t
• As with Bezier curves, B i n (s) and
B j m (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,
P i,j
11/26/02 (C) University of Wisconsin
• 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)
11/26/02 (C) University of Wisconsin
• 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?
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
x ( s , t )
S
T
B
T
PBT x ( s , t )
s
3 s
2 s 1
3
1
1
3
3
3
0
6
3
0
0
3 1
0
0
0
P
0
P
1 ,
P
2
P
3 ,
,
, 0
0
0
0
P
0 , 1
P
1 , 1
P
2 , 1
P
3 , 1
P
0
P
1 ,
P
2
P
3
,
,
,
2
2
2
2
P
0
P
1 ,
P
2
P
3 ,
, 3
3
, 3
3
3
1
1
3
3
3
0
6
3
0
0
• Note that the 3 matrices stay the same if the control points do not
3 change
– The middle product can be pre-computed, leaving only: x ( s , t )
s
3 s
2 s 1
M
M
M
M
0 , 0
1 , 0
2 , 0
3 , 0
M
0 , 1
M
1 , 1
M
2 , 1
M
3 , 1
M
0 , 2
M
1 , 2
M
2 , 2
M
3 , 2
M
M
M
0 , 3
1 , 3
2 , 3
M
3 , 3
t t t
1
3
2
1
0
0
0
t
t t
1
2
3
11/26/02 (C) University of Wisconsin
• A patch mesh is just many patches joined together along their edges
– Patches meet along complete edges
– Each patch must be a quadrilateral
OK
11/26/02
OK
Not OK
(C) University of Wisconsin
Not OK
• Just like curves, the control points must satisfy rigid constraints to ensure parametric continuity
– How do we ensure C 0 continuity along an edge?
– How do we ensure C 1 continuity along an edge?
– How do we ensure C 2 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 C 1 continuity at the corner point?
11/26/02 (C) University of Wisconsin
• Just like curves, the control points must satisfy rigid constraints to ensure parametric continuity
– C 0 continuity along an edge? Share control points at the edge
– C 1 continuity along an edge? Control points across edge are collinear and equally spaced
– C 2 continuity along an edge? Constraints extent to points farther from the edge
• For geometric continuity, constraints are less rigid
– Still collinear for G 1 , but can be anywhere along the line
• What can you say about the vertices around a corner if there must be C 1 continuity at the corner point?
– They are co-planar (not the interior points, just corner and edge)
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• 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
11/26/02 (C) University of Wisconsin
• 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
x
s s , t
i m n
0 j
0
P i , j dB i n ds s
B j m
x
t s , t
i m n
0 j
0
P i , j
B i n dB j m dt t n
x
s s , t
x
t s , t
ˆ n n
11/26/02 (C) University of Wisconsin
• Defined just like Bezier surfaces:
X
j n m
0 k
0
P j , k
B j , d
( s ) B k , d
• Continuity is automatically obtained everywhere
• BUT, the control points must be in a rectangular grid
11/26/02
OK
(C) University of Wisconsin
Not OK
• 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)
11/26/02 (C) University of Wisconsin