CS 43/585 Compute Gaphics I NURBS Dawing Week 5, Lectue 1 David Been, William Regli and Maim Pesakhov Geometic and Intelligent Computing Laboato Depatment of Compute Science Deel Univesit http://gicl.cs.deel.edu Outline Conic Sections via NURBS Knot insetion algoithm The de Boo s algoithm fo B-Splines fo NURBS Oslo Algoithm Bacentic Coodinates Tenso Poducts Intoduction and discussion of homewok #3 1 Conic Sections via NURBS Conic Sections via NURBS Obtained via pojection of the 3D paabola onto a plane Note: 3D Case: ational cuve is a 4D object D Case: ational cuve is a 3D object assign w to each contol point 3 Define the cuve with thee contol points Weights of fist/last contol points ae 1 Fo cente contol point w<1 gives an ellipse w>1 gives a hpebola w=1 gives a paabola Knot vecto is.,.,., 1., 1., 1. 4 Conic Sections via NURBS: A Cicula Ac The legs of the contol polgon ae of equal length The chod connecting the fist and last contol points meets each leg at an angle θ equal to half the angula etent of the desied ac (fo instance, 3 fo a 6 ac) The weight of the inne contol point is equal to the cosine of θ Knot vecto is.,.,., 1., 1., 1. 5 Conic Sections via NURBS: A Cicle What if we need an ac of >18? Idea: Use multiple 9 o 1 acs B = B 6 =.866 stitch them togethe with knots Eample: 3 acs of 1,.5,1 B = 1.73, 1,.5 B =, 1,1 B = 1.73, 1,.5 1 B 5 =,,.5 B = 4.866,.5,1 3 6
Conic Sections via NURBS Eample: 4 acs of 9 B 1 = 1,1, B 3 = 1,1, Knot Insetion Issue: Moe contol points mean moe contol How do we add moe points and keep same cuve? B 5 = 1, 1, B 7 = 1, 1, 7 8 Knot Insetion Basic Appoach Decide whee we d like to tweak the cuve Add a new knot Find affected d-1 contol points Replace it with d new contol points Eample: New knot at u=.6 9 Knot Insetion Given: n+1 contol points (P, P 1,..., P n ), a knot vecto of m+1 knots U = u, u1,..., u m and a degee d B- spline cuve C(u). Inset a new knot t into the knot vecto without changing the shape of the cuve. If t lies in knot span [u k, u k+1 ), onl the basis functions fo (P k, P k-d ) ae non-zeo. Find d new contol points Q k on edge P k-1 P k, Q k-1 on edge P k- P k-1,..., and Q k-d+1 on edge P k-d P k-d+1 All othe contol points ae unchanged. Note that d-1 contol points of the oiginal contol polline ae emoved and eplaced with d new contol points. See http://www.cs.mtu.edu/~shene/courses/cs361/notes/spline/b-spline/single-insetion.html 1 Knot Insetion Algoithm Ceate new contol point Q j = (1 α j )P j-1 + α j P j Whee α is defined as t u α j = j u j + d u j Popeties of Knot Insetion Inceasing the multiplicit of a knot deceases the numbe of non-zeo basis functions at this knot At a knot of multiplicit d, thee will be onl one non-zeo basis function Coesponding point on the cuve p(u) is affected b eactl one contol point p i In fact p(u) is p i See http://www.cs.mtu.edu/~shene/courses/cs361/notes/spline/b-spline/single-insetion.html 11 1
The de Boo Algoithm Genealization of de Casteljau's algoithm It povides a fast and numeicall stable wa fo finding a point on a B-spline cuve Obsevation: if a knot u is inseted d times to a B-spline, then p(u) is the point on the cuve. Idea: We just simpl inset u d times and the last point is p(u)! See http://www.cs.mtu.edu/~shene/courses/cs361/notes/spline/b-spline/de-boo.html 13 De Boo s Algoithm fo u := to 1 do If u lies in [u k,u k+1 ) and u!= u k, let h = d If u = u k and u k is a knot of multiplicit s, let h = d s Cop the affected contol points p k-s, p k-s-1,..., p k-d+1, p k-d to a new aa and ename them as p k-s,, p k-s-1,,..., p k-d+1, ; fo := 1 to h do fo i := k-d+ to k-s do Let a i, = (u - u i ) / ( u i+d-+1 - u i ) Let p i, = (1 - a i, ) p i-1,-1 + a i, p i,-1 p k-s,d-s is the point p(u). 14 De Boo s Algoithm (con fo u := to 1 do fo := 1 to h do fo i := k-p+ to k-s do Let a i, = (u - u i ) / ( u i+p-+1 - u i ) Let p i, = (1 - a i, ) p i-1,-1 + a i, p i,-1 p k-s,p-s is the point p(u). Eample of de Boo s Algoithm Degee 3 B-spline cuve (i.e., d = 3) Defined b seven contol points p,..., p 6 And knot vecto: u =.4 a 4,1 = (u - u 4 ) / ( u 4+3 - u 4 ) =. a 3,1 = (u - u 3 ) / ( u 3+3 - u 3 ) = 8/15 =.53 a,1 = (u - u ) / ( u +3 - u ) =.8 p 4,1 = (1 - a 4,1 )p 3, + a 4,1 p 4, =.8p 3, +.p 4, p 3,1 = (1 - a 3,1 )p, + a 3,1 p 3, =.47p, +.53p 3, p,1 = (1 - a,1 )p 1, + a,1 p, =.p 1, +.8p, u = u 1 = u = u 3 u 4 u 5 u 6 u 7 = u 8 = u 9 = u 1.5.5.75 1 a 4, = (u - u 4 ) / (u 4+3-1 - u 4 ) =.3 a 3, = (u - u 3 ) / (u 3+3-1 - u 3 ) =.8 p 4, = (1 - a 4, ) p 3,1 + a 4, p 4,1 =.7p 3,1 +.3p 4,1 p 3, = (1 - a 3, ) p,1 + a 3, p 3,1 =.p,1 +.8p 3,1 a 4,3 = (u - u 4 )/ (u 4+3- - u 4 ) =.6 p 4,3 = (1 - a 4,3 )p 3, + a 4,3 p 4, =.4p 3, +.6p 4, 15 16 Simila but Diffeent De Casteljau's: Dividing points ae computed with a pai of numbes (1 - u) and u that neve change Can be used fo cuve subdivision Uses all contol points De Boo's These pais of numbes ae diffeent and depend on the column numbe and contol point numbe Intemediate contol points ae not sufficient d+1 affected contol points ae involved in the computation 17 De Boo's Algoithm fo NURBS Cuves Multipl eve contol point b its weight (convet the 3D NURBS to a 4D B-Spline) X ( = ( W (, Y ( = ( W (, Z ( = z( W (, W ( = w( Pefom de Boo's algoithm on 4D B-Spline. Divide the fist thee components b the fouth and keeping the fouth component as weight. (poject the esulting cuve back to 3D) X ( Y ( Z ( ( =, ( =, z( =, w( = W ( W ( W ( W ( 18
De Boo s: Cuves Oslo Algoithm A subdivision algoithm fo B-splines, the basic idea: Take the cuve with m+1 contol points P to P m Inset a knot in an point (.5 mabe?) As a esult ou will have new points P k and P k Take cuves with m+1 contol points P P k, P k P m-1 and P 1 P k, P k P m Appl Pocedue ecusivel on each pat 19 Animated b Ma Pesakhov @ Deel Univesit Oslo Algoithm Bacentic Coodinates B Ceva's Theoem: Fo an point K inside the tiangle ABC Conside the eistence of masses w A, w B, and w C, placed at the vetices of the tiangle Thei cente of gavit (bacente) will coincide with the point K. A, w A August Fedinand Moebius (179-1868) defined (187) w A, w B, and w C as the K B, w bacentic coodinates of K B C, w C 1 Recoded fom: http://heim.ifi.uio.no/~tondbe/osloalgapp.html http://www.cut-the-knot.og/tiangle/bacente.shtml Popeties of Bacentic Coodinates Not unique Can be genealized to negative masses Can be made unique b setting w A + w B + w C = 1 w A = fo points on BC w B = fo points on AC w C = on AB Locating the Point in Bacentic Coodinates Compute D as a cente of mass of B and C BD*w B = DC*w C Compute K as a cente of mass of A and D AK*w A = KD*w D A, w A K B, w B D, wd = wb +wc C, w C 3 http://www.cut-the-knot.og/tiangle/bacente.shtml 4 http://www.cut-the-knot.og/tiangle/bacente.shtml
Tensos A Tenso is a genealization of vecto Tensos have a numbe of components depending on: R a n k 1 Numbe of dimensions in space D 3 D Scala U Scala U Vecto [U,U ] Vecto [U,U,U z ] U U U U Tenso Tenso U U U U U z U z U z U z U zz 5 Metic Tensos (MT) Fo a geneal coodinate sstem MT defined: g jk = u j u k So MT is of the ank and smmetic g jk = g kj Useful to compute: Distances between points in space Tansfom one space to anothe space Compute components of diffeential vecto opeatos like: Gadient Divegence Cul 6 Eamples of Metic Tensos Pogamming assignment 3 Pola coodinates Clindical coodinates u = u cosθ + u sinθ u = u cosθ + u sinθ sinθ u cosθ uθ = u sinθ + ucosθ θ + 1 1 g = g = 1 u z Spheical coodinates u = u cosθ + u sinθ + u cosφ sinθ u cosθ θ + 1 g = cosθ cosφ + u sinθ cosφ u φ sin φ z z Output B/W XPM, input PostScipt like file. Implement viewpots. Use Weile-Atheton intesection fo polgon clipping. Implement scanline polgon filling. (You can not use flood filling algoithms) 7 8 Onto Bézie Sufaces B-spline Sufaces NURBS Sufaces Faceting, Subdivision, Tessellation 3D Objects 9