37 B splines+NURBS
37 B splines+NURBS
37 B splines+NURBS
• 2nd derivative of start point p 2 = f ''(0) = 2 *11 a 2 + 6 * 0 2 a 3 For segment i: fi (0) = p i−1 , i = 1,…,n
• position of end point p 3 = f (1) = a 0 + 1 a1 +1
12 a 2 + 13 a 3 fi (1) = p i , i = 1,…,n
• constraint and basis matrices:
⎡ 1 0 0 0 ⎤ ⎡ 1 0 0 0 ⎤ fi' (0) = fi−1
'
(1), i = 1,…,n − 1
⎢ ⎥ ⎢ 0 1 0 0 ⎥
C=⎢
0 1 0 0 ⎥, B = C −1 = ⎢ ⎥ f (0) = f (1),
i
" "
i−1 i = 1,…,n − 1
⎢ ⎥
1
⎢ 0 0 2 0 ⎥ 0 0 2 0
⎢⎣ 1 1 1 1 ⎥⎦ ⎢ −1 −1 − 12 1 ⎥
⎣ ⎦
• subsequent segments assume the position and 1st and 2nd
Set: f1" (0) = fn" (1) = 0
derivatives of the end point of the preceding segment
O’Brien
Natural Cubic Splines B-splines
Each curve segment (other than the first) receives Given n (≥ d + 1) control points,
three out of its four control points from the a B-spline curve has n−d segments
preceding segment, this gives the curve C 2 continuity • d is the degree of each B-spline segment
Durand
For cubic, the basis functions could be, for example: The bi(u)’s are the basis functions of the other basis
• 1, 1+u, 1+u+u2, 1+u–u2+u3 (we’ve known them as the blending functions)
• u3, u3–u2, u3+u, u3+1
Durand
B-splines Uniform B-splines
Given n control points, there are n−d segments
The knots of a uniform B-splines are spaced at
• we call the segments fi(u), d ≤ i < n
• each segment has a unit range, 0 ≤ u ≤1
equal intervals
• we call the entire B-spline curve with n control points f(t) y(t) P9
P8
a cubic
The parameters ti’s where two segments join are P1 P3 B-spline
f5(u)
Q5 P4 t10 fQ
9(u)
9
called knots P t9
P7
y(t) 9 P8
a cubic t5 t6
• the start and end points (td and tn)
f8(u)
Q
B-spline t3 8
P1 P3 t fQ9(u) f6(u)
Q t8
are also called knots
(u) P4 10
f5Q 9
5
P7 Q
f4(u)4
6
t5 t6
t9 t4 P6
f3(u)
Q t7
• the range [td, tn] is the domain
Q
f8(u)
t3
f66(u)
Q
t8 8 3 Q
f7(u)
7
Q4
of a B-spline curve f3Q
(u)
3
t4 f4(u)
t7 Q
f77(u)
P6
P5
Knot
• the parameter u of segment i is P5
Knot
P0 P2 Control point
scaled to ti ≤ u < ti+1 P0 P2 Control point
x(t) x(t)
Foley, van Dam90
For segment i, we write the interpolating linear The hardest part of working with B-splines is
t − ti keeping track of the tedious notations!
curve as fi (u) = (1−u)pi–1+ upi, where u = ∈[ 0,1]
ti+1 − ti
[Craig] [Craig]
(1 u) pi−1 (1 u) pi where bi(t)’s are the basis functions (in this case, linear)
[Craig] [Craig]
Quadratic B-splines de Boor Algorithm
Quadratic B-splines (d=2, k=3) are drawn by two De Boor algorithm is an iterative interpolation
interpolation steps, similar but different to quadratic algorithm that generalizes de Casteljau’s algorithm
Bézier p i–1 To evaluate a B-spline curve f(t) at parameter value t:
qi
1/5 4/5
1. determine the [ti, ti+1) in which t belongs;
4/5 qi–1 f(t) d ≤ i < n, the domain of the curve is [td, tn]
1/5
4/5 1/5 2. to compute f(t) of degree d, first interpolate between
B-splines quadratic: control points p’s
Bézier quadratic: parameter “around” pi
control point 3. then, in a bottom up fashion, continue to perform r rounds
parameter “along” edge
of pairwise linear interpolations, until r = d, using:
pi–2
t − t r−1 t − tj
Whereas de Casteljau algorithm performs the iterative r
f j,d (t) = j+k−r f j−1 (t) + f jr−1 (t), t j ≤ t < t j+k−r ,
t j+k−r − t j t j+k−r − t j
interpolations for Bézier curves, de Boor algorithm 1 ≤ r ≤ d,
does so for B-splines j = i − d + r, i − d + r + 1, …,i
[TP3,Buss] [TP3,Buss]
pi–1 pi–1
qi qi
Using the de Boor algorithm we first compute qi–1 Then we linearly interpolate between qi–1 and qi in
and qi (note: over two knot intervals): a second round (r = 2) of interpolation:
ti+1 − t t − ti−1 ti+1 − t t − ti
qi−1 = fi−1,2
1
(t) = p i−2 + p i−1 , ti−1 ≤ t < ti+1 2
fi,2 (t) = qi−1 + qi , ti ≤ t < ti+1
ti+1 − ti−1 ti+1 − ti−1 ti+1 − ti ti+1 − ti
t −t t − ti t − t ti+1 − t
qi = fi,2
1
(t) = i+2 p i−1 + p i , ti ≤ t < ti+2 f (t) = i+1 p i−2
ti+2 − ti ti+2 − ti ti+1 − ti ti+1 − ti−1
⎛ t − t t − ti−1 t − ti ti+2 − t ⎞
+ ⎜ i+1 + p i−1
⎝ ti+1 − ti ti+1 − ti−1 ti+1 − ti ti+2 − ti ⎟⎠
t − ti t − ti
+ pi
ti+1 − ti ti+2 − ti
[TP3,Buss] [TP3,Buss]
fi+1(t)
Quadratic B-splines fi(t)
fi+2(t) Interpolation and Basis Functions
∑ b (t)p , t ∈[3,n]
y(t)
is non-zero f(t) = i i
P’’4 P’’4Curve
P’4
i=0 P’4 Curve
⎪⎧ 1, ti ≤ t < ti+1
P1 P4 Curve
bi,1 (t) = ⎨ the basis functions of the segments:
⎩⎪ 0, otherwise
⎧ t3 P3
P7
P8
⎪ 6 fQ
4(u)
4
f6Q(u)
6
f8Q(u)
8
t − ti t −t
bi,3 (t) = bi,2 (t) + i+3 bi+1,2 (t) ⎪ −3t 3 + 12t 2 − 12t + 4 P2
P5 Q
f7(u)
7 P6 Knot
2 2
⎪ , 1 ≤ t < 2, Control point
t − ti t −t 6 Watt 00 x(t)
bi,4 (t) =
3
bi,3 (t) + i+4
3
bi+1,3 (t) ⎪⎪ domain of curve
b0,4 (t) = ⎨ ! • each segment is influenced by four
3t 3 − 24t 2 + 60t − 44 b(t)
f(t)
⎪ , 2 ≤ t < 3, 6
—
(non-zero) basis functions
6 6
b4 (t) • each control point is scaled by a
⎪
5
—
bi (t) 6
B
bi−Bs2 BBs bi−1
single basis function
⎪ −t 3 + 12t 2 − 48t + 64
4
— —2 —1
6
, 3 ≤ t < 4, 3
— • each basis function is non-zero
⎪
6
6 2
—
6 over four successive intervals in t
⎪ 1
— B
bi−Bs3 BBsb t=i t=i+1 t=i+2 t=i+3 t=i+4
each control point influences four
everywhere!else
6 0i
⎪⎩ 0, —3
tt
ti ti+1 ti+2 ti+3 ti+4 ! 0 1
segments (only) local control
[Buss, Shirley, Gleicher] Foley, van Dam 90
0 1
ut • shifted pieces of a single basis function to u∈[0,1] range
Between knot values, the four basis 3
u3
At each knot value, one basis function
b (t ) ≥ 0, 3 ≤ i < n, 0 ≤ k ≤ 3
i−k bi,4 (u) = , u = t, !0 ≤ t < 1 b(u)
f(t)
6 6
—
“switches off” and another “switches on”, and −3u 3 + 3u 2 + 3u + 1
6
5
—
three basis functions are non-zero and sum to unity bi−1,4 (u) = , u = t − 1, !1 ≤ t < 2 6
4
—
B
bi−Bs2
—2
BBs bi−1
—1
6 6
3
—
b0 (t) b1 (t) b2 (t) b3 (t) b4 (t) b5 (t) b6 (t) b7 (t) b8 (t) 3u 3 − 6u 2 + 4 6
(1− u)3 ut
bi−3,4 (u) = , u = t − 3, !3 ≤ t < 4 0 1
! 6
domain of curve [Shirley, Gleicher]
Uniform Cubic B-spline Segment Bézier is Not B-spline
Control points for one segment fi(u) are pi-3, pi-2, Relationship to the control points is different
pi-1, pi, 3 ≤ i < n, recall: the control points can take
on arbitrary values (geometric constraints)
A segment is described as: y(t) P9
P8
Bézier
3 P1 P3
P4 t10 fQ9(u)
∑b
f5Q(u) 9
fi (u) = (u)p i−3+ j , u ∈[0,1]
5
P7
i−3+ j t9
j=0 t5 t6 Q
f88(u)
t3 t8
f66(u)
Q
fQ4(u)
(1− u)3 3u 3 − 6u 2 + 4 t4
4
P6
= p i−3 + p i−2 + f3Q(u) t7 Q
3 f 7(u)
7
6 6 P5
Knot
−3u 3 + 3u 2 + 3u + 1 u3 P0 P2 Control point
p i−1 + p i Foley, van Dam 90
x(t)
6 6
The cubic B-spline segment ⎡ −1 3 −3 1 ⎤ B-spline
basis matrix is: 1 ⎢ 3 −6 3 0 ⎥
B= ⎢ ⎥
6 ⎢ −3 0 3 0 ⎥
⎣⎢ 1 4 1 0 ⎥⎦ Durand
Interpolation with
Interpolation
Multiple Control Points
A B-spline curve doesn’t have to interpolate any A B-spline curve can be made to interpolate one or
of its control points more of its control points by adding multiple control
points of the same value, at the loss of continuity
Examples:
C2G2
C2G1 C2G0
P1 P3 t
(u) P4 10
f5Q fQ9(u)
9
5
P7
curve becomes a t5 t6 t9
Q
f8(u)
Q3 Q4 Q4 straight line on t3
f66(u)
Q
t8 8
Q4
either side of the t4 f4(u) P6
f3Q
(u) t7 Q
control points 3 f77(u)
P5
Q3 Q3 Q4 Knot
P0 P2 Control point
P1 P3 P1 = P2 P4 P1 = P2 = P3 x(t)
Foley, van Dam 90 Foley, van Dam 90
(a) (b) (c)
• projected to z = 1: ∑ w b (u) i i
Polynomial curves are affine invariant, i=0
f p (u)
[Farin] [Farin,Watt]
Non-Uniform Rational B-Splines Advantages of NURBS
3
Most general, can represent:
• B-splines
∑w b i i,k (u)p i
• Bézier and rational Bézier
cubic NURB control points
cubic Bézier control points
f (u) = i=0
3 • conic sections
∑w b i i,k (u)
i=0
Properties:
with: • local control
wi = scalar weight for each control point • convex hull (if wi ≥ 0)
p i = control points • variation diminishing (if wi ≥ 0)
wi p i = (wi xi ,wi yi ,wi zi ,wi ) • invariant under both affine and projective transformations
bi,k (u) = the B-splines basis functions
k = B-splines order Standard tool for representing
freeform curves in CAGD applications
[Farin]
Chenney