Computer Science - Semantic Scholar

Report 0 Downloads 257 Views
Curve and Surface Interpolation and Approximation: Knowledge Unit and Software Tool Yan Zhou and Ching-Kuang Sheney Department of Computer Science Michigan Technological University Houghton, MI 49931{1295 Email: fyzhou,[email protected] 1 Motivation Curve and surface construction is an important topic in computer graphics, computer-aided design, geometric modeling and visualization courses. In addition to Bezier, B-spline and NURBS, interpolation/approximation provides another level of sophistication. In many situations such as surface reengineering and facial movement animation, a designer may specify a set of data points that describes a desired shape (e.g., the head of a dinosaur model) through laser probing or scanning, and obtain a surface that contains all data points (i.e., interpolation). Interpolation is also important in computer animation. An animator may specify a number of key camera positions and orientations (i.e., keyframes), interpolate these positions with a B-spline curve (i.e., camera path), and interpolate the keyframes with additional frames. While interpolation can produce a curve/surface that follows the shape of the data points, it may oscillate or wiggle its way through every point. Approximation can overcome this problem so that the curve/surface still captures the shape of the data points without containing all of them. It is dicult to teach this powerful and useful skill in an undergraduate course because of its formidable mathematics. However, with our tool DesignMentor [2, 3, 4], we are able to cover interpolation and approximation in a junior course. This paper presents our approach in a way that is very close to what we are doing in classroom. This work was partially supported by the National Science Foundation under grants DUE-9653244 and DUE9952621, and by a grant from the Michigan Research Excellence Fund 1998{1999. y Corresponding author. 

2 Course Structure and Design Merit Curve and surface interpolation/approximation is a knowledge unit in a junior level course Computing with Geometry [1] for students in computer science, mathematics and engineering. Students rst learn the way of approaching geometric problems, followed by the representations and algorithms for curves, surfaces, and solids, including Bezier, B-spline, and NURBS curves and surfaces [2, 4]. This is followed by cross-sectional design [3]. Interpolation and approximation normally takes more than two weeks near the end of a semester. This course is taught in a computer-equipped classroom and DesignMentor is always used in class for students to practice and visualize important properties. In this way, students are built up gradually and the formidable mathematics is hidden within DesignMentor. The topics covered include parameter selection, global and local interpolations, global approximation, and curve network interpolation. The reasons of selecting these topics are (1) they are the most fundamental ones; (2) they are simple enough for students who have acquired knowledge in B-spline curves, calculus and linear algebra to learn and practice; and (3) they are the most widely used topics and can be found in computer graphics, geometric modeling, computer vision, and visualization textbooks, and in all good graphics systems. We do not ask students to master the algebraic derivations. Instead, we expect our students to be aware of the existence of this technology, to understand the fundamentals and algorithms, to be able to write programs based on existing algorithms, and to recognize the advantages and disadvantages of various methods. To this end, materials are introduced in an intuitive and learning-by-doing way with an emphasis on experimenting and visualizing important concepts and algorithms. Students will see the e ect of each algorithm, compare di erent algorithms without the formidable mathematics, and practice design skills. Consequently, learning interpolation/approximation is no more a dicult task.

3 What Are the Di erences? Students who know numerical methods frequently expect a comparison between the interpolation methods they have learned (e.g., Lagrange's method) and the B-spline methods. Here is our answer. First, traditional methods use a polynomial y = p(x) and any two data points cannot have equal x-coordinates; however, B-splines use a parametric form. Second, in traditional methods the degree of the interpolating polynomial is determined by the number of data points, whereas the degree of an interpolating B-spline is an input, permitting the use of lower degree curves/surfaces (e.g., 2 or 3). Third, the input to traditional methods is a set of points (xi ; yi), where xi is the parameter value corresponding to yi , whereas the B-spline case only requires a set of points. Fourth, traditional methods are global in the sense that changing the position of a data point a ects the whole curve. However, local B-spline interpolation restricts the impact to the vicinity of that point. 4 It All Begins with a Set of Good Parameters Given a set of m + 1 data points Dk (0  k  m) and a degree p, we seek a B-spline curve C(u) that passes through all given points. A set of parameters t0 = 0  t1  : : :  tm = 1 has to be found so that the interpolating curve can be \ xed" at these values (i.e., Dk = C(tk ) for all 0  k  m). See Figure 1(a). D2 D3

D1

D4 D0

ated from the chosen parameters. In class, with the help of DesignMentor, we ask students to specify data points, choose a parameter computation method, generate an interpolating B-spline, and compare the results. Thus, they can quickly learn the importance of parameter and its impact on the curve before they learn interpolation algorithms!

5 Global Interpolation The rst and the simplest method is the global interpolation. Since the degree p is an input and the knot vector is computed from the selected parameters tk 's, the only missing part for the interpolating B-spline curve is m + 1 control points. Let these unknown control points be PiP(0m  i  m), and let the B-spline curve be C(u) = i=0 Ni;p (u)Pi, where Ni;p (u) is the i-th B-spline basis function of degree p. Hence, we have Dk

t1

t2

t3

t4 t 5

(a) Concept

Dk;l

(b) E ects

Figure 1: Parameter Selection Four methods are presented in class: equidistant, centripetal, chord-length, and universal. Each method has its own convincing merit and drawbacks, and the resulting B-splines may be very di erent. In Figure 1(b), the curves with dark and light colors are computed with the equidistant and centripetal methods, while the other is obtained with the chord-length method. We pay special attention to the latter because it is easy to understand and perform well when there is no better alternatives. In this method, the total length of the data polygon is computed and the domain [0,1] of the interpolating Bspline curve is subdivided according to the ratio of the distance P from D0 to Dk . That is, tk = dk =dm, where dj = ji=1 jDi ; Di;1j. Then, a knot vector is gener-

m X i=0

Ni;p (tk )Pi

for all 0  k  m

Let N = [Ni;p(tk )](m+1)(m+1) , D = [Dk](m+1)1 and P = [Pi](m+1)1 . Then, the above equation becomes D = N  P. Since D and N are known, solving for P yields an interpolating B-spline curve of degree p. The surface case is based on the curve one. Given a grid of data points Dk;l (0  k  m and 0  l  n) and degrees p and q, we seek a B-spline surface S(u; v) of degree (p; q) such that Dk;l = S(sk ; tl ) for 0  k  m and 0  l  n, where sk 's and tl 's are the chosen parameter values. Thus, we have

D5 t0

= C(tk ) =

= S(sk ; tl ) =

m X n X i=0 j =0

Ni;p (sk )Nj;q (tl )Pi;j

where Pi;j 's (0  i  m and 0  j  n) are unknown control points. The above can be rewritten as follows: Dk;l

=

m X i=0

2 3 n m X X 4 5 Ni;p (sk ) Nj;q (tl )Pi;j = Ni;p (sk )Ri;l j =0

where Ri;l

=

n X j =0

i=0

Nj;q (tl )Pi;j

Therefore, we can solve for Ri;l 's from the rst equation, and Pi;j 's from the second once Ri;l 's are available. Hence, a global interpolating B-spline surface is computed by applying the curve interpolation algorithm twice! Figure 2 shows interpolating a 5  6 grid with a B-spline surface of degree (3,3).

(a) Isoparametric Lines(b) Rendered Surface

(a) Curves

(b) Surface

Figure 2: Global Interpolation

Figure 4: Local Interpolation Construction

While changing the position of a control point of a Bspline curve only a ects part of the curve, changing the position of a data point a ects the whole curve. Figure 3 shows the impact of changing the position of the marked data point. The neighborhood of that data point is changed drastically, and the impact even propagates to the right as shown by the isoparametric lines.

After all necessary control points are constructed, we have a number of Bezier surfaces joining together with C 1-continuity. The desired B-spline surface is obtained by removing control points along common boundaries. Figure 5 shows the result of applying local interpolation to the same data points used for global interpolation.

(a) Isoparametric Lines(b) Rendered Surface

Figure 3: Changing the Position of a Data Point In class, students use DesignMentor to create curves and surfaces with di erent parameters, and visualize the impact of changing the position of a data point. DesignMentor also helps students understand the meaning and drawbacks of \global" interpolation.

6 Local Interpolation Local interpolation techniques are introduced to overcome the unpleasant result in Figure 3 and other problems. Consider the curve case rst. Given m + 1 data points Dk (0  k  m), a Bezier curve of degree 3 is constructed for each pair of adjacent data points such that two adjacent Bezier curves are joined with C 1 continuity. Since we only know the two end-points, two internal control points must be found. In Figure 4(a), the four dots are the given data points, while the squares are the constructed internal control points. The surface case is more involved. A Bezier surface of degree (3; 3) requires 16 control points as shown in Figure 4(b). From any four corner data points, eight \border" control points are constructed (dots) as in the curve case. The four internal control points (squares) are computed from the given data points and the \border" control points. Since the theory is too complex, only a computation scheme is discussed in class.

(a) Isoparametric Lines (b) Rendered Surface

Figure 5: Local Interpolation In general, results from local and global interpolations are not very di erent. The real advantage of using local interpolation is for local control. Figure 6 is the result of changing the position of the marked point. The impact is not so drastic as shown in Figure 3(a). Moreover, local interpolation does not produce a large bulge, and the right-end of the surface seems una ected.

(a) Isoparametric Lines (b) Rendered Surface

Figure 6: Changing the Position of a Data Point In class, we start with the drawbacks of global interpolation as a motivation for local interpolation. DesignMentor is used to show the construction of local interpolation, and to demonstrate the local control property. Since this topic is more dicult than the others, we only ask students to interpolate three points by hand calculation to reinforce their understanding, and compare the di erences between global and local interpolations.

7 Global Approximation In many applications, requiring a curve/surface to contain all data points may be too restrictive, and a curve/surface that can follow the trend closely may be sucient. This leads to the discussion of global approximation. Given a set of m+1 data points Dk and a degree p, we seek a B-spline curve C(u) of degree p that approximates the data points in the P least square sense. Let this B-spline curve be C(u) = ni=0 Ni;p (u)Pi , where n is a user selectable value and Pi's are n + 1 unknown control points. For each parameter tk , jC(tk ) ; Dk j is the distance between the \computed" point and the actual point. A good approximation method should minimize the sum of squared \error" distances: f(P1 ; : : :; Pn) =

m X k=0

jC(tk ) ; Dk j2

Those Pi 's that make the above function to reach its minimum are the desired control points. To ensure a unique solution for the control points, we set D0 = P0 and Dm = Pn (i.e., clamped). Then, computing and setting partial derivatives to 0's yields a system of linear equations whose solution is the desired result. The surface case is similar. Given a set of (m+1)(n+1) data points Dk;l (0  k  m and 0  l  n) and a desired degree (p; q), we seek a B-spline surface S(u; v) that approximates the Dk;l's in the sense of least square. More precisely, nd a set of control points Pi;j (0  i  e and 0  j  f) such that the following is minimized, f(Pi;j ) =

m X n X k=0 l=0

jS(sk ; tl ) ; Dk;l j2

where e and f are user selectable values, and sk 's and tl 's are parameters. A simpli ed method is presented in class. Curve approximation is applied to each column l of Dk;l (0  k  m) to obtained a set of (e+1)  (n+1) \intermediate" control points Ri;l (0  i  e). Then, curve approximation is applied again to each row i of Ri;l 's to obtain the nal control points Pi;j (0  j  f). Thus, an approximating B-spline surface is constructed using (n+1)+(m+1) curve approximations. Although the resulting surface may not be optimal, it is simple enough for students to understand and implement. Figure 7 is the result of applying surface approximation to the same data points used before. The surface does not contain all points, and looks \smoother" than those constructed with global and local methods. This approximation method is also global, but the impact of changing the position of a point is not as drastic as that of global interpolation (Figure 8).

(a) Isoparametric Lines (b) Rendered Surface

Figure 7: Approximation

(a) Isoparametric Lines (b) Rendered Surface

Figure 8: Changing the Position of a Data Point Just like the global interpolation case, students are asked to interpolate and approximate the same set of data point, compare the di erence to see the impact of relaxing the requirement of \passing every point," and visualize the \global" impact of moving one data point.

8 Curve Network Interpolation Sometimes designers may prefer to use a curve network rather than a set of data points. A curve network consists of two families of B-spline curves, Fk (u) (0  k  K) and Gl (v) (0  l  L) such that the intersection of two curves, one from each family, consists of exactly one point (Figure 9(a)). Let Dl;k = Fk (ul ) \ Gl (vk ) for some ul and vk . An interpolating surface for this curve network is a B-spline surface S(u; v) such that Fk (u)'s are isoparametric curves in one direction (i.e., S(u; vk) = Fk (u)) and Gl (v)'s are isoparametric curves in the other (i.e., S(ul ; v) = Gl (v)).

(a) Network

(b) Lines

(c) Surface

Figure 9: Gordon Surfaces Gordon's elegant solution to this problem is discussed in class. It consists of three simpler surfaces. The rst S1(u; v) contains all Gl (v)'s, the second S2(u; v) contains all Fk (u)'s, and the third S3(u; v) contains all in-

tersection points. The rst two are skinned surfaces that can be constructed with the skinning technique [3], which is discussed before interpolation and approximation. The third one can be constructed with global or local interpolation. Then, the desired surface is simply S(u; v) = S1 (u; v) + S2(u; v) ; S3 (u; v). Note that there are an in nite number of surfaces that contain the given curve network, and the constructed Gordon surface is only a possible, maybe non-optimal, solution. Figure 9(b) and (c) are the constructed Gordon surface in isoparametric and rendered forms, respectively. Students may be asked to use DesignMentor to design a curve network, and interpolate it with a Gordon surface using their own implementation. The curve network may be extracted from a set of isoparametric curves of a B-spline surface. Then, students are asked to compare the constructed Gordon surface with the original using a \goodness-of- t" measure. In this way, students not only practice curve network design, but also learn to investigate the concept of goodness-of- t to determine if the resulting surface is good enough.

9 A Mini-Project Since interpolation/approximation is a dicult topic, it normally takes more than two weeks to cover the materials to certain depth. To make sure students have learned the subject, we gave them a comprehensive and challenging two-week mini-project. They are provided with a linear equation solver and a scaled-down version of DesignMentor for implementing global interpolation and approximation using di erent parameters from a pre-de ned menu (Figure 10(a)). Also, they must use de Boor's algorithm to trace the surface and display the de Boor net correctly. Figure 10(b) and (c) show a sample screen shot of a typical student program.

(a) Menu

(b) Interpolation (c) Approximation

Figure 10: Surface Interpolation and Approximation

10 Experience This course is evaluated with pre- and post- tests. Students were asked the same set of 22 questions to assess their understanding of course topics in a scale from 0 (none) to 4 (excellent). Two questions are about curve

and surface interpolation/approximation. The curve (resp., surface) question has pre- and post- test averages 0.7 and 1.9 (resp., 0.5 and 2) with standard deviations 0.7 and 0.8 (resp., 0.6 and 0.8). The KomogorovSmirnov test shows that the di erence between pre- and post- test is signi cant. Thus, students did learn interpolation and approximation. The gain is smaller in the curve case because students thought this topic is similar to what they learned in a numerical methods class and rated themselves higher in the pre-test. We did not expect a large gain because this is a dicult topic. Judged by exam scores and the mini-project, we are con dent that our students did know how to implement global interpolation and approximation provided proper tools are given. This is exactly our expectation. Even more encouraging is that many students felt that doing such a challenging project will improve their programming skills and the understanding of the subject.

11 Conclusions We have presented course content, a project, and the use of DesignMentor for teaching important concepts, algorithms, and design skills in interpolation and approximation. Combined with our web-based text, students not only learn the fundamentals in an intuitive way, but also practice design skills interactively. We will continually develop DesignMentor into a full featured system in the near future. The interested readers may nd more about our work, including our electronic book, user guides, DesignMentor and other tools, and future announcements, at the following site: http://www.cs.mtu.edu/~shene/NSF-2

References [1] J. L. Lowther and C.-K. Shene, Computing with Geometry as an Undergraduate Course: A Three-Year Experience, The Thirty-second SIGCSE Technical Symposium, 2001, pp. 119{123. [2] Y. Zhao, J. L. Lowther and C.-K. Shene, A Tool for Teaching Curve Design, The Twenty-ninth SIGCSE Technical Symposium, 1998, pp. 97{101. [3] Y. Zhao, Y. Zhou, J. L. Lowther and C.-K. Shene, Cross-Sectional Design: A Tool for Computer Graphics and Computer-Aided Design Courses, ASEE/IEEE Frontiers in Education, Vol. II (1999), pp. (12b3-1){(12b3-6). [4] Y. Zhou, Y. Zhao, J. L. Lowther and C.-K. Shene, Teaching Surface Design Made Easy, The Thirtieth SIGCSE Technical Symposium, 1999, pp. 222{226.