B-Splines and NURBS: Outline

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

CS 430/536 Outline

Computer Graphics I
•  Types of Curves
–  Splines
B-Splines and NURBS –  B-splines
Week 5, Lecture 9
–  NURBS
David Breen, William Regli and Maxim Peysakhov •  Knot sequences
Geometric and Intelligent Computing Laboratory
•  Effects of the weights
Department of Computer Science
Drexel University
http://gicl.cs.drexel.edu

1 2

Splines Natural Splines


•  Popularized in late 1960s in •  Mathematical representation of physical
US Auto industry (GM) splines
–  R. Riesenfeld (1972) •  C2 continuous
–  W. Gordon •  Interpolate all control
•  Origin: the thin wood or points
metal strips used in •  Have Global control Pn-2
Pn

building/ship construction (no local control) P0


P1
Pn-1

•  Goal: define a curve as a set of piecewise P2

simple polynomial functions connected


together 3 4

B-splines: Basic Ideas B-spline: Benefits


•  Similar to Bézier curves •  User defines degree
–  Smooth blending function times control points –  Independent of the number of control points
•  But: •  Produces a single piecewise curve of a
–  Blending functions are non-zero over only a particular degree
small part of the parameter range
–  No need to stitch together separate curves
(giving us local support)
at junction points
–  When nonzero, they are the “concatenation”
of smooth polynomials. (They are piecewise!) •  Continuity comes for free

5 6

1
B-splines B-splines:
•  Defined similarly to Bézier curves Cox-deBoor Recursion
–  pi are the control points •  Cox-deBoor Algorithm: defines the blending
–  Computed with basis functions (Basis-splines) functions for spline curves (not limited to deg 3)
•  B-spline basis functions are blending functions –  curves are weighted avgs of lower degree curves
–  Each point on the curve is defined by the •  Let Bi ,d (t ) denote the i-th blending function for a
blending of the control points B-spline of degree d, then:
(Bi is the i-th B-spline blending function)
m 1, if t k ≤ t < t k +1
Bk , 0 (t ) = 
p (t ) = ∑ Bi ,d (t ) pi 0, otherwise
i =0 t − tk t −t
Bk ,d (t ) = Bk ,d −1 (t ) + k + d +1 Bk +1,d −1 (t )
–  Bi is zero for most values of t! 7
tk +d − tk t k + d +1 − t k +1 8

B-spline Blending Functions:


B-spline Blending Functions Example for 2nd Degree Splines
Bk , 0 (• t ) is a step function that is 1 in the •  Note: can’t define a
interval
Bk,1 (t)
•  spans two intervals and is a polynomial with these
piecewise linear function that goes properties (both 0 and
from 0 to 1 (and back)
Bk , 2 (• t ) spans three intervals and is a non-zero for ranges)
piecewise quadratic that grows •  Idea: subdivide the
€ from 0 to 1/4, then up to 3/4 in the
middle of the second interval, back parameter space into
to 1/4, and back to 0 intervals and build a
Bk ,3 (• t ) is a cubic that spans four intervals
growing from 0 to 1/6 to 2/3, then piecewise polynomial
back to 1/6 and to 0 –  Each interval gets different
B-spline blending functions polynomial function
9 10
Pics/Math courtesy of Dave Mount @ UMD-CP Pics/Math courtesy of Dave Mount @ UMD-CP

B-spline Blending Functions:


Example for 3rd Degree Splines B-splines: Knot Selection
m
p (t ) = ∑ Bi ,d (t ) pi •  Observe: •  Instead of working with the parameter
i =0 –  at t=0 and t=1 just space 0 ≤ t ≤ 1, use t min ≤ t0 ≤ t1 ≤ t 2 ... ≤ t m −1 ≤ t max
four of the functions
are non-zero •  The knot points
–  all are >=0 and sum –  joint points between
to 1, hence the curve segments, Qi
convex hull property
holds for each curve –  Each has a
segment of a knot value
B-spline –  m-1 knots for
11
m+1 points 12
1994 Foley/VanDam/Finer/Huges/Phillips ICG
1994 Foley/VanDam/Finer/Huges/Phillips ICG

2
Uniform B-splines:
Setting the Options Example: Creating a B-spline
m
•  Specified by
–  m ≥ 3
p (t ) = ∑ Bi ,d (t ) pi •  m=9
•  10 control points
i =0
–  m+1 control points, P0 … Pm •  8 knot points
–  m-2 cubic polynomial curve segments, Q3…Qm •  7 segments
–  m-1 knot points, t3 … tm+1
–  segments Qi of the B-spline curve are
•  defined over a knot interval [ti , ti +1 ]
•  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
14 15
1994 Foley/VanDam/Finer/Huges/Phillips ICG

B-splines:
B-spline: Knot Sequences
Cox-deBoor Recursion
•  Even distribution of knots •  Cox-deBoor Algorithm: defines the blending functions for
–  uniform B-splines spline curves (not limited to deg 3)
–  Curve does not interpolate end points –  curves are weighted avgs of lower degree curves
•  first blending function not equal to 1 at t=0 •  Let Bi,d (t) denote the i-th blending function for a B-spline
•  Uneven distribution of knots of degree d, then:
–  non-uniform B-splines
–  Allows us to tie down the endpoints by repeating knot values
(in Cox-deBoor, 0/0=0) € 1, if t k ≤ t < t k +1
–  If a knot value is repeated, it increases the effect (weight) of the
Bk , 0 (t ) = 
blending function at that point
0, otherwise
–  If knot is repeated d times, blending function converges to 1 and t − tk t −t
the curve interpolates the control point
Bk ,d (t ) = Bk ,d −1 (t ) + k + d +1 Bk +1,d −1 (t )
16
tk +d − tk t k + d +1 − t k +1 17

Creating a Non-Uniform
B-splines: Multiple Knots
B-spline: Knot Selection
•  Given curve of degree d=3, with m+1 control •  Knot Vector
points {0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0}

–  first, create m+d knot values •  Several consecutive


–  use knot values (0,0,0,1,2,…, m-2, m-1,m-1,m-1) knots get the same
(adding two extra 0’s and m-1’s) value
–  Note •  Changes the basis
•  Causes Cox-deBoor to give functions!
added weight in blending to the
first and last points when t is
near tmin and tmax

18 19
Pics/Math courtesy of G. Farin @ ASU From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

3
m
p (t ) = ∑ Bi ,d (t ) pi
i =0
B-spline Summary Watching Effects 00123456789

of Knot Selection
1, if t k ≤ t < t k +1
Bk , 0 (t ) =  •  9 knot points (initially)
0, otherwise
t − tk t −t –  Note: knots are distributed
Bk ,d (t ) = Bk ,d −1 (t ) + k + d +1 Bk +1,d −1 (t )
tk +d − tk t k + d +1 − t k +1 parametrically based on t,
hence why they “move”
•  10 control points
•  Curves have as many
segments as they have
non-zero intervals in u degree of
curve

20 21
Pics/Math courtesy of G. Farin @ ASU

B-splines: Local Control Property


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

22 23
1994 Foley/VanDam/Finer/Huges/Phillips ICG
Recorded from: http://heim.ifi.uio.no/~trondbre/OsloAlgApp.html

B-splines: Convex Hull Property B-splines: Continuity


•  The effect of multiple control points on a •  Derivatives are easy for cubics
uniform B-spline curve 3
p (u ) = ∑ u k ck
k =0

•  Derivative:
p′(u ) = c1 + 2c2u + 3c3u 2

Easy to show C0 , C1 , C2
25 26
1994 Foley/VanDam/Finer/Huges/Phillips ICG

4
B-splines: Setting the Options NURBS
•  How to space the knot points? •  At the core of several
–  Uniform modern CAD systems
–  I-DEAS, Pro/E, Alpha_1
•  equal spacing of knots along the curve
–  Non-Uniform •  Describes analytic and
freeform shapes
•  Which type of parametric function?
•  Accurate and efficient
–  Rational evaluation algorithms
•  x(t), y(t), z(t) defined as ratio of cubic polynomials
•  Invariant under affine and
–  Non-Rational perspective transformations
27 28
U of Utah, Alpha_1

Benefits of
NURBS
Rational Spline Curves
•  Invariant under rotation, scale, translation, Non-uniform Rational B-splines: NURBS
perspective transformations
–  transform just the control points, •  Basic idea: four dimensional non-uniform B-splines,
then regenerate the curve followed by normalization via homogeneous coordinates
–  (non-rationals only invariant under rotation, scale –  If Pi is [x, y, z, 1], results are invariant wrt perspective projection
and translation) •  Also, recall in Cox-deBoor, knot spacing is arbitrary
•  Can precisely define the conic sections and –  knots are close together,
influence of some control points increases
other analytic functions –  Duplicate knots can cause points to interpolate
–  conics require quadratic polynomials –  e.g. Knots = {0, 0, 0, 0, 1, 1, 1, 1} create a Bézier curve
–  conics only approximate with non-rationals
29 30

Rational Functions Rational Functions: Example


•  Cubic curve segments •  Example:
X (t ) Y (t ) Z (t ) –  rational function: a ratio of polynomials
x(t ) = , y (t ) = , z (t ) =
W (t ) W (t ) W (t ) –  a rational parameterization
where X (t ), Y (t ), Z (t ), W (t ) in u of a unit circle in xy-plane:
are all cubic polynomials with control
points specified in homogenous –  a unit circle in 3D homogeneous
coordinates, [x,y,z,w] coordinates:
•  Note: for 2D case, Z (t ) = 0
31 32

5
NURBS: Notation Alert NURBS: Notation Alert
•  Depending on the source/reference 1.  If defined using homogenous
–  Blending functions are either Bi ,d (u ) or N i ,d (u ) coordinates, the 4th (3rd for 2D)
–  Parameter variable is either u or t dimension of each Pi is the weight
–  Curve is either C or P or Q
–  Control Points are either Pi or Bi 2.  If defined as weighted euclidian, a
–  Variables for order, degree, number of control separate constant wi, is defined for
points etc are frustratingly inconsistent each control point
•  k, i, j, m, n, p, L, d, ….
33 34

Observe: Weights Induce New


NURBS
Rational Basis Functions, R
•  A d-th degree NURBS curve C is def’d as: •  Setting: wi Bi ,d (u )
n −1
Ri (u ) = n −1
∑ i =0 i
w Bi ,d (u ) Pi ∑ w B (u )i i ,d
C (u ) = n −1 i =0

∑ i =0
wi Bi ,d (u ) n −1
Where Allows us to write: C (u ) = ∑ Ri ,d (u ) Pi
i =0
–  control points,
–  d-th degree B-spline blending functions, Bi ,d (u ) Where Ri,d (u ) are rational basis functions
–  the weight, wi, for control point Pi –  piecewise rational basis functions on u ∈ [0,1]
(when all wi=1, we have a B-spline curve) 35 –  weights are incorporated into the basis fctns
36

Geometric Interpretation of
NURBS: Examples
NURBS
•  With Homogeneous coordinates, a rational n- •  Unif. Knot Vector •  Non-Unif. Knot Vector
D curve is represented by polynomial curve in
(n+1)-D
•  Homogeneous 3D control points are written
as:
in 4D where {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}

•  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) 37 38
From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

6
NURBS: Examples NURBS: Examples
•  Knot Vector •  Knot Vector
{0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0} {0.0, 1.0, 2.0, 3.0, 3.0, 5.0, 6.0, 7.0}

•  Several consecutive •  Several consecutive


knots get the same knots get the same
value value
•  Bunches up the curve •  Bunches up the curve
and forces it to and forces it to
interpolate interpolate
•  Can be done midcurve
39 40
From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

The Effects of the Weights The Effects of the Weights


•  wi of Pi effects only the range [ui, ui+k+1) •  Increased weight
•  If wi=0 then Pi does not contribute to C pulls the curve
•  If wi increases, point B and curve C are pulled toward B3
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)

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

Programming assignment 3
•  Input PostScript-like file containing polygons
•  Output B/W XPM
•  Implement viewports
•  Use Sutherland-Hodgman intersection for
polygon clipping
•  Implement scanline polygon filling. (You
cannot use flood filling)

43

You might also like