Download presentation
Presentation is loading. Please wait.
Published bySabrina White Modified over 9 years ago
1
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
2
Designing Parametric Cubic Curves Ed Angel Professor Emeritus of Computer Science University of New Mexico 2 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
3
3 Objectives Introduce the types of curves Interpolating Hermite Bezier B-spline Analyze their performance Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
4
4 Matrix-Vector Form define then Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
5
5 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 There are 3 equations…
6
6 Interpolating Curve p0p0 p1p1 p2p2 p3p3 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 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
7
7 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Interpolating Curve http://terpconnect.umd.edu/~petersd/interp.html (select « Polynomial » or « Cubic spline »)
8
8 Interpolation Equations apply the interpolating conditions at u=0, 1/3, 2/3, 1 These equations can be written in matrix form using p = [p 0 p 1 p 2 p 3 ] T p=Ac Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 p 0 =p(0)= c 0 + (0)c 1 + (0) 2 c 2 + (0) 3 c 3 p 1 =p(1/3)=c 0 +(1/3)c 1 +(1/3) 2 c 2 +(1/3) 3 c 3 p 2 =p(2/3)=c 0 +(2/3)c 1 +(2/3) 2 c 2 +(2/3) 3 c 3 p 3 =p(1)= c 0 + (1)c 1 + (1)c 2 + (1)c 3 where
9
9 Interpolation Matrix Solving for c we find the interpolation matrix c=MIpc=MIp Note that M I does not depend on input data and can be used for each segment in x, y, and z Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
10
10 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Computing the constants… One can compute C y and C z using the y and z components of the control points (p).
11
11 Interpolating Multiple Segments use p = [p 0 p 1 p 2 p 3 ] T use p = [p 3 p 4 p 5 p 6 ] T Get continuity at join points but not continuity of derivatives Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
12
12 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Blending Functions 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)
13
13 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Practical example If p 0 =(0,4,8) p 1 =(1,5,9) p 2 =(2,6,10) and p 3 =(3,7,11), find p(u=0.2) if an interpolation curve is used. The blending polynomials for interpolation are : b 0 (u) = -4.5(u-1/3)(u-2/3)(u-1) = -4.5(0.2-1/3)(0.2-2/3)(0.2-1) = 0.224 b 1 (u) = 13.5u (u-2/3)(u-1) = 13.5x0.2 (0.2-2/3)(0.2-1) = 1.008 b 2 (u) = -13.5u (u-1/3)(u-1) = -13.5x0.2 (0.2-1/3)(0.2-1) = -0,288 b 3 (u) = 4.5u (u-1/3)(u-2/3) = 4.5x0.2 (0.2-1/3)(0.2-2/3) = 0.056 Using those four values : p(u) = b 0 (u)p 0 + b 1 (u)p 1 + b 2 (u)p 2 + b 3 (u)p 3 p(u) = 0.224 p 0 + 1.008 p 1 - 0.288 p 2 + 0.056 p 3
14
14 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Practical example Therefore, we can compute p x (u=0.2) p x (u=0.2) = b 0 (u=0.2)p x0 + b 1 (u=0.2)p x1 + b 2 (u=0.2)p x2 + b 3 (u=0.2)p x3 p x (u=0.2) = 0.224 (0) + 1.008 (1) - 0.288 (2) + 0.056 (3) p x (u=0.2) = 0.6 Similarly, we can compute p y (u=0.2) p y (u=0.2) = b 0 (u=0.2)p y0 + b 1 (u=0.2)p y1 + b 2 (u=0.2)p y2 + b 3 (u=0.2)p y3 p y (u=0.2) = 0.224 (4) + 1.008 (5) - 0.288 (6) + 0.056 (7) p y (u=0.2) = 4.6 and p z (u=0.2) p z (u=0.2) = b 0 (u=0.2)p z0 + b 1 (u=0.2)p z1 + b 2 (u=0.2)p z2 + b 3 (u=0.2)p z3 p z (u=0.2) = 0.224 (8) + 1.008 (9) - 0.288 (10) + 0.056 (11) p z (u=0.2) = 8.6
15
15 Blending Functions These functions are not smooth (if we follow b 3, then b 2, then b 1 and b 0, there are discontinuities) Hence the interpolation polynomial is not smooth Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
16
16 Interpolating Patch Need 16 conditions to determine the 16 coefficients c ij Choose points at u,v = 0, 1/3, 2/3, 1 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
17
17 Matrix Form 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 So, we can write p(u,v) = u T M I PM I T v Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 C = M I PM I T (note: there was an error in original slide)
18
18 Blending Patches Each b i (u)b j (v) is a blending patch Shows that we can build and analyze surfaces from our knowledge of curves Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
19
19 Other Types of Curves and Surfaces How can we get around the limitations of the interpolating form ? Lack of smoothness Discontinuous derivatives at join points We have four conditions (for cubics) that we can apply to each segment Use them other than for interpolation Need only come close to the data Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
20
20 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Hermite Form (named after Charles Hermite – french mathematician)Charles Hermite 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
21
21 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Equations Interpolating conditions are the same at ends p(u=0) = p 0 = c 0 +0c 1 +0c 2 +0c 3 p(u=1) = p 3 = c 0 +c 1 +c 2 +c 3 Differentiating p(u), we find p’(u) = c 1 +2uc 2 +3u 2 c 3 Evaluating at end points (i.e. at u=0 and u=1) p’(u=0) = p’ 0 = c 1 p’(u=1) = p’ 3 = c 1 +2c 2 +3c 3
22
22 Matrix Form Solving, we find c=M H q where M H is the Hermite matrix Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
23
23 Blending Polynomials Although these functions are smooth, the Hermite form is not used directly in Computer Graphics and CAD because we usually have control points but not derivatives However, the Hermite form is the basis of the Bezier form Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 p(u) = u T c = u T M H q = b H (u) T q
24
24 (Parametric and Geometric Continuity) We can require the derivatives of x, y,and z to each be continuous at join points (parametric continuity) Alternately, we can only require that the tangents of the resulting curve be continuous (geometry continuity) The latter gives more flexibility as we have need satisfy only two conditions rather than three at each join point Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
25
25 (Example) Here the p and q have the same tangents at the ends of the segment but different derivatives Generate different Hermite curves This techniques is used in drawing applications Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
26
26 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.