Está en la página 1de 10

CS 536

Computer Graphics Outline


Hermite Curves
Hermite Curves, B-Splines More Types of Curves
and NURBS Splines
B-splines
Week 2, Lecture 4
David Breen, William Regli and Maxim Peysakhov NURBS
Department of Computer Science
Knot sequences
Drexel University
Effects of the weights
Additional slides from Don Fussell, University of Texas
1 2

Hermite Curve Algebraic Representation


All of these curves are just parametric algebraic polynomials
3D curve of polynomial bases expressed in different bases
Parametric linear curve (in R3) x = ax u + bx
Geometrically defined by position P(u) = au + b y = ay u + by
and tangents at end points z = az u + bz

No convex hull guarantees Parametric cubic curve (in R3) x = ax u + bx u + c x u + dx


3 2

P(u) = au3 + bu 2 + cu+ d y = ay u 3 + by u 2 + c y u + dy


Able to tangent-continuous (C1)
z = az u 3 + bz u 2 + c z u + dz
composite curve
Basis (monomial or power) [u 1]
[u 3
u2 u 1]
3
D. Fussell UT, Austin

Hermite Curves Hermite Basis


12 degrees of freedom (4 3-d vector Substituting for the coefficients and collecting terms gives
constraints) P(u) = (2u3 3u 2 +1)p(0) + (2u3 + 3u 2 )p(1) + (u3 2u 2 + u)p u (0) + (u3 u 2 )p u (1)

Specify endpoints and tangent vectors at H1 H2


endpoints Call
P(0) = d u dP
p (u) (u) 3
H1 (u) = (2u 3u + 1) 2

P(1) = a + b + c + d du
u H 2 (u) = (2u 3 + 3u 2 )
P (0) = c
H 3 (u) = (u 3 2u 2 + u) H3
P u (1) = 3a + 2b + c pu(0) pu(1)
H 4 (u) = (u 3 u 2 )
n

Solving for the coefficients: p(1)


u=1 H4
a = 2p(0) 2p(1) + pu (0) + pu (1)
the Hermite blending functions or basis functions
u u
b = 3p(0) + 3p(1) 2p (0) p (1)
c = pu (0)
u=
p(0)0
u
Then P(u) = H1 (u)p(0) + H 2 (u)p(1) + H 3 (u)p (0) + H 4 (u)p (1)
u

d = p(0)
D. Fussell UT, Austin D. Fussell UT, Austin

1
Blending Functions Hermite Curves - Matrix Form
3 2 3 2 3 2 u 3 2 u
P(u) = (2u 3u +1)p(0) + (2u + 3u )p(1) + (u 2u + u)p (0) + (u u )p (1) Putting this in matrix form H = [H1 (u) H 2 (u) H 3 (u) H 4 (u)]
# 2 2 1 1 &
% (
H2(u) H4(u) 3 3 2 1(
H1(u) H3(u) = [u 3 u2 u 1] %
%0 0 1 0(
% (
$1 0 0 0'
= UM H

At u = 0: P(0) = p0 MH is called the Hermite characteristic matrix


! p(0) $
H1 = 1, H2 = H3 = H4 = 0 P(0) = T0 Collecting the Hermite geometric
# &
H1 = H2 = H4 = 0, H3 = 1 coefficients into a
geometry vector B, # p(1) &
we have a matrix formulation for B =# u &
At u = 1: P(1) = p1 the Hermite curve P(u)
# p (0) &
H1 = H3 = H4 = 0, H2 = 1 P(1) = T1 # u &
" p (1) %
H1 = H2 = H3 = 0, H4 = 1 P(u) = UM H B
D. Fussell UT, Austin

Hermite and Algebraic Forms Hermite Curves


MH transforms geometric coefficients Geometrically defined by position
(coordinates) from the Hermite basis to the and tangents at end points
algebraic coefficients of the monomial basis
! a $
# &
b &
A =#
# c &
# d & #0 0 0 1&
" % % (
1 1 1 1(
P(u) = UA = UM H B M =% 1
H
%0 0 1 0(
A = MHB % (
$3 2 1 0'
B = M1
HA

10
D. Fussell UT, Austin

Issues with Bzier Curves Continuity


Creating complex curves may (with lots Two types:
of wiggles) requires many control points Geometric Continuity, Gi:
potentially a very high-degree polynomial endpoints meet
tangent vectors directions are equal
Bzier blending functions have global
Parametric Continuity, Ci:
support over the whole curve
endpoints meet
move just one point, change whole curve tangent vectors directions are equal
Improved Idea: link (C1) lots of low tangent vectors magnitudes are equal
degree (cubic) Bzier curves end-to-end In general: C implies G but not vice versa

11 12

2
Parametric Continuity Continuity
Continuity (recall from the calculus): What are the conditions for C0 and C1
Two curves are Ci continuous at a point p iff the continuity at the joint of curves xl and xr?
i-th derivatives of the curves are equal at p tangent vectors at end points equal
end points equal
dQ l dQ r
Q l (1) = Q r (0), (1) = (0)
dt dt

13 Ql Qr 14
Pics/Math courtesy of Dave Mount @ UMD-CP 1994 Foley/VanDam/Finer/Huges/Phillips ICG

Continuity Continuity
In 3D, compute this for each component of
The derivative of is the parametric the parametric function
tangent vector of the curve: For the x component:

Similar for the y and z components.

15 xl xr 16
1994 Foley/VanDam/Finer/Huges/Phillips ICG 1994 Foley/VanDam/Finer/Huges/Phillips ICG

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 17 18

3
B-splines: Basic Ideas B-spline: Benefits
Similar to Bzier 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!

19 20

B-splines B-splines:
Defined similarly to Bzier 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! 21
tk +d tk t k + d +1 t k +1 22

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: cant 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
23 24
Pics/Math courtesy of Dave Mount @ UMD-CP Pics/Math courtesy of Dave Mount @ UMD-CP

4
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 in t=0 to t=1 range space 0 t 1, use t min t0 t1 t 2 ... t m 1 t max
just four of the
functions are non- The knot points
zero joint points between
all are >=0 and sum curve segments, Qi
to 1, hence the
convex hull property Each has a
holds for each curve knot value
segment of a m-1 knots for
B-spline m+1 points
25 26
1994 Foley/VanDam/Finer/Huges/Phillips ICG
1994 Foley/VanDam/Finer/Huges/Phillips ICG

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, Q3Qm 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
28 29
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 )
30
tk +d tk t k + d +1 t k +1 31

5
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 0s and m-1s) 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

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

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

34 35
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
defn, affected region
extends at most 2 knot
points away

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

6
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
39 40
1994 Foley/VanDam/Finer/Huges/Phillips ICG

B-splines: Setting the Options NURBS


How to space the knot points? At the core of several
Uniform modern CAD systems
equal spacing of knots along the curve I-DEAS, Pro/E, Alpha_1

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
41 42
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 Bzier curve
conics only approximate with non-rationals
43 44

7
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
45 46

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, .
47 48

Observe: Weights Induce New


NURBS
Rational Basis Functions, R
A d-th degree NURBS curve C is defd 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) 49 weights are incorporated into the basis fctns
50

8
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) 51 52
From http://devworld.apple.com/dev/techsupport/develop/issue25/schneider.html

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
53 54
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)

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

9
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
57

10

También podría gustarte