Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10: Curves and Surfaces Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides.

Similar presentations


Presentation on theme: "Chapter 10: Curves and Surfaces Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides."— Presentation transcript:

1 Chapter 10: Curves and Surfaces Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides by Edward Angel and Dave Shreiner

2 Objectives Introduce types of curves and surfaces: – Explicit. – Implicit. – Parametric. – Strengths and weaknesses. Discuss Modeling and Approximations: – Conditions. – Stability. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 2

3 Escaping Flatland Until now we have worked with flat entities such as lines and polygons: – Fit well with graphics hardware. – Mathematically simple. The world is not composed of flat entities: – Need curves and curved surfaces. – May only have need at the application level. – Implementation can render them approximately with flat primitives. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 3

4 Modeling with Curves E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 4 data points approximating curve interpolating data point

5 What Makes a Good Representation? There are many ways to represent curves and surfaces. Want a representation that is: – Stable. – Smooth. – Easy to evaluate. – Must we interpolate or can we just come close to data? – Do we need derivatives? E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 5

6 Explicit Representation Dependent variables in terms of independent variables. Familiar form of curve in 2D: y=f(x) Coordinate system dependent. Cannot represent all curves (special cases): – Vertical lines and circles. Extension to 3D : – y=f(x), z=g(x) – The form z = f(x, y) defines a surface. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 6 x y x y z

7 Implicit Representation Two dimensional curve(s): f(x, y)=0 Much more robust (less coordinate system dependent): – All lines ax+by+c=0; Circles x 2 +y 2 -r 2 =0 Divides space into points that belong to curve and those that do not. Three dimensions f(x, y, z)=0 defines a surface: – Intersect two surface to get a curve. In general, difficult to solve for points that satisfy constraints. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 7

8 Algebraic Surface E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 8 Sum of polynomials in the variables: Quadric surface (spheres, disks, cones): 2  i + j + k (at most 10 terms) Intersection of quadrics with lines provides at most two intersection points. Can solve intersection of quadrics with a ray by reducing problem to solving a quadratic equation.

9 Parametric Curves Separate equation for each spatial variable in terms of an independent variable/parameter (u). x=x(u) y=y(u) z=z(u) For u max  u  u min we trace out a curve in two or three dimensions: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 9 Locus of points: p(u)=[x(u), y(u), z(u)] T p(u) p(u min ) p(u max )

10 Selecting Functions Usually we can select “good” functions: – Not unique for a given spatial curve. – Approximate or interpolate known data. – Want functions that are easy to evaluate. – Want functions that are easy to differentiate: Computation of normals. Connecting pieces (segments). – Want functions that are smooth. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 10

11 Parametric Lines E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 11 p(u)=(1-u)p 0 +up 1 We can normalize u to be over the interval (0,1). Line connecting two points p 0 and p 1 : Ray from p 0 in the direction d: p(0) = p 0 p(1)= p 1 p(u)=p 0 +ud p(0) = p 0 p(1)= p 0 +d d

12 Parametric Surfaces Surfaces require 2 parameters: x=x(u,v) y=y(u,v) z=z(u,v) p(u,v) = [x(u,v), y(u,v), z(u,v)] T Want same properties as curves: – Smoothness. – Differentiability. – Ease of evaluation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 12 x y z p(u,0) p(1,v) p(0,v) p(u,1)

13 Surface Normals We can differentiate with respect to u and v to obtain the normal at any point p. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 13

14 Parametric Planes E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 14 Point-vector form: p(u,v)=p 0 +uq+vr n = q x r Three-point form: q r p0p0 n p0p0 n p1p1 p2p2 q = p 1 – p 0 r = p 2 – p 0

15 Parametric Sphere E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 15 x(u,v) = r cos  sin  y(u,v) = r sin  sin  z(u,v) = r cos  360    0 180    0  constant: circles of constant longitude.  constant: circles of constant latitude. differentiate to show n = p

16 Curve Segments After normalizing u, each curve is written as: p(u)=[x(u), y(u), z(u)] T, 1  u  0 Classical numerical methods design a single global curve. In computer graphics and CAD, it is better to design small connected curve segments. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 16 p(u) q(u) p(0) q(1) join point p(1) = q(0)

17 Parametric Polynomial Curves E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 17 If N=M=K, we need to determine 3(N+1) coefficients. Equivalently we need 3(N+1) independent conditions. Noting that the curves for x, y and z are independent, we can define each independently in an identical manner. We will use the form where p can be any of x, y, z:

18 Why Polynomials? Easy to evaluate. Continuous and differentiable everywhere: – Must worry about continuity at join points including continuity of derivatives. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 18 p(u) q(u) join point p(1) = q(0) but p’(1)  q’(0)

19 Cubic Parametric Polynomials N=M=L=3, balances ease of evaluation and flexibility in design: Four coefficients to determine for each of x, y and z. Seek four independent conditions for various values of u resulting in 4 equations in 4 unknowns for each of x, y and z. – Conditions are a mixture of continuity requirements at the join points and conditions for fitting the data. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 19

20 Cubic Polynomial Surfaces E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 20 General equations are of the form: where: p is any of x, y or z. Need 48 coefficients (3 independent sets of 16) to determine a surface patch. p(u,v)=[x(u,v), y(u,v), z(u,v)] T

21 Objectives Introduce the types of curves: – Interpolating. – Hermite. – Bezier. – B-splines. Analyze their performance. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 21

22 Design Criteria Criteria for designing parametric polynomials: – Local control of shape. – Smoothness and continuity. – Ability to evaluate derivatives. – Stability. – Ease of rendering. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 22

23 Matrix-Vector Form E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 23 Define Then

24 Interpolating Curve E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 24 p0p0 p1p1 p2p2 p3p3 Cubic interpolating polynomial: an example of the cubic parametric polynomial. Given four data (control) points p 0, p 1,p 2, p 3 determine cubic p(u) which passes through them. Must find: c 0,c 1,c 2, c 3

25 Interpolation Equations E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 25 Apply the interpolating conditions at u=0, 1/3, 2/3, 1. p 0 = p(0) = c 0 p 1 = p(1/3) = c 0 +(1/3)c 1 +(1/3) 2 c 2 +(1/3) 3 c 2 p 2 = p(2/3) = c 0 +(2/3)c 1 +(2/3) 2 c 2 +(2/3) 3 c 2 p 3 = p(1) = c 0 +c 1 +c 2 +c 3 or in matrix form with p = [p 0 p 1 p 2 p 3 ] T p=Ac

26 Interpolation Matrix E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 26 Solving for c we find the interpolation matrix: Note that M I does not depend on input data and can be used for each segment in x, y, and z. c=MIpc=MIp

27 Interpolating Multiple Segments E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 27 use p = [p 0 p 1 p 2 p 3 ] T use p = [p 3 p 4 p 5 p 6 ] T Derive a set of cubic interpolating curves, each specified with four control points. Get C 0 continuity at join points but not C 1 continuity of derivatives!

28 Blending Functions E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 28 Study smoothness of interpolating polynomial curves by rewriting the equation for p(u): p(u) = u T c = u T M I p = b(u) T p where b(u) = [b 0 (u) b 1 (u) b 2 (u) b 3 (u)] T is an array of blending polynomials such that: p(u) = b 0 (u)p 0 + b 1 (u)p 1 + b 2 (u)p 2 + b 3 (u)p 3 b 0 (u) = -4.5(u-1/3)(u-2/3)(u-1) b 1 (u) = 13.5u (u-2/3)(u-1) b 2 (u) = -13.5u (u-1/3)(u-1) b 3 (u) = 4.5u (u-1/3)(u-2/3)

29 Blending Functions These functions are not smooth: – Hence the interpolation polynomial is not smooth! – Lack of smoothness because curves have to pass through control points. – More pronounced for higher degree polynomials. – Also lack derivative continuity at joint points. – Limited use in CG applications. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 29

30 Cubic Interpolating Patch E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 30 Need 16 conditions to determine the 16 coefficients c ij Choose at u, v = 0, 1/3, 2/3, 1

31 Matrix Form E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 31 Define v = [1 v v 2 v 3 ] T C = [c ij ] P = [p ij ] p(u,v) = u T Cv If we observe that for constant u (v), we obtain interpolating curve in v (u), we can show: C=M I PM I p(u,v) = u T M I PM I T v

32 Blending Patches E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 32 Each b i (u)b j (v) is a blending patch. We can therefore build and analyze surfaces from our knowledge of curves.

33 Other Types of Curves and Surfaces How to get around the limitations of the interpolating form? – Lack of smoothness. – Discontinuous derivatives at join points. We have four conditions (for cubics) applied to each segment: – Use them other than for interpolation. – Need only come close to the data! E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 33

34 Hermite Form E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 34 p(0)p(1) p’(0) p’(1) Use two interpolating conditions and two derivative conditions per segment. Ensures continuity and first derivative continuity between segments.

35 Equations E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 35 Interpolating conditions are the same at ends: p(0) = p 0 = c 0 p(1) = p 3 = c 0 +c 1 +c 2 +c 3 Differentiating we find p’(u) = c 1 +2uc 2 +3u 2 c 3. Evaluating at end points: p’(0) = p’ 0 = c 1 p’(1) = p’ 3 = c 1 +2c 2 +3c 3

36 Matrix Form E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 36 Solving, we find c = M H q where M H is the Hermite matrix.

37 Blending Polynomials E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 37 p(u) = b(u) T q These functions are smooth, but the Hermite form is not used directly in Computer Graphics and CAD. We usually have control points but not derivatives. However, the Hermite form is the basis of the Bezier form.

38 Parametric and Geometric Continuity We can require the derivatives of x, y and z to be continuous at join points (C 0 and C 1 parametric continuity). Alternately, we can only require that the tangents of the resulting curve be continuous, i.e., proportional but different magnitudes (G 1 geometry continuity). The latter gives more flexibility as we have need satisfy only two conditions rather than three at each join point. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 38

39 Example Here the p and q have the same tangents at the ends of the segment. Curves have different derivatives (same direction, different magnitude). Generate different Hermite curves. This techniques is used in drawing applications. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 39

40 Higher Dimensional Approximations The techniques for both interpolating and Hermite curves can be used with higher dimensional parametric polynomials. For interpolating form, the resulting matrix becomes increasingly more ill- conditioned and the resulting curves less smooth and more prone to numerical errors. In both cases, there is more work in rendering the resulting polynomial curves and surfaces. E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 40


Download ppt "Chapter 10: Curves and Surfaces Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 1 Mohan Sridharan Based on Slides."

Similar presentations


Ads by Google