CS 430/536 Compuer Graphics I B-Splines an NURBS Wee 5, Lecure 9 Davi Breen, William Regli an Maxim Peysahov Geomeric an Inelligen Compuing Laboraory Deparmen of Compuer Science Drexel Universiy hp://gicl.cs.rexel.eu
Types of Curves Splines B-splines NURBS Ouline Kno sequences Effecs of he weighs 2
Splines Popularize in lae 960s in US Auo inusry (GM) R. Riesenfel (972) W. Goron Origin: he hin woo or meal srips use in builing/ship consrucion Goal: efine a curve as a se of piecewise simple polynomial funcions connece ogeher 3
Naural Splines Mahemaical represenaion of physical splines C 2 coninuous Inerpolae all conrol poins Have Global conrol (no local conrol) P 0 P P n-2 P n P n- P 2 4
B-splines: Basic Ieas Similar o Bézier curves Smooh blening funcion imes conrol poins Bu: Blening funcions are non-zero over only a small par of he parameer range (giving us local suppor) When nonzero, hey are he concaenaion of smooh polynomials. (They are piecewise!) 5
B-spline: Benefis User efines egree Inepenen of he number of conrol poins Prouces a single piecewise curve of a paricular egree No nee o sich ogeher separae curves a juncion poins Coninuiy comes for free 6
Define similarly o Bézier curves p i are he conrol poins Compue wih basis funcions (Basis-splines) B-spline basis funcions are blening funcions Each poin on he curve is efine by he blening of he conrol poins (B i is he i-h B-spline blening funcion) p( ) B-splines = i= 0 B i is zero for mos values of! m B ( ) i, p i 7
8 ) ( ) ( ) ( oherwise 0, if, ) (,,,,0 B B B B = < = B-splines: Cox-eBoor Recursion Cox-eBoor Algorihm: efines he blening funcions for spline curves (no limie o eg 3) curves are weighe avgs of lower egree curves Le enoe he i-h blening funcion for a B-spline of egree, hen: ) (, B i
B-spline Blening Funcions B, ) 0 ( B, () B, 2 ( B, 3 ( is a sep funcion ha is in he inerval spans wo inervals an is a piecewise linear funcion ha goes from 0 o (an bac) ) spans hree inervals an is a piecewise quaraic ha grows from 0 o /4, hen up o 3/4 in he mile of he secon inerval, bac o /4, an bac o 0 ) is a cubic ha spans four inervals growing from 0 o /6 o 2/3, hen bac o /6 an o 0 B-spline blening funcions 9 Pics/Mah couresy of Dave Moun @ UMD-CP
B-spline Blening Funcions: Example for 2 n Degree Splines Noe: can efine a polynomial wih hese properies (boh 0 an non-zero for ranges) Iea: subivie he parameer space ino inervals an buil a piecewise polynomial Each inerval ges ifferen polynomial funcion 0 Pics/Mah couresy of Dave Moun @ UMD-CP
B-spline Blening Funcions: Example for 3 r Degree Splines p( ) = m i= 0 B i, ( ) p i Observe: a =0 an = jus four of he funcions are non-zero all are >=0 an sum o, hence he convex hull propery hols for each curve segmen of a B-spline 994 Foley/VanDam/Finer/Huges/Phillips ICG
B-splines: Kno Selecion Insea of woring wih he parameer space 0, use min 0 2... m The no poins join poins beween curve segmens, Q i Each has a no value m- nos for m poins 2 max 994 Foley/VanDam/Finer/Huges/Phillips ICG
Specifie by m 3 Uniform B-splines: Seing he Opions m conrol poins, P 0 P m m-2 cubic polynomial curve segmens, Q 3 Q m m- no poins, 3 m segmens Q i of he B-spline curve are efine over a no inerval [ i, i ] efine by 4 of he conrol poins, P i-3 P i segmens Q i of he B-spline curve are blene ogeher ino smooh ransiions via (he new & improve) blening funcions 4
Example: Creaing a B-spline m p( ) = B ( p m = 9 i= 0 i, ) i 0 conrol poins 8 no poins 7 segmens 5 994 Foley/VanDam/Finer/Huges/Phillips ICG
B-spline: Kno Sequences Even isribuion of nos uniform B-splines Curve oes no inerpolae en poins firs blening funcion no equal o a =0 Uneven isribuion of nos non-uniform B-splines Allows us o ie own he enpoins by repeaing no values (in Cox-eBoor, 0/0=0) If a no value is repeae, i increases he effec (weigh) of he blening funcion a ha poin If no is repeae imes, blening funcion converges o an he curve inerpolaes he conrol poin 6
7 B i, () ) ( ) ( ) ( oherwise 0, if, ) (,,,,0 B B B B = < = B-splines: Cox-eBoor Recursion Cox-eBoor Algorihm: efines he blening funcions for spline curves (no limie o eg 3) curves are weighe avgs of lower egree curves Le enoe he i-h blening funcion for a B-spline of egree, hen:
Creaing a Non-Uniform B-spline: Kno Selecion Given curve of egree =3, wih m conrol poins firs, creae m no values use no values (0,0,0,,2,, m-2, m-,m-,m-) (aing wo exra 0 s an m- s) Noe Causes Cox-eBoor o give ae weigh in blening o he firs an las poins when is near min an max 8 Pics/Mah couresy of G. Farin @ ASU
B-splines: Muliple Knos Kno Vecor {0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0} Several consecuive nos ge he same value Changes he basis funcions! 9 From hp://evworl.apple.com/ev/echsuppor/evelop/issue25/schneier.hml
20 B-spline Summary = = m i i i p B p 0, ) ( ) ( ) ( ) ( ) ( oherwise 0, if, ) (,,,,0 B B B B = < =
Waching Effecs of Kno Selecion 0 0 2 3 4 5 6 7 8 9 9 no poins (iniially) Noe: nos are isribue paramerically base on, hence why hey move 0 conrol poins Curves have as many segmens as hey have non-zero inervals in u egree of curve 2 Pics/Mah couresy of G. Farin @ ASU
B-splines: Local Conrol Propery Local Conrol polynomial coefficiens epen on a few poins moving conrol poin (P 4 ) affecs only local curve Why: Base on curve ef n, affece region exens a mos 2 no poins away 22 994 Foley/VanDam/Finer/Huges/Phillips ICG
B-splines: Local Conrol Propery 23 Recore from: hp://heim.ifi.uio.no/~ronbre/osloalgapp.hml
B-splines: Convex Hull Propery The effec of muliple conrol poins on a uniform B-spline curve 25 994 Foley/VanDam/Finer/Huges/Phillips ICG
B-splines: Coninuiy Derivaives are easy for cubics p( u) = = 0 Derivaive: p ( u) = c 2c u c u 3 u c 2 3 3 2 Easy o show C 0, C, C 2 26
B-splines: Seing he Opions How o space he no poins? Uniform equal spacing of nos along he curve Non-Uniform Which ype of parameric funcion? Raional x(), y(), z() efine as raio of cubic polynomials Non-Raional 27
NURBS A he core of several moern CAD sysems I-DEAS, Pro/E, Alpha_ Describes analyic an freeform shapes Accurae an efficien evaluaion algorihms Invarian uner affine an perspecive ransformaions 28 U of Uah, Alpha_
Benefis of Raional Spline Curves Invarian uner roaion, scale, ranslaion, perspecive ransformaions ransform jus he conrol poins, hen regenerae he curve (non-raionals only invarian uner roaion, scale an ranslaion) Can precisely efine he conic secions an oher analyic funcions conics require quaraic polynomials conics only approximae wih non-raionals 29
NURBS Non-uniform Raional B-splines: NURBS Basic iea: four imensional non-uniform B-splines, followe by normalizaion via homogeneous coorinaes If P i is [x, y, z, ], resuls are invarian wr perspecive projecion Also, recall in Cox-eBoor, no spacing is arbirary nos are close ogeher, influence of some conrol poins increases Duplicae nos can cause poins o inerpolae e.g. Knos = {0, 0, 0, 0,,,, } creae a Bézier curve 30
Raional Funcions Cubic curve segmens X ( ) Y ( ) x ( ) =, y( ) =, z( ) = W ( ) W ( ) where X ( ), Y ( ), Z( ), W ( ) are all cubic polynomials wih conrol poins specifie in homogenous coorinaes, [x,y,z,w] Noe: for 2D case, Z( ) = 0 Z( ) W ( ) 3
Raional Funcions: Example Example: raional funcion: a raio of polynomials a raional parameerizaion in u of a uni circle in xy-plane: a uni circle in 3D homogeneous coorinaes: 32
NURBS: Noaion Aler Depening on he source/reference Blening funcions are eiher ( ) or Parameer variable is eiher u or Curve is eiher C or P or Q Conrol Poins are eiher P i or B i Variables for orer, egree, number of conrol poins ec are frusraingly inconsisen, i, j, m, n, p, L,,. B i, u N i, ( u) 33
NURBS: Noaion Aler. If efine using homogenous coorinaes, he 4 h (3 r for 2D) imension of each P i is he weigh 2. If efine as weighe eucliian, a separae consan w i, is efine for each conrol poin 34
NURBS A -h egree NURBS curve C is ef as: Where C = = 0, ( ) i i i u n n w B w B i= 0 i i, ( u) P ( u) conrol poins, -h egree B-spline blening funcions, i B i, ( u) he weigh, w i, for conrol poin P i (when all w i =, we have a B-spline curve) 35
Observe: Weighs Inuce New Raional Basis Funcions, R Seing: R i ( u) = n i= 0 w B i i i, w B ( u) i, ( u) Allows us o wrie: Where R i, ( u) ( u) R ( u) = i= are raional basis funcions u [0,] piecewise raional basis funcions on C weighs are incorporae ino he basis fcns n 0 i, P i 36
Geomeric Inerpreaion of NURBS Wih Homogeneous coorinaes, a raional n- D curve is represene by polynomial curve in (n)-d Homogeneous 3D conrol poins are wrien as: in 4D where To ge, ivie by w i a perspecive ransform wih cener a he origin Noe: weighs can allow final curve shape o go ousie he convex hull (i.e. negaive w) 37
NURBS: Examples Unif. Kno Vecor Non-Unif. Kno Vecor {0.0,.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0} {0.0,.0, 2.0, 3.75, 4.0, 4.25, 6.0, 7.0} 38 From hp://evworl.apple.com/ev/echsuppor/evelop/issue25/schneier.hml
NURBS: Examples Kno Vecor {0.0, 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0} Several consecuive nos ge he same value Bunches up he curve an forces i o inerpolae 39 From hp://evworl.apple.com/ev/echsuppor/evelop/issue25/schneier.hml
NURBS: Examples Kno Vecor {0.0,.0, 2.0, 3.0, 3.0, 5.0, 6.0, 7.0} Several consecuive nos ge he same value Bunches up he curve an forces i o inerpolae Can be one micurve 40 From hp://evworl.apple.com/ev/echsuppor/evelop/issue25/schneier.hml
The Effecs of he Weighs w i of P i effecs only he range [u i, u i ) If w i =0 hen P i oes no conribue o C If w i increases, poin B an curve C are pulle owar P i an pushe away from P j If w i ecreases, poin B an curve C are pushe away from P i an pulle owar P j If w i approaches infiniy hen B approaches an B i -> P i, if u in [u i, u i ) 4
The Effecs of he Weighs Increase weigh pulls he curve owar B 3 42 From hp://evworl.apple.com/ev/echsuppor/evelop/issue25/schneier.hml
Programming assignmen 3 Inpu PosScrip-lie file conaining polygons Oupu B/W XPM Implemen viewpors Use Suherlan-Hogman inersecion for polygon clipping Implemen scanline polygon filling. (You canno use floo filling) 43