Splines IV – B-spline Curvesbased on:
Michael Gleicher: Curves, chapter 15 inFundamentals of Computer Graphics, 3rd ed.
(Shirley & Marschner)Slides by Marc van Kreveld
1
Interpolation vs. approximation
• Interpolation means passing through given points, approximation means getting “close” to given points
• Bézier curves and B-spline curves
p3
p2p1
p0 p3
p2p1
p0
p1 and p2 are interpolated
p1 and p2 are approximated
2
B-spline curves
• Approximates all control points• Polynomials of any degree d• C d-1 continuous everywhere
3
B-spline curves
• A linear combination ofthe control points
• The bi(t) are the basis functionsand show how to blend the points
• The basis functions are splines themselves B-splines
n
iii tbt
1
)()( pf
t
bi(t)the contribution of point pi to the curve depending on the parameter value t
4
B-splines and B-spline curves
t
bi(t)bi-1(t) bi+1(t)
pi-1 pi
pi+1
t’0.15
0.55
0.3
5
B-splines and B-spline curves
bi(t)bi-1(t) bi+1(t)
pi-1 pi
pi+1
t’
bi(t’)=0.55
bi-1(t’)=0.15
bi+1(t’)=0.3
0.15
0.55
0.3
t6
B-splines and B-spline curves
bi(t)bi-1(t) bi+1(t)
pi-1 pi
pi+1
t’0.15
0.55
0.3
t
the blended point determined by pi-1, pi , pi+1 and their basis functions
7
B-spline curves
8
• A B-spline curve of n points and parameter value k– is C k-2 continuous– is made of polynomials of degree k – 1– has local control: any location on the curve is determined
by only k control points– is bounded by the convex hull of the control points– has the variation diminishing property:
any line intersects the B-spline curve at most as often as that line intersects the control polygon
Types of B-splines
• Uniform linear B-splines• Uniform quadratic B-splines• Uniform cubic B-splines• Non-uniform B-splines• NURBS (non-uniform rational B-splines)
To define the B-splines is to define the B-spline curve
9
Uniform linear B-splines
• Basis functions are piecewise linear, for example:
b1,2(t)1
54321
0
22 it
it
tbi, )(
i t i+1
i +1 t i +2
otherwise
knots10
Uniform linear B-splines, knots
• A knot (for a uniform linear B-spline, or any type of B-spline) is a parameter value where the definition of the function of some B-spline changes
• Slight abuse: the corresponding point on the curve
b1,2(t)1
54321
knots11
Uniform linear B-splines, knots
b1,2(t)
b2,2(t)
1
54321
1
54321
b3,2(t)1
5432112
five knots in total
Uniform linear B-splines
• Basis functions are piecewise linear, for example:
• The B-spline curve can be used for parameter values t [2, n+1] (the t where the bi,2(t) sum up to 1), given points p1, p2, …, pn
• The B-spline curve is just the polygonal line through the control points; only two B-splines are non-zero for any t
0
22 it
it
tbi, )(
i t i +1
i +1 t i +2
otherwise
13
Uniform linear B-splines
• Each B-spline has 3 knots and they are uniformly spaced They are shifted copies of each other
• In total there are n+2 knots (at 1, 2, …, n+2)
b1,2(t)
b2,2(t)
1
543211
54321
b3,2(t)1
54321 14
Uniform quadratic B-splines
• Uniform quadratic B-splines bi,3(t) have knots at i, i+1, i+2, and i+3
• They are shifted copies of each other
t
b1,3(t)
54321
1
15
Uniform quadratic B-splines
t
b1,3(t)
54321
1
0
1 2
2
2
,3
21
21
21
)( u
uu
u
bi
if t [i, i+1] u = t – i
if t [i+1, i+2] u = t – (i+1)
if t [i+2, i+3] u = t – (i+2)
otherwise
0.5
u is set to be in [0,1] for the t-range
16
Quadratic B-spline curve
p1
p6
p2
p5
p4
p3
p7
control points defining this piece of curve between the knots
p2p3p4p1p2p3
p3p4p5
p4p5p6
p5p6p7
knot
17
Uniform quadratic B-splines
• At the 4 knots, the left and right derivatives are equal C1 continuous B-splines C1 continuous B-spline curve
t54321
1
0.5b2,3(t)
b’2,3(t) (derivative)– 1
– 0.5
18
Uniform quadratic B-splines
• At the 4 knots, the left and right derivatives are equal C1 continuous B-splines C1 continuous B-spline curve
• Starting at t = 3, the B-splines sum up to exactly 1
t54321
1
0.5b1,3(t)
b2,3(t) b3,3(t) b4,3(t) b5,3(t)
19
Uniform quadratic B-splines
• Suppose n control points• Then we have n B-splines and n+3 knots• The B-spline curve has n – 2 quadratic pieces,
starting at the 3rd knot and ending at the n+1st knot
20
Uniform quadratic B-splines
• What is the starting point and what is the ending point of the uniform quadratic B-spline curve using control points p1, p2, …, pn ?
21
Uniform cubic B-splines
• Uniform cubic B-splines bi,4(t) have knots at i, i+1, i+2, i+3 and i+4
• They are shifted copies of each other
t
b1,4(t)
54321
1
0.5
6
2/3
22
Uniform cubic B-splines
0
133
463
1333
23
23
23
3
,4
61
61
61
61
)(
)(
)(
)(
uuu
uu
uuu
u
tbi
if t [i, i+1] u = t – i
if t [i+1, i+2] u = t – (i+1)
if t [i+2, i+3] u = t – (i+2)
otherwise
if t [i+3, i+4] u = t – (i+3)
t
b1,4(t)
54321
1
0.5
6
2/3
23
Uniform cubic B-splines
• Every location on the B-spline curve is determined by four control points and their B-splines
• Starting at the 4th knot, t = 4, the B-spline curve can be used, because the B-splines sum up to 1
• A cubic B-spline is C2 continuous (the 1st and 2nd derivatives from the left and right are the same at the knots, and everywhere else too of course) a cubic B-spline curve is C2 continuous
24
Uniform cubic B-splines
• At what height are the second and fourth knots of a cubic B-spline?
• What weight of what control points determines the first point of a B-spline curve?
25
b1,4(t)
54321
1
0.5
6
2/3
7 8
b2,4(t) b3,4(t) b4,4(t)
t54321
10.5
6
2/3
Closed uniform B-spline curves
• Simply repeat the first k – 1 points as the last points– quadratic: p1, p2, …, pn p1, p2, …, pn, p1, p2
– cubic: p1, p2, p3, …, pn p1, p2, …, pn, p1, p2, p3
26
Non-uniform B-splines
• Uniform B-splines have knots at 1, 2, 3, …, but generally knots can have any parameter value non-uniform B-splines
• The knot vector t = [t1, … , tn+k] is a sequence of non-decreasing values specifying where the knots for the parameter t occur
27
Non-uniform B-splines
• We can repeat control points and combine the consecutive B-splines into one allows more local control
• We can repeat knots and adapt the B-splines affected allows more local control
• When we have a sequence of control points and a useful parameter range k, ..., n+1, we may want to insert an extra point (and knot) in the middle without changing the parameter range near the ends
28
Cox-de Boor recurrence
)()()( 11,1
1,1
, tbtttt
tbtt
tttb ki
iki
kiki
iki
iki
0
1)(1, tbi
if ti t < ti+1
otherwise
• Cox-de Boor recurrence for defining B-splines with parameter k and knot vector t = [t1, … , tn+k]:
29
The recurrence shows that parameter k B-splines are a weighted interpolation of parameter k – 1 B-splines, with weights linearly dependent on t
Repeating control pointsin B-spline curves
• Consider quadratic B-spline curves, in the figure:– Five B-splines of control points – 5+3 = 8 knots (t = 1, 2, ..., 8), useful in interval [3, 6]
t54321
1
0.5b1,3(t)
b2,3(t) b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p3 p4 p5
30
Repeating control pointsin B-spline curves
• Consider quadratic B-spline curves, in the figure:– Suppose p1 is repeated– 9 knots, useful interval [3, 7]
t54321
1
0.5b1,3(t)
b2,3(t) b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p3 p4 p5
9
b*1,3(t)p1
31
Repeating control pointsin B-spline curves
• Consider quadratic B-spline curves, in the figure:– Suppose p1 is repeated– 9 knots, useful interval [3, 7]– The B-spline curve starts at p1 at knot 3
t54321
1
0.5
b2,3(t) b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p3 p4 p5
9
b1,3(t) b*1,3(t)+
32
Repeating control pointsin B-spline curves
• Consider quadratic B-spline curves, in the figure:– Suppose p3 is repeated– 9 knots, useful interval [3, 7]
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2p3 p4 p5
9
b*3,3(t)p3
33
Repeating control pointsin B-spline curves
• Consider quadratic B-spline curves, in the figure:– Suppose p3 is repeated– 9 knots, useful interval [3, 7]– The B-spline curve passes through point p3
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p4 p5
9
b*3,3(t)
p3
+
34
Repeating control pointsin B-spline curves
• For a B-spline curve with parameter k (degree k – 1),
it will pass through the first and last control points if each occurs k – 1 times
• Similarly, we can make it pass through an intermediate control point by having k – 1 copies of that control point
• The level of geometric continuity, G, at an intermediate repeated control point decreases
35
Repeating control pointsin B-spline curves
• On the parameter interval [4,5], only p2 and p3 have a non-zero B-spline the curve is a line segment! Also on parameter interval [5,6]
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p4 p5
9
b*3,3(t)
p3
+
36
Repeating control pointsin B-spline curves
p1
p6
p2
p5p3
p7
quadratic B-spline curve
p1p2p3
p3p4p5
p5p6p7
knot 3
37
p2p3p4
p4p5p6
p4
Repeating control pointsin B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curvewith repeated control point
p2p3p4p1p2p3
p3p4
p4p5p6p5p6p7
knot 3
repeated control point p4
38
p4p5
Repeating control pointsin B-spline curves
• The quadratic B-spline curve remains C1 although it is only G0 at the repeated control point
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t) b4,3(t) b5,3(t)
76 8
p1
p2 p4 p5
9
b*3,3(t)
p3
+
39
Repeating control pointsin B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curvewith repeated control point
p2p3p4p1p2p3
p3p4
p4p5p6p5p6p7
knot 3
repeated control point p4
40
p4p5
Repeating knots in B-spline curves
• Repeating a knot means that one sequence of control points no longer occurs– For example, for quadratic B-spline curves, the part
between knots 4 and 5 (was based on points p2 p3 p4 )
– The curve part before (based on points p1 p2 p3 ) directly connects to the curve part after (based on points p3 p4 p5 )
– The B-splines get different shapes to accommodate the missing part (because the B-splines must still be continuous and sum up to 1)
41
Repeating knots in B-spline curves
• Repeating a knot means that one sequence of control points no longer occurs– For example, for quadratic B-spline curves, the part
between knots 4 and 5 (was based on points p2 p3 p4 )
t54321
1
0.5b1,3(t)
b2,3(t) b3,3(t) b4,3(t) b5,3(t)
76 842
Repeating knots in B-spline curves
• Repeating a knot means that one sequence of control points no longer occurs– For example, for quadratic B-spline curves, the part
between knots 4 and 5 (was based on points p2 p3 p4 )
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t) b4,3(t) b5,3(t)
76 8=43
Repeating knots in B-spline curves
• Repeating a knot means that one sequence of control points no longer occurs– For example, for quadratic B-spline curves, the part
between knots 4 and 5 (was based on points p2 p3 p4 )
t54321
1
0.5b1,3(t)
b2,3(t)b3,3(t)b4,3(t) b5,3(t)
76 844
Repeating knots in B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curve
p2p3p4p1p2p3
p3p4p5
p4p5p6p5p6p7
knot 3
repeat knot 5
45
Repeating knots in B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curvewith repeated knot
p2p3p4p1p2p3
p4p5p6p5p6p7
knot 3
knot 5 = 6
46
Repeating knots in B-spline curves
• Repeating a control point creates line segments on either side, but repeating a knot does not have this effect on quadratic B-spline curves
• Repeating a knot twice (three same knots in a sequence) creates a discontinuity in a quadratic B-spline curve– Two consecutive curve parts have no point in common– The curve part before the two disappearing parts (e.g.,
based on points p1 p2 p3 ) is disconnected from the curve part after those parts (based on points p4 p5 p6 )
47
Repeating knots in B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curve
p2p3p4p1p2p3
p3p4p5
p4p5p6p5p6p7
knot 3
repeat knot 5 twice
48
Repeating knots in B-spline curves
p1
p6
p2
p5
p4
p3
p7
quadratic B-spline curve
p2p3p4p1p2p3
p5p6p7
knot 3
knot 5 = 6 = 7
49
Repeating knots in B-spline curves
• In cubic B-spline curves– a double knot gives C1 / G1
continuity– a triple knot gives C0 / G0
continuity– a quadruple knot
disconnects the curve– a triple knot at the start lets
p1 be the start of the curve– a triple knot at the end lets
pn be the end of the curve
50
Repeating knots in B-spline curves
• Cubic B-splines for a B-spline curve passing through its endpoints, knot vector [1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8]
• The first three and last three B-splines are different from the standard cubic B-spline shape
51
Repeating knots in B-spline curves
• The expressions for B-splines can be determined for any parameter k and knot vector t = [t1, … , tn+k] using the Cox-de Boor recurrence (also when knots are repeated):
52
)()()( 11,1
1,1
, tbtttt
tbtt
tttb ki
iki
kiki
iki
iki
0
1)(1, tbi
if ti t < ti+1
otherwise
These recurrences also allow easy evaluation: get the point on a B-spline curve for a given t
Summary
• B-spline curves are defined by B-splines and provide great flexibility in curve design
• They exist of any order (degree) and continuity• Repeating control points or knots allows
interpolation instead of approximation• B-spline surfaces are a direct generalization• Even more general are NURBS:
Non-Uniform Rational B-Splines– defined using ratios of two polynomials– allow conic sections (circles, ellipses, hyperbolas)
53
Questions1. Let p1 p2 p3 be the three points of a uniform linear
B-spline curve, so there are five knots 1, 2, 3, 4 and 5. The useful parameter range is from knot 2 to knot 4. Draw the curve from knot 1 to knot 5, so also outside the useful parameter range, where p1 = (1,2), p2 = (3,1), and p3 = (2,1)
2. Approximately draw a quadratic B-spline curve for the points (1,2), (4,2), (4,0), (6,3), and (4,4) in its useful para-meter range. Make sure the curve is correct at its knots
3. Same but now for a cubic B-spline curve4. Draw a cubic B-spline and its derivative in one figure, as was
done for quadratic B-splines in the slides5. Suppose a quadratic B-spline curve is based on 8 points.
Point 4 is repeated and so is point 6. How many polygonal pieces does the B-spline curve have? 54