GOSPR 5/5/2005 5:47 PM Page i

Computer Graphics and Geometric Modeling GOSPR 5/5/2005 5:47 PM Page iii

Max K. Agoston Computer Graphics and Geometric Modeling

Implementation and Algorithms GOSPR 5/5/2005 5:47 PM Page iv

Max K. Agoston, MA, MS, PhD Cupertino, CA 95014, USA

British Library Cataloguing in Publication Data Agoston, Max K. Computer graphics and geometric modeling:implementation & algorithms 1. Computer graphics 2. Geometry—Data processing 3. Computer-aided design 4. Computer graphics—Mathematics I. Title 006.6 ISBN 1852338180

Library of Congress Cataloging-in-Publication Data

Agoston, Max K. Computer graphics & geometric modeling/Max K. Agoston. p. cm. Includes bibliographical references and index. Contents: Implementation & algorithms ISBN 1-85233-818-0 (v. 1 : alk. paper) 1. Computer graphics. 2. Geometry—Data processing. 3. Mathematical models. 4. CAD/CAM systems. I. Title.

T385.A395 2004 006.6—dc22 2004049155

Apart from any fair dealing for the purposes of research or private study, or criticism or review, as per- mitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers.

ISBN 1-85233-818-0 Springer is part of Springer Science+Business Media springeronline.com

© Springer-Verlag London Limited 2005 Printed in the United States of America

The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use.

The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made.

Typesetting: SNP Best-set Typesetter Ltd., Hong Kong 34/3830-543210 Printed on acid-free paper SPIN 10971451 GOSPR 5/5/2005 5:47 PM Page v

Preface

This book and [AgoM05] grew out of notes used to teach various types of computer graphics courses over a period of about 20 years. Having retired after a lifetime of teaching and research in mathematics and computer science, I finally had the time to finish these books. The two books together present a comprehensive overview of com- puter graphics as seen in the context of geometric modeling and the mathematics that is required to understand the material. Computer graphics itself is a multifaceted subject, but it has grown up. It is no longer necessary that a book on graphics demon- strate the diversity of the subject with a long list of “fun” projects at the expense of the mathematics. From movies, television, and other areas of everyday life, readers have already seen what graphics is about and what it can do. It follows that one should be able to present the geometric modeling aspect of the subject in a systematic fashion. Unfortunately, the sheer amount of material that I wanted to cover meant that it had to be divided into two parts. This book contains the practical stuff and describes the various algorithms and implementation issues that one runs into when writing a geometric modeling program. The book [AgoM05] provides the mathemat- ical background for the underlying theory. Although each book can be read by itself without reading the other, one will get the most benefit from them if they are read in parallel. The intended audience of this book (and the combined two volumes especially) is quite broad. It can be used in a variety of computer graphics courses or by those who are trying to learn about graphics and geometric modeling on their own. In particu- lar, it is for those who are getting involved in what is referred to as computer-aided design (CAD) or computer-aided (CAGD), but it is also for mathe- maticians who might want to use computers to study geometry and topology. Both modeling and rendering issues are covered, but the emphasis is on the former. The basic prerequisites are that the reader has had an upper division data structure course, minimally three semesters of calculus, and a course on linear algebra. An additional course on advanced calculus and modern algebra would be ideal for some of the more advanced topics. On the companion CD there is a geometric modeling program (GM) that implements many of the algorithms discussed in the text and is intended to provide a programming environment both for further experimentation and applica- tion development. Another program (SPACE) on the CD is an application that uses some of the more advanced geometric modeling concepts to display the intrinsic GOSPR 5/5/2005 5:47 PM Page vi

vi Preface

geometry of two- and three-dimensional manifolds. Both programs were written using the Microsoft Visual C++ compiler (and OpenGL) and run under Microsoft Windows 98 or later. Their source code and documentation are included on the CD. The ReadMe file on the CD lists what all is on the CD and also contains instructions for how to use what is there. As I began to develop this book on geometric modeling, one concern obviously was to do a good job in presenting a thorough overview of the practical side of the subject, that is, the algorithms and their implementation details. However, there were two other goals that were important from the very beginning. One was to thoroughly explain the mathematics and the other, to make the material as self-contained as pos- sible. In other words, pretty much every technical term or concept that is used should be defined and explained. The reason for putting all the computer graphics–related material into one book and all the mathematics into the other rather than inter- weaving the material was to keep the structure of the implementation of a modeling program as clear as possible. Furthermore, by separating out the mathematics it is easier for readers to skip those mathematical topics that they are already familiar with and concentrate on those with which they are not. In general, though, and in partic- ular as far as instructors using this book are concerned, the intent is that the mate- rial in the two books be covered in parallel. This is certainly how I always taught my courses. An added motivation for the given division was that the applied part of geo- metric modeling was often a moving target because, largely due to improvements in hardware (faster CPUs, more memory, more hard disk space, better display devices), the way that one deals with it is changing and will continue to change in the future. This is in contrast to the supporting mathematics. There may be new mathematics relevant to computer graphics in the future but it will be a long time before the math- ematics I do discuss will lose its relevance. A lot of it, in fact, is only now starting to be used as hardware becomes capable of dealing with computationally expensive algorithms. One property that sets this book apart from others on geometric modeling is its breadth of coverage, but there is another. The combined books, this one and [AgoM05], differ from other books on computer graphics or geometric modeling in an important way. Some books concentrate on implementation and basically add the relevant mathematics by tossing in appropriate formulas or mathematical algorithms. Others concentrate on some of the mathematical aspects. I attempt to be as compre- hensive on both the implementation and theory side. In [AgoM05] I provide a com- plete reference for all the relevant mathematics, but not in a cookbook fashion. A fundamental guiding principle was to present the mathematics in such a way that the reader will see the motivation for it and understand it. I was aiming at those indi- viduals who will want to take the subject further in the future and this is not possi- ble without such understanding. Just learning a few formulas is not good enough. I have always been frustrated by books that throw the reader some formulas without explaining them. Furthermore, the more mathematics that one knows, the less likely it is that one will end up reinventing something. There are instances (such as in the case of the term “geometric continuity”) where unfamiliarity with what was known caused the introduction of confusing or redundant terminology. The success or failure of the two books should be judged on how much understanding of the mathematics and algorithms the reader gets. In the case of this book by itself, it is a question of whether or not the major topics were covered adequately. In any case, because I GOSPR 5/5/2005 5:47 PM Page vii

Preface vii

emphasize understanding what is going on, there is a natural emphasis on theory and not on tricks of the trade. The reader will also not find any beautiful glossy pictures. Clearly, no one book can cover all that falls under the general heading of geo- metric modeling. As usual, the topics that are in fact covered and the degree to which they are covered reflect my own bias. In a large field, there are many special topics and it should not be surprising that some are not discussed at all and others only briefly in an overview. On the other hand, one would expect to see a discussion of principles and issues that are basic to the field as a whole. In that regard, I would like to alert the reader to one topic, namely, the issue of robustness of algorithms and com- putations, that really is a central issue in geometric modeling, but is not dealt with as thoroughly as it should be, given its importance. The only excuse for this is that to do this topic justice would have entailed a much larger book. It is important that readers who want to do serious work in geometric modeling realize that they will have to get more information elsewhere on this. The discussion in Section 5.10 is inade- quate (although I do devote the brief Chapter 18 to interval analysis). When it comes to the bibliography, as large as it is, it is also a victim of space constraints. In some cases I have tried to compensate for the lack of completeness by giving references to books or papers where additional references could be found. Most of this book covers material that is not new, but a few algorithms have not appeared in print before. One is the approach to trimmed surfaces based on the Vatti clipping algorithm described in Section 14.4. Another is the result in Section 17.5 about convex set intersections, which motivated the algorithm described in Section 13.2. Another aspect of the book that should be noted is Chapter 16 and the SPACE program. Although the material on intrinsic geometry in Sections 16.3 and 16.4 did not get developed as much as I would have liked, it is a start. The extensive material on topology in [AgoM05], in particular algebraic and differential topology, has hereto- fore not been found in books on geometric modeling. Although this subject is slowly entering the field, its coming has been slow. Probably the two main reasons for this are that computers are only now getting to be powerful enough to be able to handle the complicated computations and the material involves exceptionally advanced mathematics that even mathematics majors would normally not see until graduate school. Here is how the material in this book has been used successfully in teaching three different types of semester courses on computer graphics in the Department of Math- ematics and Computer Science at San Jose State University. The courses were

(1) Introduction to Computer Graphics, (2) Computer Graphics Algorithms, and (3) Geometric Modeling.

The first two were upper-division undergraduate courses and the third was a gradu- ate course. The prerequisites for the introductory course were three semesters of calculus, linear algebra, and an upper division course in data structures. The only prerequisite to both the algorithm and geometric modeling course was the introduc- tory computer graphics course. Some of the material in the introductory course was briefly reviewed in the other two courses. The courses used material from the fol- lowing parts of this book and [AgoM05] (but the material was not necessarily dis- GOSPR 5/5/2005 5:47 PM Page viii

viii Preface

cussed in the order listed, and listing a chapter or section in no way means that all of it was covered):

Introduction to Computer Graphics: Chapters 1–4, a quick overview of Chapters 5, 6, 11, 12, and a brief discussion of visible surface algorithms and shading from Chapters 7 and 10. From [AgoM05]: Chapters 1–3. Computer Graphics Algorithms: Chapters 2–10, just enough of Chapter 12 to have surfaces to render, Sections 21.6– 21.8, and Chapter 22. From [AgoM05]: Chapter 1 and Sections 4.5, 4.7, 8.1–8.5. Geometric Modeling: Chapters 3–6, 11, 12, a sampling of topics from Chapters 13–15, and Sections 17.4– 17.5. From [AgoM05]: Review of parts of Chapters 1 and 2, Sections 4.2, 4.5, 4.7, Chapter 6, and Sections 8.1–8.5, 9.2–9.4, 9.9.

The numbering of items in this book uses the following format: x.y.z refers to item number z in section y of chapter x. For example, Theorem 12.7.1 refers to the first item of type theorem, proposition, lemma, or example in Section 7 of Chapter 12. Algorithm 14.3.1 refers to the first algorithm in Section 3 of Chapter 14. Tables are numbered like algorithms. Figures are numbered by chapter, so that Figure 14.7 refers to the seventh figure in Chapter 14. Exercises and programming projects at the end of chapters are numbered by section. Finally, some comments on the language used in this book to describe algorithms. Even though the C/C++ language is the language of choice for most people writing computer graphics programs, with the exception of some initialization code found in Section 1.6, we have opted to use “the” more universal “standard” algorithmic lan- guage. The reason is that this book is mostly about concepts that are independent of any particular programming language and low-level optimization issues that hinge on the language being used do not play any role. Every reader with some general com- puter experience will understand the language used here (a detailed description of its syntax can be found in Appendix B) and so there seemed to be little point to restrict the audience to those familiar with C. Consider the following points:

(1) There is little difference between the code that is presented and what the corresponding C code would look like, so that any translation would be straightforward. (2) The emphasis in the code and algorithms in this book is on clarity and the fact is that even in simple constructs like a for-loop or a case statement, C has more complicated syntax and uses more obscure terminology which would make it harder for the non-C reader to understand. A certain universality would be lost with no real corresponding gain. The efficiency advantage of C that is usually cited is only really GOSPR 5/5/2005 5:47 PM Page ix

Preface ix

significant in a relatively small number of places. It would be relevant, for example, if one wanted to implement low level drawing primitives, but that is not what this book is about. (3) C programmers who want to see C code can look at the GM and SPACE pro- grams, which are written in C++.

Cupertino, California Max K. Agoston GOSPR 5/5/2005 5:47 PM Page xi

Contents

Preface ...... v

I Basic Computer Graphics ...... 1

1 Introduction ...... 3 1.1 Overview ...... 3 1.2 The Basic Graphics Pipeline ...... 4 1.3 Hardware Basics ...... 7 1.4 Graphics Standards and Primitives ...... 10 1.5 From Window to Viewport ...... 12 1.6 Programming Notes ...... 13 1.7 Exercises ...... 16 1.8 Programming Projects ...... 16

2 Raster Algorithms ...... 22 2.1 Introduction ...... 22 2.2 Discrete Topology ...... 22 2.3 Border Following Algorithms ...... 26 2.4 Fill Algorithms ...... 28 2.5 Generating Discrete Curves ...... 35 2.5.1 Digital Differential Analyzers ...... 36 2.5.2 The Bresenham Line-Drawing Algorithm ...... 38 2.5.3 The Midpoint Line-Drawing Algorithm ...... 40 2.6 The Aliasing Problem ...... 44 2.7 Halftoning, Thresholding, and Dithering ...... 48 2.8 Choosing the Coordinates of a Pixel ...... 49 2.9 More Drawing Algorithms ...... 49 2.9.1 Scan Converting Polygons ...... 49 2.9.2 Drawing ...... 54 2.9.3 Drawing Ellipses and Other Conics ...... 57 2.10 Bit Map Graphics ...... 59 2.11 2D Animation ...... 61 GOSPR 5/5/2005 5:47 PM Page xii

xii Contents

2.12 Exercises ...... 66 2.13 Programming Projects ...... 67

3 Clipping ...... 69 3.1 Introduction ...... 69 3.2 Line Clipping Algorithms ...... 71 3.2.1 Cohen-Sutherland Line Clipping ...... 71 3.2.2 Cyrus-Beck Line Clipping ...... 73 3.2.3 Liang-Barsky Line Clipping ...... 77 3.2.4 Nicholl-Lee-Nicholl Line Clipping ...... 81 3.3 Polygon Clipping Algorithms ...... 84 3.3.1 Sutherland-Hodgman Polygon Clipping ...... 84 3.3.2 Weiler Polygon Clipping ...... 85 3.3.3 Liang-Barsky Polygon Clipping ...... 86 3.3.4 Maillot Polygon Clipping ...... 89 3.3.5 Vatti Polygon Clipping ...... 98 3.3.6 Greiner-Hormann Polygon Clipping ...... 106 3.4 Text Clipping ...... 109 3.5 Exercises ...... 110 3.6 Programming Projects ...... 110

4 Transformations and the Graphics Pipeline ...... 111 4.1 Introduction ...... 111 4.2 From Shape to Camera Coordinates ...... 112 4.3 Vanishing Points ...... 117 4.4 Windows and Viewports Revisited ...... 119 4.5 The Clip Coordinate System ...... 122 4.6 Clipping ...... 125 4.7 Putting It All Together ...... 130 4.8 Stereo Views ...... 131 4.9 Parallel Projections ...... 132 4.10 Homogeneous Coordinates: Pro and Con ...... 134 4.11 The Projections in OpenGL ...... 138 4.12 Reconstruction ...... 139 4.13 Robotics and Animation ...... 141 4.14 Quaternions and In-betweening ...... 146 4.15 Conclusions ...... 149 4.16 Exercises ...... 151 4.17 Programming Projects ...... 152

5 Approaches to Geometric Modeling ...... 156 5.1 Introduction ...... 156 5.2 R-sets and Regularized Set Operators ...... 158 5.3 Representation Schemes ...... 160 5.3.1 Early Representation Schemes ...... 164 GOSPR 5/5/2005 5:47 PM Page xiii

Contents xiii

5.3.2 Boundary Representations ...... 166 5.3.3 The CSG Representation ...... 167 5.3.4 Euler Operations ...... 171 5.3.5 Sweep Representations and Generative Modeling ...... 174 5.3.6 Parametric Representations ...... 178 5.3.7 Decomposition Schemes ...... 178 5.3.8 Volume Modeling ...... 180 5.3.9 The Medial Axis Representation ...... 182 5.4 Modeling Natural Phenomena ...... 188 5.5 Physically Based Modeling ...... 190 5.6 Parametric and Feature Based Modeling ...... 192 5.7 Functions and Algorithms ...... 198 5.8 Data Structures ...... 199 5.8.1 Data Structures for Boundary Representations ...... 199 5.8.2 Data Structures for Volume Modeling ...... 203 5.9 Converting Between Representations ...... 205 5.10 Round-off Error and Robustness Issues ...... 211 5.11 Algorithmic Modeling ...... 215 5.12 Conclusions ...... 220 5.13 Exercises ...... 225

6 Basic Geometric Modeling Tools ...... 227 6.1 Introduction ...... 227 6.2 Bounding Objects and Minimax Tests ...... 227 6.3 Surrounding Tests ...... 232 6.4 Orientation Related Facts ...... 238 6.5 Simple Intersection Algorithms ...... 240 6.6 Distance Formulas ...... 245 6.7 Area and Volume Formulas ...... 249 6.8 Formulas ...... 252 6.9 Parametric or Implicit: Which Is Better? ...... 258 6.10 Transforming Entities ...... 259 6.11 Exercises ...... 261 6.12 Programming Projects ...... 262

7 Visible Surface Algorithms ...... 264 7.1 Introduction ...... 264 7.2 Back Face Elimination ...... 267 7.3 The Schumacker List Priority Algorithm ...... 268 7.4 Newell-Newell-Sancha Depth Sorting ...... 269 7.5 The BSP Algorithm ...... 270 7.6 Warnock and Weiler-Atherton Area Subdivision ...... 273 7.7 Z-buffer Algorithms ...... 275 7.8 The Watkins Scan Line Algorithm ...... 278 7.9 Octree Algorithms ...... 283 GOSPR 5/5/2005 5:47 PM Page xiv

xiv Contents

7.10 Curved Surface Algorithms ...... 284 7.11 Adding Antialiasing ...... 290 7.12 Conclusions ...... 291 7.13 Programming Projects ...... 293

8 Color ...... 294 8.1 Introduction ...... 294 8.2 What Is Color? ...... 294 8.3 Perceived Color ...... 295 8.4 Colorimetry ...... 297 8.5 Color Models ...... 299 8.6 Transforming Between Color Models ...... 303 8.7 Programming Projects ...... 307

9 Illumination and Shading ...... 308 9.1 Introduction ...... 308 9.2 Local Reflectance Models ...... 310 9.3 Simple Approaches to Shading ...... 316 9.4 Global Illumination Models ...... 318 9.4.1 Shadows ...... 318 9.4.2 Transparency ...... 320 9.4.3 Ray Tracing ...... 322 9.4.4 Radiosity Methods ...... 323 9.5 The Rendering Equation ...... 323 9.6 Texture and Texture Mappings ...... 324 9.7 Environment Mappings ...... 327 9.8 Bump Mappings ...... 328 9.9 The Rendering Pipeline ...... 330 9.10 Selecting a Color Palette ...... 332 9.11 Programming Notes ...... 333 9.12 Programming Projects ...... 335

10 Rendering Techniques ...... 337 10.1 Introduction ...... 337 10.2 Ray Tracing ...... 338 10.2.1 A Ray-Tracing Program ...... 338 10.2.2 Ray Intersection Formulas ...... 344 10.2.3 Ray Tracing CSG objects ...... 348 10.3 The Radiosity Method ...... 350 10.3.1 Form Factors: The Hemicube Method ...... 355 10.4 Volume Rendering ...... 358 10.4.1 Discrete Three-Dimensional Lines ...... 362 10.4.2 The Marching Cubes Algorithm ...... 365 10.5 Exercises ...... 369 10.6 Programming Projects ...... 369 GOSPR 5/5/2005 5:47 PM Page xv

Contents xv

II Geometric Modeling Topics ...... 371

11 Curves in Computer Graphics ...... 373 11.1 Introduction to Curves and Surfaces ...... 374 11.2 Early Historical Developments ...... 378 11.2.1 Lagrange Interpolation ...... 378 11.2.2 Hermite Interpolation ...... 381 11.2.3 Spline Interpolation ...... 387 11.3 Cubic Curves ...... 390 11.4 Bézier Curves ...... 396 11.5 B-Spline Curves ...... 404 11.5.1 The Standard B-Spline Curve Formulas ...... 404 11.5.2 The Multiaffine Approach to B-Splines ...... 418 11.5.3 Rational B-spline Curves ...... 430 11.5.4 Efficient B-spline and NURBS Curve Algorithms ...... 436 11.5.5 B-Spline Interpolation ...... 441 11.6 Nonlinear Splines ...... 445 11.7 Superellipses ...... 448 11.8 Subdivision of Curves ...... 449 11.9 Composition of Curves and Geometric Continuity ...... 452 11.10 The Shape of a Curve ...... 456 11.11 Hodographs ...... 459 11.12 Fairing Curves ...... 460 11.13 Parallel Transport Frames ...... 461 11.14 Recursive Subdivision Curves ...... 465 11.15 Summary ...... 466 11.16 Exercises ...... 468 11.17 Programming Projects ...... 470

12 Surfaces in Computer Graphics ...... 472 12.1 Introduction ...... 472 12.2 Surfaces of Revolution ...... 474 12.3 Quadric Surfaces and Other Implicit Surfaces ...... 480 12.4 Ruled Surfaces ...... 482 12.5 Sweep Surfaces ...... 484 12.6 Bilinear Surfaces ...... 486 12.7 Coons Surfaces ...... 487 12.8 Tensor Product Surfaces ...... 495 12.9 The Bicubic Patch ...... 496 12.10 Bézier Surfaces ...... 500 12.11 Gregory Patches ...... 502 12.12 B-spline Surfaces ...... 504 12.12.1 The Basic B-spline Surface ...... 504 12.12.2 Polynomial Surfaces and Multiaffine Maps ...... 505 12.12.3 Triangular Bézier Surfaces ...... 509 12.12.4 Rational B-spline Surfaces ...... 512 GOSPR 5/5/2005 5:47 PM Page xvi

xvi Contents

12.12.5 Efficient B-spline and NURBS Surface Algorithms ...... 514 12.12.6 B-spline Interpolation ...... 516 12.13 Cyclide Surfaces ...... 517 12.14 Subdivision of Surfaces ...... 521 12.15 Composite Surfaces and Geometric Continuity ...... 522 12.16 Fairing Surfaces ...... 525 12.17 Recursive Subdivision Surfaces ...... 526 12.18 Summary for Curves and Surfaces ...... 530 12.19 A Little Bit of History ...... 532 12.20 Exercises ...... 534 12.21 Programming Projects ...... 536

13 Intersection Algorithms ...... 537 13.1 Overview ...... 537 13.2 Convex Set Intersections ...... 540 13.3 Curve Intersections ...... 543 13.3.1 Ray-Curve Intersection ...... 543 13.3.2 Curve-Curve Intersections ...... 545 13.3.3 A Curve Newton-Raphson Method ...... 546 13.3.4 Curve Recursive Subdivision Methods ...... 547 13.3.5 Curve Algebraic Methods ...... 551 13.4 Special Surface Intersections ...... 552 13.4.1 Ray-Surface Intersections ...... 552 13.4.2 Curve-Surface Intersections ...... 552 13.4.3 Surface Sections ...... 553 13.5 Surface-Surface Intersections ...... 557 13.5.1 Surface Lattice Evaluation Methods ...... 558 13.5.2 Surface Marching Methods ...... 558 13.5.3 Surface Homotopy Method ...... 570 13.5.4 Surface Recursive Subdivision Methods ...... 572 13.5.5 Surface Algebraic Methods ...... 574 13.6 Summary ...... 578 13.7 Programming Projects ...... 580

14 Global Geometric Modeling Topics ...... 582 14.1 Overview ...... 582 14.2 Distance Algorithms ...... 582 14.3 Polygonizing Curves and Surfaces ...... 587 14.4 Trimmed Surfaces ...... 598 14.5 Implicit Shapes ...... 614 14.5.1 Implicit Curves ...... 614 14.5.2 Implicit Surfaces and Quadrics ...... 622 14.6 Finding Contours ...... 624 14.7 Skinning ...... 630 14.8 Computing Arc Length ...... 633 14.9 Offset Shapes ...... 638 14.9.1 Offset Curves ...... 638 14.9.2 Offset Surfaces ...... 644 GOSPR 5/5/2005 5:47 PM Page xvii

Contents xvii

14.10 Envelopes ...... 646 14.11 Exercises ...... 647 14.12 Programming Projects ...... 647

15 Local Geometric Modeling Topics ...... 649 15.1 Overview ...... 649 15.2 Curvature ...... 649 15.3 Geodesics ...... 652 15.3.1 Generating Smooth Geodesics ...... 652 15.3.2 Generating Discrete Geodesics ...... 657 15.4 Filament Winding and Tape Laying ...... 667 15.5 Dropping Curves on Surfaces ...... 670 15.6 Blending ...... 672 15.7 Programming Projects ...... 683

16 Intrinsic Geometric Modeling ...... 684 16.1 Introduction ...... 684 16.2 Virtual Reality ...... 685 16.3 Geometrically Intelligent Modeling Systems ...... 687 16.4 Exploring Manifolds ...... 689 16.5 Where To From Here? ...... 693

III More on Special Computer Graphics Topics ...... 695

17 Topics ...... 697 17.1 Introduction ...... 697 17.2 Range Queries ...... 697 17.3 Interval and Segment Trees ...... 703 17.4 Box Intersections ...... 709 17.5 Convex Set Problems ...... 711 17.6 Triangulating Polygons ...... 714 17.7 Voronoi Diagrams ...... 720 17.8 Delaunay Triangulations ...... 722

18 Interval Analysis ...... 726 18.1 Introduction ...... 726 18.2 Basic Definitions ...... 727 18.3 Inclusion Functions ...... 731 18.4 Constraint Solutions ...... 735 18.5 An Application: Implicit Curve Approximations ...... 738 18.6 Constrained Minimizations ...... 742 18.7 Conclusions ...... 744 18.8 Exercises ...... 744

19 The Finite Element Method ...... 745 19.1 Introduction ...... 745 19.2 What Is It All About? ...... 745 GOSPR 5/5/2005 5:47 PM Page xviii

xviii Contents

19.3 The Mathematics Behind FEM ...... 747 19.4 An Example ...... 749 19.5 Summary ...... 753

20 Quaternions ...... 755 20.1 Introduction ...... 755 20.2 Basic Facts ...... 755 20.3 Quaternions as Transformations ...... 760 20.4 Exercises ...... 766

21 Digital Image Processing Topics ...... 767 21.1 Introduction ...... 767 21.2 The Ubiquitous Laplace Equation ...... 768 21.3 From Laplace to Fourier ...... 772 21.4 The Lp Function Spaces ...... 773 21.5 Fourier Series ...... 775 21.6 The Fourier Transform ...... 781 21.7 Convolution ...... 786 21.8 Signal Processing Topics ...... 788 21.9 Wavelets ...... 792 21.10 Exercises ...... 796

22 Chaos and Fractals ...... 797 22.1 Introduction ...... 797 22.2 Dynamical Systems and Chaos ...... 797 22.3 Theory and Fractals ...... 802 22.4 Iterated Function Systems ...... 806

Appendix A: Notation ...... 815

Appendix B: Abstract Program Syntax ...... 819

Appendix C: IGES ...... 822 C.1 What Is IGES? ...... 822 C.2 A Sample IGES File ...... 822 C.3 The IGES Geometric Types ...... 827 C.4 The IGES Nongeometric Types ...... 832

Bibliography ...... 835 Abbreviations ...... 835 Advanced Calculus ...... 835 Algebraic Curves and Surfaces ...... 835 ...... 836 Algebraic Topology ...... 836 Analytic Geometry ...... 836 Antialiasing ...... 836 Blending ...... 836 Clipping ...... 837 GOSPR 5/5/2005 5:47 PM Page xix

Contents xix

Color ...... 837 Computational Geometry ...... 838 Conics ...... 839 Constructive Solid Geometry ...... 839 Contours ...... 839 Convex Sets ...... 840 Curvature ...... 840 Curve Algorithms ...... 840 Cyclides ...... 841 ...... 841 Digital Image Processing ...... 841 Engineering Applications ...... 841 Finite Element Method ...... 842 Fourier Series and Transforms ...... 842 Fractals ...... 842 General Computer Graphics ...... 843 Geodesics ...... 843 Geometric Modeling Books ...... 843 Geometric Modeling Papers ...... 845 Graphical User Interfaces ...... 848 Graphics Pipeline ...... 848 Graphics Standards ...... 848 Hodographs ...... 849 Implicit Curves and Surfaces ...... 849 Intersection Algorithms ...... 850 Interval Analysis ...... 852 Mathematics for Geometric Modeling ...... 852 Medial Axes ...... 852 Miscellaneous ...... 854 Numerical Methods ...... 854 Offset Curves and Surfaces ...... 855 PC Oriented Computer Graphics ...... 855 Physically Based Modeling ...... 855 Polygonization Algorithms ...... 856 Projective Geometry and Transformations ...... 856 Quadrics ...... 856 Quaternions ...... 856 Radiosity ...... 857 Raster Algorithms ...... 857 Ray Tracing ...... 858 Real Analysis ...... 859 Rendering ...... 859 Robotics ...... 859 Shading and Illumination (Early Work) ...... 859 Spatial Data Structures ...... 860 Splines ...... 860 Subdivision Curves and Surfaces ...... 862 Surfaces and Manifolds ...... 862 GOSPR 5/5/2005 5:47 PM Page xx

xx Contents

Texture ...... 863 Topology ...... 863 Trimmed Surfaces ...... 863 Virtual Reality ...... 864 Visible Surface Detection ...... 864 Visualization ...... 865 Volume Rendering ...... 865

Index ...... 867 Bibliographic Index ...... 896 Index of Algorithms ...... 906 GOS01 5/5/2005 5:48 PM Page 1

PART I

BASIC COMPUTER GRAPHICS CHAPTER 1