CS-184: Computer Graphics Lecture #13: Natural Splines, B-Splines, and NURBS Prof. James O’Brien University of California, Berkeley V2013-S-13-1.0 1 Natural Splines • Draw a “smooth” line through several points A real draftsman’s spline. Image from Carl de Boor’s webpage. 2 2 Sunday, March 10, 13
Natural Cubic Splines • Given points n + 1 • Generate a curve with segments n • Curves passes through points • Curve is continuous C 2 • Use cubics because lower order is better... 3 3 Natural Cubic Splines u = 2 s 2 u = n s 3 u = 3 sn s 1 u = 1 sn − 1 u = n − 1 u = 0 s 1 ( u ) if 0 ≤ u < 1 s 2 ( u − 1) if 1 ≤ u < 2 s 3 ( u − 2) if 2 ≤ u < 3 x ( u ) = . . . s n ( u − ( n − 1)) if n − 1 ≤ u ≤ n 4 4 Sunday, March 10, 13
Natural Cubic Splines u = 2 s 2 u = n s 3 u = 3 sn s 1 u = 1 sn − 1 u = n − 1 u = 0 ← n constraints s i (0)= p i � 1 i = 1 . . . n ← n constraints s i (1)= p i i = 1 . . . n ← n- 1 constraints s 0 i (1)= s 0 i +1 (0) i = 1 . . . n − 1 ← n- 1 constraints s 00 i (1)= s 00 i +1 (0) i = 1 . . . n − 1 ← 2 constraints s 00 1 (0)= s 00 n (1) = 0 Total 4 n constraints 5 5 Natural Cubic Splines • Interpolate data points • No convex hull property • Non-local support • Consider matrix structure... • using cubic polynomials C 2 6 6 Sunday, March 10, 13
B-Splines • Goal: cubic curves with local support C 2 • Give up interpolation • Get convex hull property • Build basis by designing “hump” functions 7 7 B-Splines b − 2 ( u ) if u − 2 ≤ u <u − 1 b − 1 ( u ) if u − 1 ≤ u <u 0 b ( u ) = b + 1 ( u ) if u 0 ≤ u <u +1 b + 2 ( u ) if u +1 ≤ u ≤ u +2 ← 3 constraints � 2 ( u � 2 ) = b 0 � 2 ( u � 2 ) = b � 2 ( u � 2 ) = 0 b 00 ← 3 constraints b 00 +2 ( u +2 ) = b 0 +2 ( u +2 ) = b +2 ( u +2 ) = 0 b � 2 ( u � 1 )= b � 1 ( u � 1 ) [ Repeat for and b 0 b 00 b � 1 ( u 0 ) = b +1 ( u 0 ) ← 3 × 3=9 constraints b +1 ( u +1 )= b +2 ( u +1 ) Total 15 constraints ...... need one more 8 Sunday, March 10, 13
B-Splines b − 2 ( u ) if u − 2 ≤ u <u − 1 b − 1 ( u ) if u − 1 ≤ u <u 0 b ( u ) = b + 1 ( u ) if u 0 ≤ u <u +1 b + 2 ( u ) if u +1 ≤ u ≤ u +2 ← 3 constraints � 2 ( u � 2 ) = b 0 � 2 ( u � 2 ) = b � 2 ( u � 2 ) = 0 b 00 ← 3 constraints b 00 +2 ( u +2 ) = b 0 +2 ( u +2 ) = b +2 ( u +2 ) = 0 b � 2 ( u � 1 )= b � 1 ( u � 1 ) [ Repeat for and b 0 b 00 b � 1 ( u 0 ) = b +1 ( u 0 ) ← 3 × 3=9 constraints b +1 ( u +1 )= b +2 ( u +1 ) b − 2 ( u − 2 ) + b − 1 ( u − 1 ) + b +1 ( u 0 ) + b +2 ( u +1 ) = 1 ← 1 constraint (convex hull) Total 16 constraints 9 9 B-Splines 10 10 Sunday, March 10, 13
B-Splines 11 11 B-Splines 12 12 Sunday, March 10, 13
B-Splines 13 13 B-Splines Example with end knots repeated 14 14 Sunday, March 10, 13
B-Splines • Build a curve w/ overlapping bumps • Continuity C 2 • Inside bumps C 2 • Bumps “fade out” with continuity • Boundaries • Circular • Repeat end points • Extra end points 15 15 B-Splines • Notation • The basis functions are the b i ( u ) • “Hump” functions are the concatenated function • Sometimes the humps are called basis... can be confusing • The are the knot locations u i • The weights on the hump/basis functions are control points 16 16 Sunday, March 10, 13
B-Splines • Similar construction method can give higher continuity with higher degree polynomials • Repeating knots drops continuity • Limit as knots approach each other • Still cubics, so conversion to other cubic basis is just a matrix multiplication 17 17 B-Splines • Geometric construction • Due to Cox and de Boor • My own notation, beware if you compare w/ text • Let hump centered on be N i, 4 ( u ) u i Cubic is order 4 N i,k ( u ) Is order hump, centered at k u i Note: is integer if is even i k else is integer ( i + 1 / 2) 18 18 Sunday, March 10, 13
B-Splines 19 19 20 20 Sunday, March 10, 13
NURBS • N on u niform R ational B - S plines • Basically B-Splines using homogeneous coordinates • Transform under perspective projection • A bit of extra control 21 21 NURBS p ix 2 3 p ix p iy p i = 5 N i ( u ) P p iy p iz 4 i p iz p iw x ( u ) = P i p iw N i ( u ) • Non-linear in the control points • The are sometimes called “weights” p iw 22 22 Sunday, March 10, 13
Recommend
More recommend