B-spline Curves

advertisement
V. Space Curves
• Types of curves
- Explicit
- Implicit
- Parametric
5-1
• Modeling with curves
interpolating data point
data points
approximating curve
• Curves with explicit representation
- xx
y  f ( x)
z  g ( x)
5-2
• Curves with implicit representation
- Intersect two surface to get a curve
- f ( x, y , z )  0
g ( x, y , z )  0
p(t)
• Parametric space curves
- x  x(t ) , t1  t  t 2
y  y (t )
p(t2)
p(t1)
z  z (t )
- Example: The parametric equations
of the circular helix are given by
5-3
Selecting Functions
• Usually we can select “good” functions
- not unique for a given spatial curve
- Approximate or interpolate known data
- Want functions which are easy to evaluate
- Want functions which are easy to differentiate
• Computation of normals
• Connecting pieces (segments)
- Want functions which are smooth
5-4
Parametric Lines
• We can normalize t to be over the interval (0,1)
• Line connecting two points p0 and p1
p(1)= p1
p(t)=(1-t)p0+tp1
p(0) = p0
• Ray from p0 in the direction d
p(u)=p0+td
p(1)= p0 +d
d
p(0) = p0
5-5
Parametric Polynomial Curves
N
M
i 1
j 1
x(t )   B xi t i 1 y (t )   B yj t j 1
L
z (t )   B zk t k 1
k 1
• If N=M=L, we need to determine 3N coefficients
• Equivalently we need 3N independent conditions
• Noting that the curves for x, y and z are
independent, we can define each independently in an
identical manner
N
P(t )   Bi t i 1
• We will use the form where
i 1
P can be any of x, y, z
P(t )  [ x(t ) y(t ) z (t )]
5-6
Cubic Splines
4
x(t )   Bix t i 1
• N=M=L=3:
4
P(t )   Bi t
i 1
i 1
4
i 1
 B1  B2t  B3t  B4t
2
t1  t  t 2
3
y (t )   Biy t i 1
i 1
4
z (t )   Biz t i 1
i 1
5-7
• Four coefficients to determine for each of x, y
and z
• Seek four independent conditions for various
values of t resulting in 4 equations in 4 unknowns
for each of x, y and z
• Boundary conditions:
, and let t1= 0
P(0)  P1 , P(t2 )  P2
P(0)  P1, P(t2 )  P2
5-8
• Piecewise cubic
spline through n given
position vectors Pk
, 1  k  n , with end
tangent vectors P1
and Pn
• The internal tangent
vectors P2 , P3, , Pn1
can be determined by imposing the continuity
conditions at the internal joints, i.e., the second
derivatives or the curvature are continuous across the
joints.
4
i 3
P
"
(
t
)

(
i

1
)(
i

2
)
B
t
•

i
i 1
5-9
5-10
• The generalized equation for a piecewise cubic spline
4
Pk (t )   Bik t i 1 0  t  tk 1 , 1  k  n  1
i 1
5-11
Blending or weighting functions:
5-12
• In matrix form: Pk (t )  [ F ] [G] , where
[ F ]  [ F1 ( ) F2 ( ) F3 ( ) F3 ( )] is a blending
function, and [G]T  [Pk
contains the
geometric
information.
Pk 1 Pk
Pk1 ]
• Any point on a
cubic spline
segment is a
weighted sum of
the end position
and tangent
vectors
5-13
5-14
5-15
5-16
5-17
5-18
• Normalized cubic spline: segment parameter values
is normalized to unity, i.e., 0  t  1
Blending functions become:
P(t )  [ F ] [G]  [T ] [ N ] [G]
5-19
The internal tangent vectors required in [G ] ,
now becomes
5-20
5-21
5-22
5-23
5-24
Bezier Curves
• Mathematically a parametric Bezier curve is defined by
n
P(t )   Bi J n, i (t )
0  t 1
i 0
where Bi is the position vectors of the vertices of the
defining polygon, and
 n
 n i
n!
n i
  
J n, i (t )   t (1  t )
 i  i!(n  i)!
i
J n, i (t ) is the ith nth-order Bezier or Bernstein basis or
blending function. Here n, the degree of the defining
Bernstein basis function and thus of the polynomial
curve segment, is one less than the number of points in
the defining Bezier polygon.
5-25
The vertices of the Bezier polygon are numbered from
0 to n.
• Properties of Bezier curve
- The basis functions are real.
- The degree of the polynomial defining the curve segment
is one less than the number of defining polygon points.
5-26
- The curve generally follows the shape of the defining
polygon.
- The first and last points on the curve are coincident with
the first and last points of the defining polygon.
- The tangent vectors at the ends of the curve have the
same direction as the first and last polygon spans,
respectively.
- The curve is contained within the convex hull of the
defining polygon, i.e., within the largest convex
polygon obtainable with the defining polygon vertices
- The curve is invariant under an affine transformation.
5-27
• The maximum value of each blending function occurs
at t  i / n , and is given by
 n  i i ( n  i ) n i
i
J n, i ( )   
n i
nn
5-28
• For any given
value of the
parameter t, the
summation of
the basis
functions is
precisely one;
i.e.,
n
J
i 0
n, i
(t )  1
5-29
5-30
5-31
• The matrix form
for a Bezier curve
P(t )  [ F ][G ]
 [T ][ N ][G ]
where
[ F ]  [ J n, 0
J n, 1  J n, n ]
[G]T  [B0
B 1  Bn ]
[T ]  [t n
t n1  t 1]
5-32
The individual terms in [N] can be given by
5-33
[N] can be also decomposed into the form: [ N ]  [C ][ D]
where
5-34
•
For example, considering four defining polygon
n points
3 (
), the cubic Bezier curve is given by
• The first and second derivatives of a Bezier curve
5-35
5-36
5-37
5-38
5-39
5-40
• Two characteristics of the Bernstein basis limit the
flexibility of the Bezier curves
- First the number of specified polygon vertices fixes
the order of the resulting polynomial which defines the
curve.
- Second the global nature of the Bernstein basis limits
the ability to produce a local change within a curve.
Since the value of the blending function is nonzero for
all parameter values over the entire curve and any
point on a Bezier curve is a result of blending the
values of all defining vertices, a change in one vertex
is felt throughout the entire curve
5-41
B-spline Curves
• B-spline basis function is generally nonglobal. The
nonglobal behavior of B-spline curves is due to the
fact that each vertex is associated with a unique
basis function.
• The B-spline basis also allows the order of the basis
function and hence the degree of the resulting curve
to be changed without changing the number of
defining polygon vertices.
• A B-spline Curve is given by
n 1
P(t )   Bi Ni ,k (t ) tmin  t  tmax
2  k  n 1
i 1
5-42
where Bi are the position vectors of the n  1 defining
polygon vertices and N i , k are the normalized B-spline
basis functions. For the ith normalized B-spline basis
function of order k (degree k  1 ), the basis functions
N i , k (t ) are defined by the Cox-deBoor recursion
formulas:
1 if xi  t  xi 1
Ni ,1 (t )  
otherwise
0
Ni ,k (t ) 
(t  xi )Ni ,k 1 (t )
xi  k 1  xi

( xi  k  t )Ni 1,k 1 (t )
xi  k  xi 1
The value of xi are elements of a knot vector satisfying
the relation xi  xi 1
5-43
The parameter t varies from tmin to tmax along the
curve P(t)
The convention 0 / 0  0 is adopted.
• Formally a B-spline curve is defined as a polynomial
spline function of order k (degree k  1 ) since it
satisfies the following two conditions:
- The function P(t) is a polynomial of degree k  1
on each interval xi  t  xi 1
.
- P(t) and its derivatives
of order 1, 2, , k  2 are
all continuous over the entire curve.
• Properties of B-spline curves:
n 1
- The sum of the B-spline basis functions for N (t )  1

i, k
any parameter value t can be shown to be i 1
5-44
- Each basis function is positive or zero for all
parameter values, i.e., N i , k  0
- Except for k  1 each basis function has precisely one
maximum value.
- The maximum order of the curve is equal to the
number of defining polygon vertices.
- The curve generally follows the shape of the defining
polygon.
- Any affine transformation can be applied to the curve
by applying it to the defining polygon vertices; i.e.,
the curve is transformed by transforming the defining
polygon vertices.
- The curve lies within the convex hull of its defining
polygon.
5-45
• Convex hull property: For a B-spline curve of order k
(degree k  1) a point on the curve lies within the
convex hull of k neighboring points
5-46
• Colinear polygon vertices make the resulting B-spline
curve to be a straight line
5-47
• If at least k  1 coincident defining polygon vertices
occur, then the convex hull of these vertices is the
vertex itself, the resulting B-spline curve must pass
through the vertex.
5-48
• A B-spline curve is everywhere C k  2 continuous.
5-49
• The only requirement for a knot vector is that it
satisfy the relation ; xi  xi 1 , i.e., it is a
monotonically increasing series of real numbers.
• The number of knot values is n  k  1 .
• Fundamentally three types of knot vector are used:
uniform, open uniform (or open) and nonuniform.
- Uniform knot vector: Individual knot values are
evenly spaced, for example: [0 1 2 3 4]; [-0.2
-0.1 0 0.1 0.2]; [0 0.25 0.5 0.75 1.0]. For a
given order k, uniform knot vectors yield periodic
uniform basis functions for which
Ni , k (t )  Ni 1, k (t  1)  Ni 1, k (t  1)
5-50
- An open uniform knot vector has multiplicity of knot
values at the ends equal to the order k of the B-spline
basis function. Internal knot values are evenly spaced,
for example: k  2 [0 0 1 2 3 4 4], [0 0 1/4 1/2
3/4 1 1]; k  3 [0 0 0 1 2 3 3 3]. Formally, an
open uniform knot vector is given by
5-51
When the number of defining polygon vertices is
equal to the order of the B-spline basis and an open
uniform knot vector is used, the B-spline basis
reduces to the Berstein basis. Hence, the resulting Bspline curve is a Bezier curve. In that case, the knot
vector is just k zeros followed by k ones. For
example, for four polygon vertices the fourth order
( k  4 ) open uniform knot vector is [0 0 0 0 1 1
1 1], and a cubic Bezier/B-spline curve results.
5-52
- Nonuniform knot vectors may have either unequally
spaced and/or multiple internal knot values. They
may be periodic or open. Examples are [0 0 0 1 1
2 2 2]; [0 1 2 2 3 4]; [0 0.28 0.5 0.72 1].
5-53
5-54
• The Cox-deBoor formula used to calculate B-spline
basis functions is a recursion relation. A basis
function of a given order k depends on lower order
basis functions down to order 1. For a given basis
function N i , k this dependence forms a triangular
pattern given by
5-55
5-56
5-57
5-58
5-59
Note: For a uniform knot vector beginning at 0 with
integer spacings the usable parameter range is
k  1  t  (n  k )  (k  1)  n  1
For more general or normalized knot vectors,
the reduction in usable parameter range
corresponds to the loss of k  1 knot value
intervals at each end of the knot vector.
5-60
5-61
5-62
5-63
5-64
• Different types of control are used to influence the
shape of the B-spline Curves
- Change the type of knot vector and hence basis
function: periodic uniform, open uniform or
nonuniform.
- Change the order k of the basis function.
- Change the number and position of the of the
defining polygon vertices.
- Use multiple polygon vertices.
- Use multiple knot values in the knot vector.
5-65
5-66
5-67
5-68
5-69
5-70
5-71
5-72
• Use periodic B-spline curve to generate closed curves:
By repeating a total of k  2 polygon vertices at the
beginning and/or end of the defining closed polygon,
a closed periodic B-spline curve is obtained.
5-73
5-74
5-75
• An open nonuniform B-spline curve generated using a
knot vector with interior values proportion to the chord
distances between polygon vertices, the knot vector is
given by
ci  Bi 1  Bi
5-76
5-77
5-78
5-79
5-80
• B-spline curves expressed in a matrix form
P(t )  [ F ][G]  [T ] [ N ] [G]
[G]T  [ B1  Bn1 ]
[T ]  [t
k 1
t
k 2
 t 1]
- The element of [N] can be obtained using the
Cox-deBoor algorithm for each nonzero interval
in the knot vector [X]
• The derivatives of a B-spline curve
5-81
N (t )  0
'
i, 1
N i", 1 (t )  0
Ni", 2 (t )  0
5-82
5-83
5-84
5-85
• End conditions for periodic B-spline curves:
Techniques for controlling the position of the start
and end points and the conditions at those points fall
into two categories: multiple vertices and
pseudovertices.
5-86
• B-spline curve fit
For j data points lie on the B-spline yield
5-87
where 2  k  n  1  j . This system of equation can be
written in matrix form as
[ D]  [ N ][ B]
- If 2  k  n  1  j , then the matrix [N] is square and
the defining polygon is obtained directly by matrix
inversion:
1
[ B]  [ N ] [ D]
5-88
- A fairer or smoother curve is obtained by specifying
fewer defining polygon points than data points,
i.e., 2  k  n  1  j . Here, [N] is no longer square.
The defining polygon vertices for a B-spline curve
that fairs or smoothes the data are given by
[ D ]  [ N ][ B ]
[ N ]T [ D]  [ N ]T [ N ][ B]
1
[ B]  [[N ] [ N ]] [ N ] [ D]
T
T
5-89
5-90
5-91
5-92
5-93
Rational B-Spline Curves
• A rational B-spline curve is given by
where the Bi are the 3D defining polygon
vertices for the rational B-spline curve and
are the rational B-spline basis functions. Here,
hi  0 for all values of i .
5-94
• Rational B-spline basis functions and curves
are a generalization of nonrational B-spline
basis functions and curves, since it is clear
that when all hi  1 , Ri ,k (t )  N i ,k (t )
• The analytic and geometric characteristics of
a rational B-spline are:
- Each rational basis function is positive or zero
for all parameter values, i.e., Ri ,k  0
- The sum of the rational b-spline basis
functions for any parameter value t is one, i.e.,
n 1
R
i 1
i ,k
(t )  1
5-95
- Except for k  1 , each rational basis function has
precisely one maximum.
- A rational B-spline curve of order k (degree k  1 ) is
C k  2 continuous everywhere.
- The maximum order of the rational B-spline curve is
equal to the number of defining polygon vertices.
- A rational B-spline curve lies within the union of
convex hulls formed by k successive defining polygon
vertices.
- Any projective transformation is applied to a rational Bspline curve by applying it to the defining polygon
vertices; i.e., the curve is invariant with respect to a
projective transformation.
- An open rational B-spline curve with order equal to the
number of defining polygon vertices is a rational
Bezier curve.
5-96
5-97
5-98
5-99
5-100
5-101
5-102
5-103
5-104
5-105
5-106
5-107
5-108
• The derivatives of rational B-spline curves are
obtained by
5-109
5-110
5-111
5-112
Download