Download presentation
Presentation is loading. Please wait.
Published byDominick Austin Modified over 9 years ago
1
Computer Graphics Lecture 13 Curves and Surfaces I
2
Computer Graphics 10/10/2008Lecture 52 Types of Curves / Surfaces Explicit: y = mx + b z = A x + B y + C Implicit: Ax + By + C = 0 (x – x 0 ) 2 + (y – y 0 ) 2 – r 2 = 0 Parametric: x = x 0 + (x 1 – x 0 )t x = x 0 + rcos y = y 0 + (y 1 – y 0 )t y = y 0 + rsin
3
Computer Graphics 10/10/2008Lecture 53 Today Implicit Surfaces –Metaball Parametric surfaces –Hermite curve –Bezier curve –Biubic patches –Tessalation
4
Computer Graphics 3/10/2008Lecture 34 Implicit Surfaces Functions in the form of F(x,y,z) = 0 –i.e. Quadric functions Sphere: f(x,y,z) = x + y + z = 0 2 2 2
5
Computer Graphics Metaballs One type of implicit surface Also known as blobby objects Negative volume to produce hollows Can be used to model smooth surfaces, liquid
6
Computer Graphics Metaballs (2) A point surrounded by a density field The density decreases with distance from the point The density of multiple particles is summed A surface is implied by sampling the area where the density is a predefined threshold
7
Computer Graphics An Example of the density function where (x 0,y 0,z 0 ) is the centre of the metaball
8
Computer Graphics Metaballs (3) The surface points are sampled and approximated by polygonal meshes for rendering Demo animation of metaballs http://www.youtube.com/watch?v=UWvGyK olkho&feature=relatedhttp://www.youtube.com/watch?v=UWvGyK olkho&feature=related http://www.youtube.com/watch?v=Nf_OlfW MRaA&NR=1http://www.youtube.com/watch?v=Nf_OlfW MRaA&NR=1
9
Computer Graphics 10/10/2008Lecture 59 Today Implicit Surfaces –Metaball Parametric surfaces –Hermite curve –Bezier curve –Biubic patches –Tessalation
10
Computer Graphics 10/10/2008Lecture 510 Why parametric? Parametric curves are very flexible. Parameter count gives the object’s dimension. (x(u,v), y(u,v), z(u,v)) : 2D surface Coord functions independent.
11
Computer Graphics 10/10/2008Lecture 511 Specifying curves Control Points: –A set of points that influence the curve’s shape. Interpolating curve: –Curve passes through the control points. Control polygon: –Control points merely influence shape.
12
Computer Graphics 10/10/2008Lecture 512 Piecewise curve segments We can represent an arbitrary length curve as a series of curves pieced together. But we will want to control how these curves fit together …
13
Computer Graphics If the tangent vectors of two cubic curve segments are equal at the join point, the curve has first-degree continuity, and is said to be C continuous If the direction and magnitude of d / dt [Q(t)] through the nth derivative are equal at the join point, the curve is called C continuous If the directions (but not necessarily the magnitudes) of two segments’ tangent vectors are equal at the join point, the curve has G continuity Continuity between curve segments 1 n nn 1
14
Computer Graphics Example The curves Q1 Q2 Q3 join at point P Q1 and Q2 have equal tangent vectors at P and hence C 1 and G 1 continuous Q1 and Q3 have tangent vectors in the same direction but Q3 has twice magnitude, so they are only G 1 continuous at P
15
Computer Graphics 10/10/2008Lecture 515 Parametric Cubic Curves In order to assure C2 continuity our functions must be of at least degree 3. Cubic has 4 degrees of freedom and can control 4 things. Use polynomials: x(t) of degree n is a function of t. – –y(t) and z(t) are similar and each is handled independently
16
Computer Graphics 10/10/2008Lecture 516 Hermite curves A cubic polynomial Polynomial can be specified by the position of, and gradient at, each endpoint of curve. Determine: x = X(t) in terms of x 0, x 0 ’, x 1, x 1 ’ Now: X(t) = a 3 t 3 + a 2 t 2 + a 1 t + a 0 and X / (t) = 3a 3 t 2 + 2a 2 t + a 1
17
Computer Graphics 10/10/2008Lecture 517 Finding Hermite coefficients Substituting for t at each endpoint: x 0 = X(0) = a 0 x 0 ’ = X / (0) = a 1 x 1 = X(1) = a 3 + a 2 + a 1 + a 0 x 1 ’ = X / (1) = 3a 3 + 2a 2 + a 1 And the solution is: a 0 = x 0 a 1 = x 0 ’ a 2 = -3x 0 – 2x 0 ’ + 3x 1 – x 1 ’ a 3 = 2x 0 + x 0 ’ - 2x 1 + x 1 ’
18
Computer Graphics 10/10/2008Lecture 518 The Hermite matrix: M H The resultant polynomial can be expressed in matrix form: X(t) = t T M H q ( q is the control vector) We can now define a parametric polynomial for each coordinate required independently, ie. X(t), Y(t) and Z(t)
19
Computer Graphics Hermite Basis (Blending) Functions
20
Computer Graphics 10/10/2008Lecture 520 Hermite Basis (Blending) Functions x0x0 x1x1 x0'x0' x1/x1/ The graph shows the shape of the four basis functions – often called blending functions. They are labelled with the elements of the control vector that they weight. Note that at each end only position is non-zero, so the curve must touch the endpoints
21
Computer Graphics 10/10/2008Lecture 521 Family of Hermite curves. x(t) y(t) Note : Start points on left.
22
Computer Graphics 10/10/2008Lecture 522 Displaying Hermite curves. Simple : –Select step size to suit. –Plug x values into the geometry matrix. –Evaluate P(t) x value for current position. –Repeat for y & z independently. –Draw line segment between current and previous point. Joining curves: –Coincident endpoints for C 0 continuity –Align tangent vectors for C 1 continuity.
23
Computer Graphics 10/10/2008Lecture 523 Bézier Curves Hermite cubic curves are difficult to model – need to specify point and gradient. More intuitive to only specify points. Pierre Bézier (an engineer at Renault) specified 2 endpoints and 2 additional control points to specify the gradient at the endpoints. Can be derived from Hermite matrix: –Two end control points specify tangent
24
Computer Graphics 10/10/2008Lecture 524 Bézier Curves P2P2 P1P1 P4P4 P3P3 P3P3 P4P4 P2P2 P1P1 Note the Convex Hull has been shown as a dashed line – used as a bounding extent for intersection purposes.
25
Computer Graphics 10/10/2008Lecture 525 Bézier Matrix The cubic form is the most popular X(t) = t T M B q (M B is the Bézier matrix) With n=4 and r=0,1,2,3 we get: Similarly for Y(t) and Z(t)
26
Computer Graphics 10/10/2008Lecture 526 Bézier blending functions This is how they look – The functions sum to 1 at any point along the curve. Endpoints have full weight The weights of each function is clear and the labels show the control points being weighted. q0q0 q3q3 q1q1 q2q2
27
Computer Graphics Joining Bezier Curves G continuity is provided at the endpoint when P 2 – P 3 = k (Q 1 – Q 0 ) if k=1, C continuity is obtained 1 1
28
Computer Graphics Bicubic patches The concept of parametric curves can be extended to surfaces The cubic parametric curve is in the form of Q(t)=t T M q where q=(q 1,q 2,q 3,q 4 ) : q i control points, M is the basis matrix (Hermite or Bezier,…), t T =(t 3, t 2, t, 1)
29
Computer Graphics Now we assume q i to vary along a parameter s, Q i (s,t)=t T M [q 1 (s),q 2 (s),q 3 (s),q 4 (s)] q i (s) are themselves cubic curves, we can write them in the form …
30
Computer Graphics Bicubic patches where q is a 4x4 matrix Each column contains the control points of q 1 (s),…,q 4 (s) x,y,z computed by
31
Computer Graphics 14/10/2008Lecture 631 Bézier example We compute (x,y,z) by
32
Computer Graphics 14/10/2008Lecture 632 Continuity of Bicubic patches. Hermite and Bézier patches –C 0 continuity by sharing 4 control points between patches. –C 1 continuity when both sets of control points either side of the edge are collinear with the edge.
33
Computer Graphics 14/10/2008Lecture 633 Displaying Bicubic patches. Need to compute the normals –vector cross product of the 2 tangent vectors. Need to convert the bicubic patches into a polygon mesh –tessellation
34
Computer Graphics Normal Vectors The surface normal is biquintic (two variables, fifth- degree) polynomial and very expensive Can use finite difference to reduce the computation
35
Computer Graphics 14/10/2008Lecture 635 Tessellation We need to compute the triangles on the surface The simplest way is do uniform tessellation, which samples points uniformly in the parameter space Adaptive tessellation – adapt the size of triangles to the shape of the surface –i.e., more triangles where the surface bends more –On the other hand, for flat areas we do not need many triangles
36
Computer Graphics Adaptive Tessellation For every triangle edges, check if each edge is tessellated enough (curveTessEnough()) If all edges are tessellated enough, check if the whole triangle is tessellated enough as a whole (triTessEnough()) If one or more of the edges or the triangle’s interior is not tessellated enough, then further tessellation is needed
37
Computer Graphics When an edge is not tessellated enough, a point is created halfway between the edge points’ uv-values New triangles are created and the tessellator is once again called with the new triangles as input Adaptive Tessellation Four cases of further tessellation
38
Computer Graphics Adaptive Tessellation AdaptiveTessellate(p,q,r) tessPQ=not curveTessEnough(p,q) tessQR=not curveTessEnough(q,r) tessRP=not curveTessEnough(r,p) If (tessPQ and tessQR and tessRP) –AdaptiveTessellate(p,(p+q)/2,(p+r)/2); –AdaptiveTessellate(q,(q+r)/2,(q+p)/2); –AdaptiveTessellate(r,(r+p)/2,(r+q)/2); –AdaptiveTessellate((p+q)/2,(q+r)/2,(r+p)/2); else if (tessPQ and tessQR) –AdaptiveTessellate(p,(p+q)/2,r); –AdaptiveTessellate((p+q)/2,(q+r)/2,r); –AdaptiveTessellate((p+q)/2,q,(q+r)/2); else if (tessPQ) –AdaptiveTessellate(p,(p+q)/2,r); –AdaptiveTessellate(q,r,(p+q)/2); Else if (not triTessEnough(p,q,r)) AdaptiveTessellate((p+q+r)/3,p,q); AdaptiveTessellate((p+q+r)/3,q,r); AdaptiveTessellate((p+q+r)/3,r,p); end;
39
Computer Graphics curveTessEnough Say you are to judge whether ab needs tessellation You can compute the midpoint c, and compute its distance l from ab Check if l/||a-b|| is under a threshold Can do something similar for triTessEnough –Sample at the mass center and calculate its distance from the triangle a b c d
40
Computer Graphics Other factors to evaluate Inside the view frustum Front facing Occupying a large area in screen space Close to the sillhouette of the object Illuminated by a significant amount of specular lighting
41
Computer Graphics Demo http://www.nbb.cornell.edu/neurobio/land/ OldStudentProjects/cs490- 96to97/anson/BezierPatchApplet/
42
Computer Graphics 10/10/2008Lecture 542 Reading for this lecture Foley et al. Chapter 11, section 11.2 up to and including 11.2.3 Introductory text Chapter 9, section 9.2 up to and including section 9.2.4 Foley at al., Chapter 11, sections 11.2.3, 11.2.4, 11.2.9, 11.2.10, 11.3 and 11.5. Introductory text, Chapter 9, sections 9.2.4, 9.2.5, 9.2.7, 9.2.8 and 9.3. Real-time Rendering 2 nd Edition Chapter 12.1-3
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.