Bài giảng Đồ họa hiện thực ảo: Bài 7 - Lê Tấn Hùng

11 53 0
Bài giảng Đồ họa hiện thực ảo: Bài 7 - Lê Tấn Hùng

Đ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

Bài giảng Đồ họa hiện thực ảo - Bài 7: Đường cong trong không gian cung cấp cho người học các kiến thức: Đường cong, phân loại đường cong, biểu diễn đường cong, đường tham chiếu, đường cong Hermite,... Mời các bạn cùng tham khảo nội dung chi tiết.

CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Đường cong - Curve Đường cong không gian 3D CURVE Why use curves? Quỹ đạo chuyển động điểm 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 representand control-the curve Cách tiếp cận sở lĩnh vực Computer Aided Geometric Design (CAGD) (c) SE/FIT/HUT 2002 (c) SE/FIT/HUT 2002 Phân loại Biểu diễn Đường cong Trên sở ràng buộc điểm đường ứng dụng khoa học thiết kế ta co thể phân làm loại: Xấp xỉ-Approximation - Được ứng dụng mơ hình hố hình học Nội suy-Interpolation Trong thiết kế nôi suy cần thiết với đối tượng không phù hợp với đối tượng có hình dáng "free form“ (c) SE/FIT/HUT 2002 Đường cong tham biến 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) = 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 Parametric Curves Biểu diễn đường cong tham biến Parametric representation: We have seen the parametric form for a line: x = x0t + (1 − t ) x1 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 y = y0t + (1 − t ) y1 z = z0t + (1 − t ) z1 Note that x, y and z are each given by an equation that involves: Define a parameter space 1D for curves 2D for surfaces The parameter t Some user specified control points, x0 and x1 Define a mapping from parameter space to 3D points A function that takes parameter values and gives back 3D points This is an example of a parametric curve The result is a parametric curve or surface Mapping F :t → (x, y, z) t (c) SE/FIT/HUT 2002 CuuDuongThanCong.com (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Đường cong đa thức bậc ba Đường cong bậc Phải đảm bảo đường cong không gian với trục toạ độ x, y, z tránh tính tốn phức tạp phần nhấp nhơ ngồi ý muốn xuất đường đa thức bậc cao Why cubic? x = a1 + b1u + c1u2 + d1u3 y = a2 + b2u + c2u2 + d2u3 z = a3 + b3u + c3u2 + d3u3 Với điểm P0, P1, P2, P3 phương trình xác định P'1 p3 P1 p2 P'0 P0 P0 (c) SE/FIT/HUT 2002 Hermite Spline P1 (c) SE/FIT/HUT 2002 Đường cong Hermite 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 p = p(u) = k0 + k1u + k2u2 + k3u3 p(u) = ∑kiui i∈n Phương pháp Hermite dựa sở 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 p0 p1 ta có hai độ dốc p0’ p1’ với u = u = hai điểm đầu cuối đoạn [0,1] We have constraints: (c) SE/FIT/HUT 2002 The curve must pass through p0 when u=0 The derivative must be p’0 when u=0 The curve must pass through p1 when u=1 The derivative must be p’1 when u=1 (c) SE/FIT/HUT 2002 10 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 Thay vào: p = p(u) = p0(1-3u2+2u3) + p1(3u2-2u3) + p0’(u-2u2+u3) + p1’(-u2+u3) p = p(u) = [ u u2 u3 ] (c) SE/FIT/HUT 2002 CuuDuongThanCong.com 11 (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt 12 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Đường cong Bezier Sử dụng điểm vector kiểm soát độ dốc đường cong điểm mà qua.(Hermit) khơng thuận lợi cho việc thiết kế tương tác, không tiếp cận vào độ dốc đường cong giá trị số (Hermite) Paul Bezier, RENAULT, 1970 đường bề mặt UNISURF po, p3 tương đương với p0, p1 đường Hermite diểm trung gian p1, p2 xác định 1/3 theo độ dài vector tiếp tuyến điểm po p3 p0’ = 3(p1 – p0) p3’ = 3(p3 – p2) p = p(u) = p0(1-3u2+2u3) + p1(3u2-2u3) + p0’(u-2u2+u3) + p1’(u + u 3) p = p(u) = p0(1 - 3u + 3u2 - u3) + p1(3u-6u2-3u3) + p2(3u2 - 3u3) + p3u3 13 (c) SE/FIT/HUT 2002 14 (c) SE/FIT/HUT 2002 Biểu diễn Ma trận Ưu điểm 1.2 0.8 B0 B1 B2 B3 0.6 0.4 0.2 0 1  − 3 p = p(u) = [ u u2 u3 ]  −  − − (c) SE/FIT/HUT 2002 0  0 0  1 dễ dàng kiểm soát hi`nh dạng đường cong vector tiếp tuyến p0’ p1’ Hermite Nằm đa giác kiểm soát với số điểm trung gian tuỳ ý( số bậc tuỳ ý) qua điểm đầu điểm cuối đa giác kiểm soát, tiếp xúc với cặp hai vector đầu cuối  p0  p   1  p2     p3  15 Example Bezier Curves 16 (c) SE/FIT/HUT 2002 Sub-Dividing Bezier Curves M12 P1 M012 [UW] M0123 P2 M123 M01 M23 P0 (c) SE/FIT/HUT 2002 CuuDuongThanCong.com 17 P3 (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt 18 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Sub-Dividing Bezier Curves Sub-Dividing Bezier Curves P1 P2 P0 Step 1: Find the midpoints of the lines joining the original control vertices Call them M01, M12, M23 Step 2: Find the midpoints of the lines joining M01, M12 and M12, M23 Call them M012, M123 Step 3: Find the midpoint of the line joining M012, M123 Call it M0123 The curve with control points P0, M01, M012 and M0123 exactly follows the original curve from the point with t=0 to the point with t=0.5 The curve with control points M0123 , M123 , M23 and P3 exactly follows the original curve from the point with t=0.5 to the point with t=1 P3 19 (c) SE/FIT/HUT 2002 de Casteljau’s Algorithm P2 n i =0 Bi ,n (u ) = C ( n, i )u i (1 − u ) n −i t=0.25 p0 pn : vector vị trí đa giác n+1 đỉnh n! C( n, i) = i! ( n − i)! M01 P3 21 (c) SE/FIT/HUT 2002 22 Review: Bézier Curve Prop’s [1/6] Tính chất P0 Pn nằm đường cong Đường cong liên tục có đạo hàm liên tục tất bậc Tiếp tuyến đường cong điểm P0 đường P0P1 Pn đường Pn-1Pn Đường cong nằm đường bao lồi convex hull đ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 đường cong đường cong đoạn thẳng (c) SE/FIT/HUT 2002 CuuDuongThanCong.com n p(u ) = ∑ Bi ,n (u ) pi p′(u ) = n ∑ Bi ,n −1 (u )( pi +1 − Pi ) M23 (c) SE/FIT/HUT 2002 Tổng quát hoá với n +1 điểm kiểm soát i =0 M12 P0 20 Biểu thức Bezier-Bernstain 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 P1 (c) SE/FIT/HUT 2002 23 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 (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt 24 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Problem with Bezier Curves 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 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 Can perspective transform of control points and then evaluate the curve 25 Longer Curves Piecewise Bezier Curve A single cubic Bezier or Hermite curve can only capture a small class of curves P0,1 At most inflection points P0,2 One solution is to raise the degree “knot” Allows more control, at the expense of more control points and higher degree polynomials Control is not local, one control point influences entire curve P0,0 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 P1,3 P0,3 P1,0 Alternate, most common solution is to join pieces of cubic curve together into piecewise cubic curves P1,1 27 Continuity P1,2 (c) SE/FIT/HUT 2002 28 Đường bậc ba Spline When two curves are joined, we typically want some degree of continuity across the boundary (the knot) C0, “C-zero”, point-wise continuous, curves share the same point where they join C1, “C-one”, continuous derivatives, curves share the same parametric derivatives where they join C2, “C-two”, continuous second derivatives, curves share the same parametric second derivatives where they join Higher orders possible Question: How we ensure that two Hermite curves are C1 across a knot? Question: How we ensure that two Bezier curves are C0, or C1, or C2 across a knot? (c) SE/FIT/HUT 2002 CuuDuongThanCong.com 26 (c) SE/FIT/HUT 2002 29 Spline qua n điểm cho trước mà đoạn đường bậc ba độc lập có độ dốc độ cong liên tục điểm kiểm soát hay điểm nút Với n điểm:n-1 đoạn với đoạn vector hệ số 4(n-1) cho n-1 đoạn, 2(n-1) điều kiện biên n-2 điều kiện độ dốc n-2 độ cong Spline dùng để phương pháp biểu diễn đường cong mềm thông qua đoạn cong tham biến bậc ba với điều kiện liên tục điểm đầu nút (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt 30 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn Đường cong bậc ba Spline Achieving Continuity For Hermite curves, the user specifies the derivatives, so C1 is achieved simply by sharing points and derivatives across the knot For Bezier curves: u0 = với : (u0 un-1) uj+1 > uj ui+1 = ui + di+1 C0 để khơng có gián đoạn hai đoạn cong C1 tính liên tục bậc hay đạo hàm bậc điểm nối C2 đạo hàm bậc hai liên tục đường cong điểm nối They interpolate their endpoints, so C0 is achieved by sharing control points The parametric derivative is a constant multiple of the vector joining the first/last control points So C1 is achieved by setting P0,3=P1,0=J, and making P0,2 and J and P1,1 collinear, with J-P0,2=P1,1-J C2 comes from further constraints on P0,1 and P1,2 31 (c) SE/FIT/HUT 2002 Bezier Continuity P0,1 (c) SE/FIT/HUT 2002 32 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 P0,2 P0,0 P1,3 J P1,1 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 P1,2 Linear B-splines have C0 continuity, cubic have C2, etc Disclaimer: PowerPoint curves are not Bezier curves, they are interpolating piecewise quadratic curves! This diagram is an approximation (c) SE/FIT/HUT 2002 33 (c) SE/FIT/HUT 2002 34 B-Splines: The Idea [1/2] Đường cong B-spline 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 Đường cong B-spline đường cong sinh từ đa giác kiểm sốt mà bậc khơng phụ thuộc vào số đỉnh đa giác kiểm soát Using functions defined in pieces, we can fix these two Start: An order-1 B-Spline has blending functions that are always either or 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 (c) SE/FIT/HUT 2002 CuuDuongThanCong.com 35 (c) SE/FIT/HUT 2002 https://fb.com/tailieudientucntt 36 CNTT-DHBK Hanoi hunglt@it-hut.edu.vn B-Splines: The Idea [2/2] B-Splines 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 and back down, then stay at zero Each function is most of the time So each blending function is defined in pieces Each piece is a polynomial of degree (graph is a line) So an order-2 B-spline is just the control polygon Again, any number of control points may be used 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 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 Non-periodic: The knots are repeated at the ends m times and the interior is equispaced e.g [0 0 3 ] These can be used to force the control point to start and finish at a control point Non-uniform B-Splines : The spacing is nonuniform and or repeated knots e.g [0 1 6 ] These can be used to obtain local control 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 then back down Again, each function is most of the time Again, each blending function is defined in pieces Each piece is a polynomial of degree We continue this repeated-lirping procedure to define B-splines of higher order See the blue book for details and graphs 37 (c) SE/FIT/HUT 2002 (c) SE/FIT/HUT 2002 Ví dụ: Uniform Cubic B-spline on [0,1] Basis Functions on [0,1] Four control points are required to define the curve for 0≤t

Ngày đăng: 11/01/2020, 20:48

Từ khóa liên quan

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

  • Đang cập nhật ...

Tài liệu liên quan