Lecture 7 Curves/Surfaces Types of Curves Graph of a function : y = f(x e.g: y = ax3 +bx 2 +cx+d - Not flexible enough, e.g. Circle Implicit : f(x,y =0 - e.g: ax+by+c = 0, x2 +y 2 -c 2 = 0 Parametric: x=f x(t, y=fy(t e.g: x = a x+bxt, y = ay+byt; - x = cos(t, y = sin(t Most common - at least in Graphics - Parametric Curves Plane Curves You can think of the free parameter t as time. Then the parametric equation of a curve gives you the position(x,y of your pen at time t x = f x(t, y= fy(t How do we choose functions f x(t and fy(t?
./-/0'-2%23-4'*./(0'(*% I@>2/:%-'J3-'0'(*C *6,3:9%5'%'/*@%,%3*'%8,-%0,9':(7$%6/%*$% 0/K(7%/(@%9'*-'9%*6/>' *6,3:9%5'%*0,,6%A(3,(C%8%?'%F,,0%(% *6,3:9%:,,K%:K'%/%*-/76%:('B$%,-%>'2'?*'%*0,,6 *6,3:9%5'%'/*@%,%9-/? 234 2 3564 &'-7/7'*%,8%9'%:,,-6(/'*%6'8('%9'%/(0'(; 6234 6 6>34 % 6 6=34 6 & # /(0'(%<% = $ $ " vector?,';%9'%@'(09%,8%9'%/(0'(%6,'*%(,%9/7'%/% 0',A'-:%A'/((0$%%6'2'(6*%,(%2/-/A''-B/,(C Tangent line : q = p(t + tp (t DE-7/E-' Local Properties of Curves include: Position Tangent Curvature Continuity These are all topics in differential geometry F(E,(;%(7'-*'%,8%9'%-/6E*%,8%9'%G'*%@,:/@% /22-,>A/,(%,8%9'%:E-7'%G=%/%:-:@'C >J =JJ >JJ =J H,-AE@/;%%%%%%%%%%%%%%%%%%%%%%9'%6'-7/7'*%/-'%I9% " 3>J + =J 4 -'*2':%,%C K 234 DE-7/E-'%/%%%*%#LK http://www.cs.mtu.edu/~shene/courses/cs362/notes/curves/normal.html
./-02/-' M,B'>(6%./-02/-'%3'*/-'*%4,5%*2-642%%7/-0'%*%2%%% 8,(29%:;%7/-02/-'%*%<'-,%'0'-=54'-'$%24'%7/-0'% *%%*2-642%>('9 =LL :;%?%@%2$%7/-02/-'%*%%%%%%%%%%%%%%%%%%%%A%%;,-%*3>>%=$%24*%*% F# + =L G K 88-,?32'>=%24'%*'7,(B%B'-020'9 C4'%*D/-'%,;%24'%7/-02/-'%7(%E'%F*,3'23'*G% 88-,?32'B%E=%%?HH "#=HH% 9 C4'%>'**%*%24'%7/-02/-'$%24'%I(7'-J%*%24'%7/-0'9 N'%%*4,/>B%E'%E>'%2,%*8'7;=%%*3>>%(/3E'-%,;% (2/20'%7,(2-,>*A 24'%7/-0'%*4,/>B%E'%/2,327>>=%7,38/2'B%;-,3% 7,(2-,>*9 O?38>'*%,;%(2/20'%7,(2-,>*P I.,(('72%24'%B,2*J%88-,74P%*8'7;=%*'0'->% 8,(2*%,(%24'%7/-0'$%B-5%%%(7'%>('%24-,/64% 24'*'%8,(2*A Q8'7;=%24'%B-'72,(%F2(6'(2G%,;%24'%7/-0'%(% *,3'%8>7'* R((2/20'%7,(2-,>*P%8,>=(,3>%7,';;7'(2*%'279 Continuity Describe how curves are joined together. Some examples: G0, C 0 - curves join G - curves join with equal tangent directions C - curves join with equal tangent directions and magnitudes (same first derivatives Cm - curves join with equal m th derivatives see pg 309 in book for a better picture for comparison http://www.cs.sfu.ca/~torsten/teaching/cmpt36/lecturenotes/html/08_2dcurves/.'/002'%*30('* 4,5%5/*%6%7,('%8'2,-'%9,:3;6'-*< 5'=>6*%?9/00'7%7;9@*A%5'-'%30/9'7%,(%/%*>''6%,2%3/3'-%/6%3,(6*%6>-,;=>%5>9>%6>'%9;-B'%*% *;33,*'7%6,%3/** C%20'D80'%*6''0%*6-3%*%30/9'7%8'65''(%6>': C%9;-B'%*%6-/9'7%,;6%,(%3/3'-E F7'/G%6-H%6,%7,%*,:'6>(=%*:0/-I 5>0'%:,7'0(=%3>H*9*%*%3,**80'$%6%*% *,:'5>/6%'D3'(*B'E%%J-H%6,%:6/6'%8'>/B,-% K;/06/6B'0HE Thomas W. Sederberg, Intro to Splines
Control Points Define points near which the curve should pass : p=(x,y, p2=(x2,y2,..., pn=(xn,yn For each point p i choose a parameter ti Simplest choice :,2,3,... uniform parameterization For each point specify a blending function B i(t how much this point contributes to the value of curve at t Curve: D?6A = D S?6A %%%%%%%%%%%%%%%%%%%%%%%%%%,-%%% H?6A = H S?6A 3?6A = 3 S?6A Curves: Blending Functions + Control Points %%% 3?6A = 3 S?6A Blending(Basis Functions Describe the Type of Curve Blending Functions Control point p i should have max influence near t = i. Influence should fall off as we move away. For local control, B i(t = 0 for i >> t and i << t I2%;//%4,(5-,/%@,(5*%;-'%5?'%*;8'$%5?'%-'*3/5(% 43-B'%*?,3/0%9'%-'034'0%5,%5?'%*;8'%@,(5F @. = = :5< @.:5< @$ *,.:5< =./'(0(%23(45,(* 6'73-'8'(5* G?,3/0%9'%';*J%5,%4,8@35'%:@,/J(,8;/*%;-'<C G?,3/0%9'%4,(5(3,3*$%;(0%022'-'(5;9/'%:K # <$% @-'2'-;9/J%5D4'%:K <F G3@@,-5%:5?'%(5'-B;/%D?'-'%5%*%(,5%E'-,<% *?,3/0%(,5%9'%5,,%9F L,3/0%9'%(4'%5,%(5'-@,/;5'%5?'%4,(5-,/% @,(5*F K;((,5%'5%5%;//M%%%.35%4;(%'5%4/,*'%2%-'/;A%,('%,2%5?'%-'73-'8'(5*F
Give up on small-support : natural splines Every control point influences the whole curve Spline passes through all points Minimizes bending energy Give up interpolation : kth degree uniform B-splines Curve doesn t pass through control points Most common - Cubic B-Splines Some interpolation : non-uniform B-Splines, Bezier Curves.'/'-%*0('* 2,(*3-453%6%54-7'%,43%,8%*'9:'(3*;%<,-%'65=% *'9:'(3%>'8('%?%0,(3*@%3A,%'(>0,(3*%6(>%3A,%,3='-%0,(3*%>'3'-:((9%3='%36(9'(3*%63% '(>0,(3*@ 4*'>%8,-%36(9'(3* Cubic Bezier Curve B8%A'%'(*4-'%3=63%C4'%0,(3*%,(%3A,%*>'*%,8%'65=% -'6>%0,(3%6-'%,(%,('%('$%3='%A=,'%54-7'%*%2 # $% 3=63%*$%=6*%6%36(9'(3%'7'-DA='-';% Bezier Curves De Casteljau Algorithm Linear Quadratic P(t = P0(-t + Pt P(t = A(t(-t + tb(t for t [0,] A(t = P0(-t + tp B(t = P(-t + tp2 P(t = P0(-t 2 + P2t(-t + P2t 2 www.ia.hiof.no/~borres/ gb/ma-bezier/p-bezier.html
De Casteljau Algorithm Cubic P(t = D(t(-t + te(t D(t = A(t(-t + tb(t E(t = B(t(-t + tc(t A(t = P0(-t + tp B(t = P(-t + tp2 C(t = P2(-t + tp3.'/'-%*0('* E='%>'6%C'=(>%.'/'-%*0('* *%3,%4*'%*0'56% C'(>(9%84(53,(*%8,-%3='%8,4-%0,(3*$%6**4:(9% 3=63%3%*%C'3A''(%"%6(>%#@ F#G3H I% 8,-%0 " $%%I3F#G3H % 8,-%0 # $%%I3 F#G3H%8,-%0 $%6(>%3 I 8,-% 0 I% ;% F#G3H I I3F#G3H I3 F#G3H %%% 3?6A = 3 S?6A 3 I Bernstein Polynomials P(t = P0(-t 3 + P(-t 2 3t + P2(-t3t 2 + P3 t 3 for t [0,] www.ia.hiof.no/~borres/ gb/ma-bezier/p-bezier.html Bernstein Polynomials Degree :(-t, t Degree 2: (-t 2, 2t(-t, t 2 Degree 3: (-t 3, (-t 2 3t, (-t3t 2, t 3 2 3 3 Degree 4: (-t 4, 4(-t 3 t, 6(-t 2 t 2, 4(-tt 3, t 4 4 6 4.......'/'-%*0('* Properties of Bernstein Polynomials 23'%4%56(78,(*%9.'-(*8'(%0,:(,;<*%,5%,-='-%>?$%@ " 98?$%@ # 98?$% @ 98?$%@ > 98?%<-'%9<;,*8?%='5('=%A:%83'%5,,B(C%0-,0'-8'*D 23'%*6;%%*%#%5,-%<%8 83'%'(=0,(8*%3<E'%(,%(56'(7'%,(%83'%0,*8,(%%,5%83'% '(=0,(8%,5%83'%76-E'%<(=%,(%83'%8<(C'(8*%<8%,00,*8'% '(=0,(8*F%%23*%;'<(*% 83<8%@ " 9#?%G%@ " 9#?G"%$%@ > 9"?%G%@ > 9"?G"% 2B,%(8'-,-%9A6'?%7,(8-,%0,(8*%<55'78%,(:%83'% 8<(C'(8%<(=%<8%83'%7,--'*0,(=(C%'(=0,(8$%(,8%<8%83'%,83'-%'(=0,(8$%<(=%=,%(,8%<55'78%83'%0,*8,(*%,5%83'% '(=0,(8*%,5%83'%76-E'% @ # 9"?%G@ # 9#?%G%@ # 9#?G"%$%@ 9#?%G@ 9"?%G%@ 9"?G"% H%0,:(,;<*%<-'%76A7%<(=%0,*8E' I:;;'8-:%BF-F8F%8G#JD%@ " 9#K8?%G%@ > 98?$%@ # 9#K8?%G%@ 98?%
.'/'-%76-E'* 23'%.'/'-%76-E'*%3<E'%83'%5,,B(C%0-,0'-8'*D '(=0,(8*%<-'%(8'-0,<8'= 8<(C'(8*%<8%'(=0,(8*%0,(8%8,B<-=*%83'% (8'-,-%7,(8-,%0,(8*L ='-E<8E'*%<-'%>90 # K0 "?%<(=%>90 > K0?% -'*0'78E':L 83'%76-E'%*%(%83'%7,(E'M%36%,5%7,(8-,% hull 0,(8*F of control points 23'%5,-;6<%5,-%83'%.'/'-%76-E'%*% (since sum of coef = Uniform B-splines 098?%G%9#K8? >% 0 " N%>89#K8? % 0 # N%>8 9#K8?%0 N%8 > 0 > 8%A'8B''(%"%<(=%#F Continuity of Bezier Curves Each piece is designed to be Ck where k = n-, with n= number of control points When combining two curves - will need extra contraints to achieve higher continuity. e.g. For set tangent at P 3 of curve P equal tangent of curve Q at Q0 Piecewise Polynomial (Cubic Basis Function $ "# % &' ( + + + * + ' ' &( * ' ' ( * ' * % = $ ' ' ( + * ' * ( + ' + ' ( * * ' # " % ' < Cubic B-Spline
@A./0('*./*0('* - Cubic C''D%,(0:%,('%?7**%25(;8,($%700%@ E8F%7-'%,?87('D?:%*<28*G%@ E8F%H%@E8AF> I<'%?7**%25(;8,(%*%/';'=*'%/,0:(,670G Cubic B-Spline Basis Function Curve: p0 p p2 p3 $ "# = % &' ( + + + * + ' ' &( * ' ' ( * ' * % $ ' ' ( + * ' * ( + ' + ' ( * * ' # " % ' < 0C8B = ( = 0.C8 B Linear combination 23'%;(;>%(5;D'-%,?%0,(8*%-'E5-'<%*%F@%83*% 4,--'*0,(<*%8,%83'%(8'-6>%?,-%8%,?%'(=83%#: p0 p p2 p3 23*%*%(4,(6'('(8%/ D58%7'%4>(%>7>A*%><<% 4,(8-,%0,(8*%DA%-'?'48,(: 0C8B = = Note on the range of t Range of t = [,n-] outside of the range ( n B i (t = i=0 0.C8 B n B(t i i=0./*0('* 233(4%5,(6-,%0,(6*%78%-'9'56,(: 0 (/# 0 # 0 ( 0 " 0 (;# 0 /# -'9'56'3%0,(6* 0 /# <%0 " /0 # = 0 (;# <%0 ( /0 (/# > problem w/ transformations : e.g. translation
Continuity of Uniform B-Splines Number of control points independent of degree of curve. It depends on the degree of the basis functions. If basis functions are of degree d, the final spline curve is C d-./*0('* 23%*4562*,( 78%84-(*%,48%8938%89'%*:,,89%;4-2'%;3(%5'%,583('6% 5<%%*4562*,(%,=%89'%,->(3%0,<('? @4562*,(%366*%('A%;,(8-,%0,(8*%5'8A''(%89'%,->(3%;,(8-,%0,(8*%3(6%40638'*%0,*8,(*%,=%,->(3%;,(8-,%0,(8*B &-?@(4%./*0('* @4562*,( A?-3@?-'%6805?8%5?(%3-?@%,(8%('%*'4B'(6*>% C''3%6,%?00-,DB?6'%./*0(' @6E%0'5'@*'% ('?-%5F-G'>%HB0'*6%?00-,?5E:% IE,,*'%*B?% 6>% I,B0F6'%0,(6*%0J"K$%0J 6K$%0J 6K>>>% &-?@%('%*'4B'(6*%5,(('56(4%6E'%0,(6*> C,6%G'-8%'995'(6%// E?G'%6,%'G?F?6'%?%5F75% 0,8(,B?%J,-%*'G'-?K%?6%'?5E%0,(6> I?(%3,%7'66'-%F*(4%?%B?45%?4,-6EB%% J*F73G*,(K> Evaluators @4562*,(%-4'*%=,-%40638(>%,6%0,(8*? ECF #CD #CD @4562*,(%-4'*%=,-%(*'-8(>%('A%0,(8*? #C #C
./02*,(%-/3'* 42'(%-/3'%5(%67'%('8%*'9/'(:'%,;%<,(6*%67'% <,(6*%867%'2'(%(/=0'-*%>-'%67'%,3%<,(6*%867% /<>6'%<,*6,(*?@ C C C ( < + D< + C+ # < = # E # < + # A%-/3'%5(%67'%('8%*'9/'(:'%67'%<,(6*%867%,% (/=0'-%*%>%('83B%(*'-6'%<,(6?@ C C ( F< F C+ # < + # = # E + < + #.(/0,(* 234%/,%5'%/,%53'(%4%0,(%*%6**(78 -'=;':'/%0,( 9(%3*%:4*'$%5'%400;<%-'=;':,(%>-':4;;%4//(7%6**(7 :,(-,;%0,(*?@%A3*%-'*B;*%(%3'%=,;;,5(7%-C4;%-B;'D E E E E E ( 0 + G0 + >0 0? 0 = E+ # " = # H # " " # 0" 34%*$%EB*%F''0%3'%,;/%C4;B'@./02*,( A;%:,/-*'$%(%>%;(6'%(/=0'-%,;%*6'<*%*/02*,(% G'('->6'*%,(3B%<,3B3('*@%H/6%67'B%G'6%>-06->-3B% :3,*'%6,%>%3=6%I % >(%67*%:/-2'%*%'J>:63B%>% :/0:%HK*<3('@ L3G,-67=M. Start.6>-6%867%>(%>-->B%,;%:,(6-,3%<,(6*%,;%3'(G67% with an array of n+ ctrl pts (N#@%I,=</6'%;-,=%67'%,-G(>3%<,(6*%('8%>-->B% 2. Compute,;%:,(6-,3%<,(6*%,;%3'(G67%(N#%/*(G% from original new array of 2n+ */02*,(%-/3'*%;,-%'2'(%>(%,%<,(6*@%O7'(% ctrl pts 3. Compute ;-,=%67'%('8%>-->B%:,=</6'%>(%>-->B%,;%3'(G67% from this, new array of 4n+ F(N#%'6:@$%56B<:>33B%FKP%*6'<*%*%'(,/G7?@%O7'(% ctrl pts... ->8%67'%3('%*'G='(6*%:,((':6(G%*'9/'(6>3% 4. Draw :,(6-,3%<,(6*@ lines between ctrl pts. Some Theory Splines <=> Subdivision
B-Spline Basis Functions Repeated convolutions of the box function Convolution : Box Function : { 0 " ( 7 f(sg(t sds # = "# " 7 7 ["$# ["$# B-Spline Properties PW-Polynomial : Bn(t is a piecewise polynomial of degree n (Box has degree 0, each convolution adds one Finite Support : Bn(t has support(is non-zero of length n+ (Box has support, each convolution adds one Continuity : Degree n B-splines have continuity n- (B(t is C 0 ( 7 0 (* 0 ( 7 * 'A*'%3,4B(,C64 = $ ( # 8* 0 ( " Refinability : Any B-Spline can be written as dilates and translates of itself -- Subdivision Rules B-Spline Basis Functions 0 # ( 7 = $ 0" (* 0" ( 7 * = ( 0 0 ( 7 " " 8*.'/(0234 55.'/(':'(3%';<03,(%/,-%67*92('* 30E'%0@A0(30F'%,/%,D%-'/(':'(3 ( 3 = 6 (3 + 6 (3 # 6 " " " # # # # G G # # H I H # from : siggraph 2000 subdivision course notes Bn(t = /(2 n "k [ TkBn(2t-k] = "k [ skbn(2t-k]
2345(' 6'7('8'(9./0(' 2-3'*%44 :;<845'* 5'6('%'789%:;*/0(' (%*2< '=7</0'>%0('7-%:;*/0(' "# "# N # (#$ $ # # 0( #$.$ /$.$ # 345(' =>-?'*%@ p i B(t i 3>8%,7%2*45('* A>-?'%<*%5('<-%A,8B(<9,( γ ( 9 = 4 ( 9 Åçåíêçä=éçáåíë Refinement of Control Points i = p i s k B(2t 2i k i k let j = 2i+k = p i s k B(2t j i k = p i s (j 2i B(2t j i j = ( p i s (j 2i B(2t j j i Refined Bases
I3'-%*0;('* A3'-'%64(<%<0'*%,=%*0;('*D J'K'-$ L'-6'$ M4B-4;$% N46B;;OP,6$ @@@ JO*0;('* 4-'%3'%6,*%B*'=B;$%QB%J'K'-%4(/%% L'-6' 4-'%B*'/%5/';<@%J'K'-%4-'%,='(%=,B(/% (%/-45(7%0-,7-46*%>'@7@%R,5'-0,(S?%4;3,B73% 3'<%4-'%%(,%C'-<%:,(C'('(@ Regular B-splines : C(t = "pibi(t p i = (xi,yi,zi in homogeneous coords: pi = (xi,yi,zi, w ipi = (xiwi, yiwi,ziwi,wi weights to control points, some attract curve more than others n i=0 C(t = w ip i B i (t n i=0 w ib i (t http://www.paulmach.com/nurbs/nurbs.pdf NURBS Non-uniform Rational B-Splines B-splines cannot represent conic sections e.g. Circle Circle in parametric form as a ratio of two polynomials: x(t = sin(t = 2s + s s = tan 2 ( t 2 2 y(t = cos(t = s2 + s 2 To draw a circle, set w = sin(#/2 for even control points http://www.cs.mtu.edu/~shene/courses/cs362/notes/spline/nurbs/nurbs-motiv.html degrees L=>R: 2,3,5,0 circle is degree 2 http://www.cs.mtu.edu/~shene/courses/cs362/notes/spline/nurbs/rb-circles.html
Space Curves Space Curves %%% 3?6A = 3 S?6A For plane curves control points : p i = (xi,yi in 3D, add an extra dimension : p i = (xi,yi,zi Basis Functions were scalar - stay the same D?6A = %%%%%%%%%%%%%%%%%%%%%%%%%%,-%%% z(t 3 =?6A = z3 i B S i (t?6a i H?6A = D S?6A H S?6A Types of Curves Same with more args Graph of a function : z = f(x,y Implicit : f(x,y,z =0 Parametric: x=f x(t, y=fy(t, z = fz(t Surfaces e.g. Helix: fx(t = acos(t fy(t = asin(t fz(t = bt
Surfaces Tensor Product Patches : Bezier, B-Spline S(u, v = n i=0 j=0 m p i,j B i (ub j (v http://www.cs.berkeley.edu/~sequin/cs284/imgs/biquinticbezierptch.gif http://www.cs.berkeley.edu/~sequin/cs284/imgs/bsplinepatch.gif OpenGL evaluators Support splines and surfaces based on the Bezier Basis only If working with B-splines will need to convert the basis functions (or of course just use subdivision Will need to determine granularity (high quality vs. high speed Triangular (box spline surfaces Surfaces Surfaces of Revolution IDEA Given: Curve : C(t = [x(t, y(t, z(t] Surface: S(u,v = [x(u,v, y(u,v,z(u,v]. Define function C [or S] 2. Enable it 3. use glevalcoord( [or glevalcoord2(] instead of glvertex*(. mathworld.wolfram.com/ SurfaceofRevolution.html
Curve Evaluators define control points as an array: cpts[n][k] if parameter defined in interval [a,b] in init(; glmapf(gl_map_vertex_3, a, b, k, order, &cpts[0][0]; glenable(gl_map_vertex_3; in display(, within glbegin(,..., glend(: glevalcoord(u Behind the scenes, * using Bernstein polynomials (the Bezier Basis * if [a,b] = [0,] : parameter = (u-a/(b-a Surface Evaluators Tensor Product Bezier Patches glmap2 (GL_MAP2_VERTEX3, u,u2,ustride, uorder, v,v2, vstride, vorder, points; glenable(gl_map2_vertex3; glevalcoord2(u,v; glmapgrid2d(nu, u, u2, nv, v,v2; glevalmesh2(mode, i, i2, j, j2; Curve Evaluators can use any value of the parameter using glevalcoord. For uniformly spaced evaluations: glmapgrid(n,a,b; glevalmesh(mode, p,p2; [GL_POINT, GL_LINE]