bài giảng đồ hoạ và hiện thực ảo - chương 7 đường cong trong không gian 3d curve

11 331 0
bài giảng đồ hoạ và hiện thực ảo -  chương 7 đường cong trong không gian 3d curve

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 1 (c) SE/FIT/HUT 2002 Đường cong trong không gian 3D CURVE (c) SE/FIT/HUT 2002 2 Đường cong - Curve  Why use curves? Quỹ đạo chuyển động của 1 điểm trong không gian  Đường cong biểu diễn Điểm -curve represents points:  Điểm Biểu diễnvà kiểm soát đường cong -Points represent- and control-the curve.  Cách tiếp cận này là cơ sở của lĩnh vực Computer Aided Geometric Design (CAGD). (c) SE/FIT/HUT 2002 3 Phân loại  Trên cơ sở ràng buộc giữa điểm và đường trong cảứng dụng khoa học và thiết kế ta co thể phân làm 2 loại:  Xấp xỉ-Approximation -  Được ứng dụng trong mô hình hoá hình học  Nội suy-Interpolation  Trong thiết kế nôi suy là cần thiết với các đối tượng nhưng không phù hợp với các đối tượng có hình dáng bất kỳ "free form“. (c) SE/FIT/HUT 2002 4 Biểu diễn Đường cong  Tường minh y=f(x)  y = f(x), z = g(x)  impossible to get multiple values for a single x • break curves like circles and ellipses into segments  not invariant with rotation • rotation might require further segment breaking  problem with curves with vertical tangents • infinite slope is difficult to represent  Không tường minh f(x,y)=0 - Implicit equations:  f(x,y,z) = 0  equation may have more solutions than we want • circle: x² + y² = 1, half circle: ?  problem to join curve segments together • difficult to determine if their tangent directions agree at their joint point (c) SE/FIT/HUT 2002 5 Đường cong tham biến  Biểu diễn các đường cong tham biến Parametric representation:  x = x(t), y = y(t), z = z(t)  overcomes problems with explicit and implicit forms  no geometric slopes (which may be infinite)  parametric tangent vectors instead (never infinite)  a curve is approximated by a piecewise polynomial curve  Define a parameter space  1D for curves  2D for surfaces  Define a mapping from parameter space to 3D points  A function that takes parameter values and gives back 3D points  The result is a parametric curve or surface 0 t 1 Mapping F :t → (x, y, z) (c) SE/FIT/HUT 2002 6 Parametric Curves  We have seen the parametric form for a line:  Note that x, y and z are each given by an equation that involves:  The parameter t  Some user specified control points, x 0 and x 1  This is an example of a parametric curve 10 10 10 )1( )1( )1( zttzz yttyy xttxx −+= −+= −+ = CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 2 (c) SE/FIT/HUT 2002 7 Đường cong đa thức bậc ba  Phải đảmbảolàđường cong không gian với 3 trụctoạđộx, y, z  tránh đượcnhững tính toán phứctạpvànhững phầnnhấp nhô ngoài ý muốnxuấthiện ở những đường đathứcbậc cao  Why cubic? (c) SE/FIT/HUT 2002 8 P0 P1 p2 p3 P0 P'0 P1 P'1 Đường cong bậc 3  x = a 1 + b 1 u + c 1 u 2 + d 1 u 3  y = a 2 + b 2 u + c 2 u 2 + d 2 u 3  z = a 3 + b 3 u + c 3 u 2 + d 3 u 3  Với 3 điểm P0, P1, P2, P3 phương trình xác định (c) SE/FIT/HUT 2002 9 Hermite Spline  A spline is a parametric curve defined by control points  The term spline dates from engineering drawing, where a spline was a piece of flexible wood used to draw smooth curves  The control points are adjusted by the user to control the shape of the curve  Phương pháp Hermite dựa trên cơ sở của cách biểu diễn Ferguson hay Coons năm 60  A Hermite spline is a curve for which the user provides:  The endpoints of the curve  The parametric derivatives of the curve at the endpoints • The parametric derivatives are dx/dt, dy/dt, dz/dt  That is enough to define a cubic Hermite spline, more derivatives are required for higher order curves (c) SE/FIT/HUT 2002 10 Đường cong Hermite  p = p(u) = k 0 + k 1 u + k 2 u 2 + k 3 u 3  p(u) = ∑kiui i∈n  p 0 và p 1 ta có hai độ dốc p 0 ’vàp 1 ’với u = 0 và u = 1 tại hai điểm đầu cuối của đoạn [0,1].  We have constraints:  The curve must pass through p 0 when u=0  The derivative must be p’ 0 when u=0  The curve must pass through p 1 when u=1  The derivative must be p’ 1 when u=1 (c) SE/FIT/HUT 2002 11 Basis Functions  A point on a Hermite curve is obtained by multiplying each control point by some function and summing  The functions are called basis functions (c) SE/FIT/HUT 2002 12  Thay vào:  p = p(u) = p 0 (1-3u 2 +2u 3 ) + p 1 (3u 2 -2u 3 ) + p 0 ’(u-2u 2 +u 3 ) + p 1 ’(-u 2 +u 3 ) p = p(u) = [ 1 u u 2 u 3 ] CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 3 (c) SE/FIT/HUT 2002 13 Đường cong Bezier  Sử dụng điểm và các vector kiểmsoátđược độ dốccủa đường cong tạinhưng điểmmànóđiqua.(Hermit)  không đượcthuậnlợi cho việcthiếtkế tương tác, không tiếpcận vào các độ dốccủa đường cong bằng các giá trị số (Hermite).  Paul Bezier, RENAULT, 1970 đường và bề mặt UNISURF (c) SE/FIT/HUT 2002 14  po, p 3 tương đương với p 0 , p 1 trên đường Hermite. diểm trung gian p 1 , p 2 được xác định bằng 1/3 theo độ dài của vector tiếp tuyến tại điểm po và p 3  p 0 ’= 3(p 1 –p 0 )  p 3 ’= 3(p 3 –p 2 )  p = p(u) = p 0 (1-3u2+2u3) + p 1 (3u2-2u3) + p 0 ’(u-2u 2 +u 3 ) + p 1 ’(- u 2 + u 3 )  p = p(u) = p 0 (1 - 3u + 3u 2 -u 3 ) + p 1 (3u-6u 2 -3u 3 ) + p 2 (3u 2 -3u 3 ) + p 3 u 3 (c) SE/FIT/HUT 2002 15 Biểu diễn Ma trận p = p(u) = [ 1 u u 2 u 3 ]                         −− − − 3 2 1 0 1331 0363 0033 0001 p p p p 0 0.2 0.4 0.6 0.8 1 1.2 B0 B1 B2 B3 (c) SE/FIT/HUT 2002 16 Ưu điểm  dễ dàng kiểm soát hi`nh dạng của đường cong hơn vector tiếp tuyến tại p 0 ’vàp 1 ’của Hermite.  Nằm trong đa giác kiểm soát với số điểm trung gian tuỳ ý( số bậc tuỳ ý)  đi qua điểm đầu và điểm cuối của đa giác kiểm soát, tiếp xúc với cặp hai vector của đầu cuối đó (c) SE/FIT/HUT 2002 17 Example Bezier Curves  [UW] (c) SE/FIT/HUT 2002 18 Sub-Dividing Bezier Curves P 0 P 1 P 2 P 3 M 01 M 12 M 23 M 012 M 123 M 0123 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 4 (c) SE/FIT/HUT 2002 19 Sub-Dividing Bezier Curves P 0 P 1 P 2 P 3 (c) SE/FIT/HUT 2002 20 Sub-Dividing Bezier Curves  Step 1: Find the midpoints of the lines joining the original control vertices. Call them M 01 , M 12 , M 23  Step 2: Find the midpoints of the lines joining M 01 , M 12 and M 12 , M 23 . Call them M 012 , M 123  Step 3: Find the midpoint of the line joining M 012 , M 123 . Call it M 0123  The curve with control points P 0 , M 01 , M 012 and M 0123 exactly follows the original curve from the point with t=0 to the point with t=0.5  The curve with control points M 0123 , M 123 , M 23 and P 3 exactly follows the original curve from the point with t=0.5 to the point with t=1 (c) SE/FIT/HUT 2002 21 de Casteljau’s Algorithm  You can find the point on a Bezier curve for any parameter value t with a similar algorithm  Say you want t=0.25, instead of taking midpoints take points 0.25 of the way P 0 P 1 P 2 P 3 M 01 M 12 M 23 t=0.25 (c) SE/FIT/HUT 2002 22 BiểuthứcBezier-Bernstain  Tổng quát hoá vớin+1 điểmkiểm soát  p 0 pn : vector vị trí của đagiácn+1 đỉnh ))(()( )()( 1 0 1, 0 , ii n i ni i n i ni PpuBnup puBup −= ′ = + = − = ∑ ∑ ini ni uuinCuB − −= )1(),()( , )!in(!i !n )i,n(C − = (c) SE/FIT/HUT 2002 23 Tính chất  P0 và Pn nằm trên đường cong.  Đường cong liên tục và có đạo hàm liên tục tất cả các bậc  Tiếp tuyến của đường cong tại điểm P0 là đường P0P1 và tại Pn là đường Pn-1Pn .  Đường cong nằm trong đường bao lồi convex hull của các điểm kiểm soát.  This is because each successive Pi(j) is a convex combination of the points Pi(j-1) and Pi-1(j-1) .  P1 ,P2 , … ,Pn-1 nằm trên đường cong khi và chỉ khi đường cong là đoạn thẳng. (c) SE/FIT/HUT 2002 24 Review: Bézier Curve Prop’s [1/6]  We looked at some properties of Bézier curves.  Generally “Good” Properties  Endpoint Interpolation  Smooth Joining  Affine Invariance  Convex-Hull Property  Generally “Bad” Properties  Not Interpolating  No Local Control CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 5 (c) SE/FIT/HUT 2002 25 Problem with Bezier Curves  To make a long continuous curve with Bezier segments requires using many segments  Maintaining continuity requires constraints on the control point positions  The user cannot arbitrarily move control vertices and automatically maintain continuity  The constraints must be explicitly maintained  It is not intuitive to have control points that are not free (c) SE/FIT/HUT 2002 26 Invariance  Translational invariance means that translating the control points and then evaluating the curve is the same as evaluating and then translating the curve  Rotational invariance means that rotating the control points and then evaluating the curve is the same as evaluating and then rotating the curve  These properties are essential for parametric curves used in graphics  It is easy to prove that Bezier curves, Hermite curves and everything else we will study are translation and rotation invariant  Some forms of curves, rational splines, are also perspective invariant  Can do perspective transform of control points and then evaluate the curve (c) SE/FIT/HUT 2002 27 Longer Curves  A single cubic Bezier or Hermite curve can only capture a small class of curves  At most 2 inflection points  One solution is to raise the degree  Allows more control, at the expense of more control points and higher degree polynomials  Control is not local, one control point influences entire curve  Alternate, most common solution is to join pieces of cubic curve together into piecewise cubic curves  Total curve can be broken into pieces, each of which is cubic  Local control: Each control point only influences a limited part of the curve  Interaction and design is much easier (c) SE/FIT/HUT 2002 28 Piecewise Bezier Curve “knot” P 0,0 P 0,1 P 0,2 P 0,3 P 1,0 P 1,1 P 1,2 P 1,3 (c) SE/FIT/HUT 2002 29 Continuity  When two curves are joined, we typically want some degree of continuity across the boundary (the knot)  C 0 , “C-zero”, point-wise continuous, curves share the same point where they join  C 1 , “C-one”, continuous derivatives, curves share the same parametric derivatives where they join  C 2 , “C-two”, continuous second derivatives, curves share the same parametric second derivatives where they join  Higher orders possible  Question: How do we ensure that two Hermite curves are C 1 across a knot?  Question: How do we ensure that two Bezier curves are C 0 , or C 1 , or C 2 across a knot? (c) SE/FIT/HUT 2002 30 Đường bậc ba Spline  Spline đi qua n điểm cho trước mà mỗi đoạn là đường bậc ba độc lập có độ dốc và độ cong liên tục tại mỗi điểm kiểm soát hay điểm nút  Với n điểm:n-1 đoạn với mỗi đoạn 4 vector hệ số 4(n-1) cho n-1 đoạn, và 2(n-1) điều kiện biên và n-2 điều kiện về độ dốc cùng n-2 về độ cong  Spline dùng để chỉ phương pháp biểu diễn đường cong mềm thông qua các đoạn cong tham biến bậc ba với các điều kiện liên tục tại các điểm đầu nút CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 6 (c) SE/FIT/HUT 2002 31 Đường cong bậcba Spline  u 0 = 0 với : (u 0 un -1 ) uj +1 > uj  ui +1 = ui + di +1  C 0 để không có sự gián đoạngiữa hai đoạn cong.  C 1 tính liên tụcbậcnhất hay đạo hàm bậcnhấttại điểmnối.  C 2 đạo hàm bậc hai liên tụccủa đường cong tại điểmnối (c) SE/FIT/HUT 2002 32 Achieving Continuity  For Hermite curves, the user specifies the derivatives, so C 1 is achieved simply by sharing points and derivatives across the knot  For Bezier curves:  They interpolate their endpoints, so C 0 is achieved by sharing control points  The parametric derivative is a constant multiple of the vector joining the first/last 2 control points  So C 1 is achieved by setting P 0,3 =P 1,0 =J, and making P 0,2 and J and P 1,1 collinear, with J-P 0,2 =P 1,1 -J  C 2 comes from further constraints on P 0,1 and P 1,2 (c) SE/FIT/HUT 2002 33 Bezier Continuity P 0,0 P 0,1 P 0,2 J P 1,1 P 1,2 P 1,3 Disclaimer: PowerPoint curves are not Bezier curves, they are interpolating piecewise quadratic curves! This diagram is an approximation. (c) SE/FIT/HUT 2002 34 B-splines  B-splines automatically take care of continuity, with exactly one control vertex per curve segment  Many types of B-splines: degree may be different (linear, quadratic, cubic,…) and they may be uniform or non-uniform  We will only look closely at uniform B-splines  With uniform B-splines, continuity is always one degree lower than the degree of each curve piece  Linear B-splines have C 0 continuity, cubic have C 2 , etc (c) SE/FIT/HUT 2002 35 Đường cong B-spline  Đường cong B-spline là đường cong được sinh ra từ đa giác kiểm soát mà bậc của nó không phụ thuộc vào số đỉnh của đa giác kiểm soát. (c) SE/FIT/HUT 2002 36 B-Splines: The Idea [1/2]  The repeated-lirping idea that produced the Bézier curves has the drawbacks that is produces polynomials with high degree that are nonzero almost everywhere.  Using functions defined in pieces, we can fix these two.  Start: An order-1 B-Spline has blending functions that are always either 1 or 0. When a function is 1, all the rest are zero.  So an order-1 B-spline is just a sequence of points.  Any number of control points may be used.  Now we make higher-order B-splines using a repeated-lirping procedure.  But this time, we can use any number of control points. CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 7 (c) SE/FIT/HUT 2002 37 B-Splines: The Idea [2/2]  We form an order-2 B-Spline by lirping between the order-1 blending functions.  As discussed, we get functions that start at 0, ramp up to 1 and back down, then stay at zero. Each function is 0 most of the time.  So each blending function is defined in pieces. Each piece is a polynomial of degree 1 (graph is a line).  So an order-2 B-spline is just the control polygon.  Again, any number of control points may be used.  We form an order-3 B-Spline by lirping between the order-2 blending functions.  Now blending functions are smooth. They start at 0, curve up to 1 then back down. Again, each function is 0 most of the time.  Again, each blending function is defined in pieces. Each piece is a polynomial of degree 2.  We continue this repeated-lirping procedure to define B-splines of higher order.  See the blue book for details and graphs. (c) SE/FIT/HUT 2002 38 Types of B-Splines Approximation Curves Used B-Spline approximations can be classified based on the spacing of the knot vector and the use of weights. 1. Uniform/Periodic B-splines : The spacing is unform and the knots (control points) are equispaced e.g. [0,1,2,3,4,5] These have satisfactory smoothness but lack local control and the starting and ending poits are ill defined as above. 2. Non-periodic: The knots are repeated at the ends m times and the interior is equispaced. e.g. [0 0 0 1 2 3 3 3 ] These can be used to force the control point to start and finish at a control point. 3. Non-uniform B-Splines : The spacing is non- uniform and or repeated knots e.g. [0 1124566 ] These can be used to obtain local control B-Splines (c) SE/FIT/HUT 2002 39 Ví dụ: Uniform Cubic B-spline on [0,1]  Four control points are required to define the curve for 0 ≤ t<1 (t is the parameter)  Not surprising for a cubic curve with 4 degrees of freedom  The equation looks just like a Bezier curve, but with different basis functions  Also called blending functions - they describe how to blend the control points to make the curve ()()()() 3 3 32 2 32 1 32 0 3 0 4 6 1 3331 6 1 364 6 1 331 6 1 tPtttPttPtttP tBPtP i ii +−++++−+−+−= = ∑ = )()( , (c) SE/FIT/HUT 2002 40 Basis Functions on [0,1] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0 0.1 0.2 0.3 0.4 0 .5 0.6 0.7 0.8 0.9 1 t  Does the curve interpolate its endpoints?  Does it lie inside its convex hull? B 0,4 B 1,4 B 2,4 B 3,4 () () () () 3 3 32 2 32 1 1 32 0 6 1 3331 6 1 364 6 1 331 6 1 tP tttP ttP tttPtP + −+++ +−+ −+−=)( (c) SE/FIT/HUT 2002 41 Uniform Cubic B-spline on [0,1)  The blending functions sum to one, and are positive everywhere  The curve lies inside its convex hull  The curve does not interpolate its endpoints  Requires hacks or non-uniform B-splines  There is also a matrix form for the curve: []                         − − −− = 1 0001 1333 4063 1331 6 1 2 3 3210 t t t PPPPtP )( (c) SE/FIT/HUT 2002 42 Uniform - B-spline  Ni,k(u) đa thức B-Spline cơ bản  Vớin+ 1 sô điểmkiểmsoát  Pi điểm kiểm soát thứ i  k bậc của đường cong 1<k<n+2  Ui vector nút của đường cong U=[U1,U2 Un+k+1] i n i ki PuNuP ∑ = = 0 , ).()( )( )( )( )( )( )( 1, 21 1 1,1 1 1 , uN UU uU uN UU Uu uN ki kii i ki kii ki ki − −++ + −− −+ −+ − − + − − =    ∈ = + others0 ],[1 )( 1 1, ii i uuu uN CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 8 (c) SE/FIT/HUT 2002 43 Using Uniform B-splines  At any point t along a piecewise uniform cubic B-spline, there are four non-zero blending functions  Each of these blending functions is a translation of B 0,4  Consider the interval 0≤t<1  We pick up the 4th section of B 0,4  We pick up the 3rd section of B 1,4  We pick up the 2nd section of B 2,4  We pick up the 1st section of B 3,4 (c) SE/FIT/HUT 2002 44 Uniform Cubic B-spline Blending Functions 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 t B 0,4 B 1,4 B 2,4 B 3,4 B 4,4 B 5,4 B 6,4 (c) SE/FIT/HUT 2002 45 Computing the Curve 0 0.05 0.1 0.15 0.2 0.25 -3 -2.7 -2.3 -2 -1.6 -1.3 -0.9 -0.6 -0.2 0.1 0.5 0.8 1.2 1.5 1.9 2.2 2.6 2.9 3.3 3.6 4 4.3 4.7 t () () ∑ = = n k kk tBPtX 0 4, P 0 B 0,4 P 1 B 1,4 P 2 B 2,4 P 3 B 3,4 P 4 B 4,4 P 5 B 5,4 P 6 B 6,4 The curve can’t start until there are 4 basis functions active (c) SE/FIT/HUT 2002 46 (c) SE/FIT/HUT 2002 47 Đặc điểm  B-spline không đi qua hai điểm đầu và cuối trừ khi hàm hợp được dùng là tuyến tính.  B-spline có thể được tạo qua hai điểm đầu, cuối và tiếp xúc với vector đầu và cuối của đa giác kiểm soát. Bằng cách thêm vào các nút tại vị trí của các nút cuối của vector tuy nhiên các giá trị giống nhau không nhiều hơn bậc của đường cong.  Tính chất bao lồi của đa giác kiểm soát và tính chất chuẩn được thoa mãn.  Số lượng các nút, bậc của đường cong và số điểm điều khiển luôn có các quan hệ ràng buộc:  0 ≤ u ≤ n - k + 2 1(u)N n 0i ki, = ∑ = (c) SE/FIT/HUT 2002 48 ()    ≤≤ = + otherwise 0 1 1 1, kk k ttt tB B-Spline Blending Functions  The recurrence relation starts with the 1st order B-splines, just boxes, and builds up successively higher orders  This algorithm is the Cox - de Boor algorithm () () () tB tt tt tB tt tt tB dk kdk dk dk kdk k dk 1,1 1 1, 1 , −+ ++ + − −+         − − +         − − = CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 9 (c) SE/FIT/HUT 2002 49 B k,1 B 0,1 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B0,1(t) B 2,1 0 0.2 0.4 0.6 0.8 1 1.2 -3 - 2. 8 - 2 . 6 - 2 . 4 -2. 2 -2 - 1. 8 - 1. 6 - 1 . 4 - 1 . 2 - 1 -0. 8 - 0. 6 - 0. 4 - 0. 2 0 0.2 0.4 0. 6 0. 8 1 t B2,1 ( t ) B 3,1 0 0.2 0.4 0.6 0.8 1 1.2 - 3 -2 . 8 -2 . 6 -2 . 4 -2 . 2 - 2 -1 . 8 -1 . 6 -1 . 4 - 1. 2 -1 -0 . 8 -0 . 6 -0 . 4 -0 . 2 0 0. 2 0. 4 0 . 6 0. 8 1 t B3 , 1 ( t ) B 1,1 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2. 8 -2. 6 -2. 4 -2. 2 - 2 -1. 8 - 1 . 6 -1. 4 -1. 2 -1 - 0 . 8 -0. 6 -0. 4 -0. 2 0 0.2 0 .4 0.6 0.8 1 t B1,1 ( t ) (c) SE/FIT/HUT 2002 50 B k,2 B 0,2 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B0,2(t) B 1,2 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B1,2(t) B 2,2 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B2,2(t)    −<≤−−− −<≤−+ = 12 1 23 3 )( 2,0 tt tt tB (c) SE/FIT/HUT 2002 51 B k,3 B 0,3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B0,3(t) B 1,3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 -3 -2 .8 -2. 6 -2.4 -2 .2 -2 -1. 8 -1. 6 -1 .4 -1 .2 -1 -0. 8 -0.6 -0 .4 -0. 2 0 0 .2 0 .4 0.6 0.8 1 t B1,3(t) ()      <≤− −<≤−−−− −<≤−+ = 01 12 362 23 3 2 1 )( 2 2 2 3,0 tt ttt tt tB (c) SE/FIT/HUT 2002 52 B 0,4 B 0,4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 -3 -2.8 -2.6 -2.4 -2.2 -2 -1.8 -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 t B0,4(t) (c) SE/FIT/HUT 2002 53 B 0,4 () ()        <≤− <≤−+−+ −<≤−−−−− −<≤−+ = 10 1 01 1333 12 521153 23 3 6 1 )( 3 23 23 3 4,0 tt tttt tttt tt tB Note that the functions given on slides 5 and 6 are translates of this function obtained by using (t-1), (t-2) and (t-3) instead of just t, and then selecting only a sub-range of t values for each function (c) SE/FIT/HUT 2002 54 B Spline - Đềuvàtuần hoàn  Vecto nút là đều khi giá trị của chúng cách đều nhau một khoảng ∇ xác định. Trong các bài toán thực tế, vecto nút đều được bắt đầu từ 0 và tăng 1 cho đến giá trị lớn nhất  Ví dụ: [ 0 1 2 3 4 5 ] với ∇ xác định = 1  [ -2 -1/2 1 5/2 4 ] với ∇ xác định = 3/2  Với cấp là k, số điểm kiểm soát là n+1 thì vecto nút đều là  U=[0 1 2 n+k] khoảng tham số (k-1)≤u≤(n+1).  Khi vecto nút là đều thì ta có Ni,k(u)=Ni-1,k(u-1)=Ni+1,k(u+1) CNTT-DHBK Hanoi hunglt@it-hut.edu.vn 10 (c) SE/FIT/HUT 2002 55 Không tuần hoàn Open – Non Uniform  Một vector không tuần hoàn hoặc mở là vector nút có giá trị nút tại các điểm đầu cuối lặp lại với số lượng các giá trị lặp lại này bằng chính cấp k của đường cong và các giá trị nút trong mỗi điểm lặp này là bằng nhau  Nếu một trong hai điều kiện này hoặc cả hai điều kiện không được thoả mãn thì vecto nút là không đều.  Cách tính Ui Ui = 0 1=<i<=k Ui = i-k k+1<i<=n+1 Ui = n-k+2 n+1<i<=n+k+1 2 6 [0 0 1 2 3 3] 3 7 [0 0 0 1 2 2 2] 4 8 [0 0 0 0 1 1 1 1] Cấp k số lượng nút (m = n + k) Vector nút không tuần hoàn (c) SE/FIT/HUT 2002 56 B-Splines: Properties  The most used B-splines are:  Order 3 (“quadratic B-splines”). • Smooth.  Order 4 (“cubic B-splines”). • Smoother, but control is a little less local.  B-splines have the following properties.  An order-k B-spline has blending functions that are defined in pieces, using polynomials of degree k–1. • This is true for any number of control points. We can choose the number of control points and the polynomial degree separately. ☺  B-splines are affine invariant (of course).  They have the convex-hull property. ☺  They have local control. ☺  A B-spline (of order 3 or more) does not interpolate any of its control points.  But we can deal with this … (c) SE/FIT/HUT 2002 57 Kếtluận  B-spline là một dòng của Bezier  Thực tế khi ta chọn bậc k cho tập hợp k điểm thì thi B-spline chuyển thành Bezier  Khi bậc của đa thức giảm sựảnh hưởng cục bộ của mỗi điểm nút càng rõ ràng hơn.  Khi tồn tại anh hưởng cục bộ càng lớn và đường cong phai đi qua điểm đó.  Chúng ta có thể thay đổi hình dạng đường cong B-spline bằng cách:  Thay đổi kiểu vecto nút : đều tuần hoàn, mở, không đều  Thay đổi cấp k của đường cong  Thay đổi số đỉnh và vị trí các đỉnh đa giác kiểm soát  Sử dụng các điểm kiểm soát trùng nhau (c) SE/FIT/HUT 2002 58 Rational Curves  Each point is the ratio of two curves  Just like homogeneous coordinates:  NURBS: x(t), y(t), z(t) and w(t) are non-uniform B-splines  Advantages:  Perspective invariant, so can be evaluating in screen space  Can perfectly represent conic sections: circles, ellipses, etc • Piecewise cubic curves cannot do this       → )( )( , )( )( , )( )( )](),(),(),([ tw tz tw ty tw tx twtztytx (c) SE/FIT/HUT 2002 59 Rational Spline - NURBS  A Rational Spline is like a B-Spline but the designer can add weightings to the blending functions to modify the curve.  The blending functions produce a ratio of the polynomials used. ∑ = = L k kk t RPP t 0 )( )( ∑ = = L k mkk mkk k t t t Nw Nw R 0 , , )( )( )( (c) SE/FIT/HUT 2002 60 OpenGL and NURBS  NURBS: Non-uniform Rational B-splines  The curved surface of choice in CAD packages  Support routines are part of the GLu utility library  Allows you to specify how they are rendered:  Can use points constantly spaced in parametric space  Can use various error tolerances - the good way!  Allows you to get back the lines that would be drawn  Allows you to specify trim curves  Only for surfaces  Cut out parts of the surface - in parametric space [...]... biến trong Độ mượt - smooth Với đường cong Hermite and Bézier tính liên tục continuity của đường cong hay đạo hàm bậc 1-first derivative tại các điểm kiểm soát-control point Với B-splines tính liên tục trên đạo hàm bậc 2 second derivative hay độ cong được đảm bảo curvature Độ biến đổi -" variation diminishing." đường cong ít bị khuếch đại sai số bởi các điểm kiểm soát hay tính nhấp nhô của đường cong. ..CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Other Splines: NURBS, etc Non-uniform Rational B-Splines(NURBS) There are any number of other types of splines The last 3 types are good for representing free form curves but also introduce unnecessary approximations in the representation of conic sections NURBS build on non-uniform B-Splines and introduce a weight function to... done quickly will be more useful in 3-D graphics The curve is described as rational since it is expressed as the ratio of two polynomials wi defines a weight function If wi is set to 1 we get back the nonuniform B-Spline Other values of the wi can be used to produce curves for straight line, parabola, ellipse and hyperbola (c) SE/FIT/HUT 2002 61 Tính chất cả đường cong đa thức 62 How to Choose a Spline... approximation that retains all the advantages of the non-uniform B-Splines and is also capable of exact representation of conic sections (circles, parabolas etc.).The general form is given below: Often we want a very general type of curve that will do whatever we want One such type of curve that has been very successful is the NURBS NURBS = Non-Uniform Rational B-Spline A NURBS is defined using rational functions... oscillate Ví dụ Bézier curve, for instance, lies within the convex hull (polygon envelope) of the set of control points Điêm kiểm soát cục bộ-local control đường cong bị ảnh hưởng mạnh nhất với chính các điểm kiểm soát gần chúng nhất (c) SE/FIT/HUT 2002 (c) SE/FIT/HUT 2002 63 Hermite curves are good for single segments where you know the parametric derivative or want easy control of it Bezier curves are good... functions • A rational function is a polynomial divided by a polynomial Control points can be given weights, so some are more important than others NURBS curves (and surfaces) are built into GLU, but can be rather complex to use One important issue when defining curves and surfaces: In advanced rendering the technique of ray tracing is often used In ray tracing, we determine the color of a pixel by tracing... good for single segments where you know the parametric derivative or want easy control of it Bezier curves are good for single segments or patches where a user controls the points B-splines are good for large continuous curves and surfaces NURBS are the most general, and are good when that generality is useful, or when conic sections must be accurately represented (CAD) (c) SE/FIT/HUT 2002 64 11 . 0,2 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2 .8 -2 .6 -2 .4 -2 .2 -2 -1 .8 -1 .6 -1 .4 -1 .2 -1 -0 .8 -0 .6 -0 .4 -0 .2 0 0.2 0.4 0.6 0.8 1 t B0,2(t) B 1,2 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2 .8 -2 .6 -2 .4 -2 .2 -2 -1 .8 -1 .6 -1 .4 -1 .2 -1 -0 .8 -0 .6 -0 .4 -0 .2 0 0.2 0.4 0.6 0.8 1 t B1,2(t) B. 0,3 0 0.1 0.2 0.3 0.4 0.5 0.6 0 .7 0.8 -3 -2 .8 -2 .6 -2 .4 -2 .2 -2 -1 .8 -1 .6 -1 .4 -1 .2 -1 -0 .8 -0 .6 -0 .4 -0 .2 0 0.2 0.4 0.6 0.8 1 t B0,3(t) B 1,3 0 0.1 0.2 0.3 0.4 0.5 0.6 0 .7 0.8 -3 -2 .8 -2 . 6 -2 .4 -2 .2 -2 -1 . 8 -1 . 6 -1 .4 -1 .2 -1 -0 . 8 -0 .6 -0 .4 -0 . 2 0 0 .2 0 .4 0.6 0.8 1 t B1,3(t) ()      <≤− −<≤−−−− −<≤−+ = 01. 0,1 0 0.2 0.4 0.6 0.8 1 1.2 -3 -2 .8 -2 .6 -2 .4 -2 .2 -2 -1 .8 -1 .6 -1 .4 -1 .2 -1 -0 .8 -0 .6 -0 .4 -0 .2 0 0.2 0.4 0.6 0.8 1 t B0,1(t) B 2,1 0 0.2 0.4 0.6 0.8 1 1.2 -3 - 2. 8 - 2 . 6 - 2 . 4 -2 . 2 -2 - 1. 8 - 1. 6 - 1 . 4 - 1 . 2 - 1 -0 . 8 - 0. 6 - 0. 4 - 0. 2 0 0.2 0.4 0. 6 0. 8 1 t B2,1 ( t ) B

Ngày đăng: 24/10/2014, 15:25

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan