ebook img

Fast Algorithms for 3D Graphics ( 1994) PDF

316 Pages·1994·13.2 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Fast Algorithms for 3D Graphics ( 1994)

Fast Aigorithms for 3D-Graphics Georg Glaeser Fast Aigorithms for 3D-Graphics With 94 Illustrations With a diskette Springer Science+Business Media, LLC Georg Glaeser Lehrkanzel für Geometrie Hochschule für Angewandte Kunst Oskar Kokoschka Platz 2 A-IOIO Wien Austria Library of Congress Cataloging-in-Publication Data Glaeser, Georg. Fast algorithms for 3D-graphics : with 94 figures 1 Georg Glaeser. p. cm. Includes bibliographical references and index. 1. Computer graphics. 2. Computer algorithms. 3. Three dimensional display systems. 1. Tide. T385.G575 1994 006.6'7-dc20 94-8076 ISBN 978-3-540-94288-7 ISBN 978-3-662-25798-2 (eBook) DOI 10.1007/978-3-662-25798-2 Printed on acid-free paper. ©1994 Springer Science+Business Media New York Originally published by Springer-Verlag New York, Inc. in 1994. All rights reserved. This work may not be translated or copied in whole or in part without the weitten permission of the publisher Springer Science+Business Media, LLC except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed is forbidden. The use of general descriptive names, trade names, trademarks, etc., in this publication, even if the former are not especially identified, is not 10 be taken as a sign that such names, as understood by the Trade Marks and Merchandise Marks Act, may accordingly be used freely by anyone. Production managed by Henry Krell; manufacturing supervised by Jacqui Ashri. Photocomposed copy created from author's LaTeX files. 9 8 7 6 5 4 3 2 (Second corrected printing, 1995) Preface In this book, a variety of algoritbms are described that may be of interest to everyone who writes software for 3D-graphics. It is a book that haB been written for programmers at an intermediate level as well aB for experienced software engineers who simply want to have some particular functions at their disposal, without having to think too much about details like special cases or optimization for speed. The programming language we use is C, and that has many advantages, because it makes the code both portable and efficient. Nevertheless, it should be possible to adapt the ideas to other high-level programming languages. The reader should have a reasonable knowledge of C, because sophisticated pro grams with economical storage household and fast sections cannot be written without the use of pointers. You will find that in the long run it is just aB easy to work with pointer variables as with multiple arrays . .Aß the title of the book implies, we will not deal with algorithms that are very computation-intensive such as ray tracing or the radiosity method. Furthermore, objects will always be (closed or not closed) polyhedra, which consist of a certain number of polygons. Ray tracing algorithms are necessary to get highly realistic pictures, and it is even possible to make ray-traced movies out of complicated scenes. If you want to do that, however, you will need the fastest computers available on the market and an enormous amount of disk space. In order to create hundreds of frames on less sophisticated computers, we need different algorithms. The loss of realism is more than offset by the increase in speed. vi Preface The method of the book is to introduce theoretical background and program ming code at the same time. Type definitions, global variables and macros are described before their first applications. Because each chapter of the book builds upon the previous one, it is not advisable to skip any of them. If you are already familiar with a particular topic, at least skim over the relevant pages. All global variables, macros and function prototypes are listed in the index of the book. In summary, it may be said that the intention of this book is to • provide a mathematical background for 3D-graphics. • gradually develop a complete graphics program that is able to render images of 3D-scenes comparatively quickly, including shadows and - to a limited degree - reßections. The images can be stored as PostScript files. The scene can be animated either interactively or by animation files. Series of scenes can be stored and replayed in real time. The program can be ported to any computer that is able to create palette colors by means of RGB-values and set pixels in those colors on the screen. The C compiler should provide a function to draw a line between two screen points and if possible a function to fill convex polygons. • illustrate techniques of C programming with emphasis on portability and speed. Readers who are not so familiar with the programming language C may also find this book useful for a better understanding of pointer arith metic. • provide the reader with a source code of a graphics programming package. With the help of this source code, it is possible to adapt new code and to implement new information. (For example, one can easily introduce new spline types or new families of surfaces.) Acknowledgments A book like this can never be the achievement of one person only. It is not easy to start with anyone, because many people and institutions have helped to get the work done. The idea of writing the book was born several years aga during the time I worked with Steve M. Slaby at Princeton University. Besides Steve, the man who came in with the most essential innovations and ideas from the very beginning was Silvio Levy from the Mathematics Department. It was he who strongly believed in the project. At the same time, I received a lot of support from Dave Dobkin from the Com puter Science Department and the individuals from the Interactive Computer Graphics Laboratory. Preface vii Back in Europe, Reinhard Thaller, Leonid Dimitrov and Emanuel Wenger from the Austrian Academy of Science helped me in many ways. During the same time, I worked together with two of my students, Thomas Grohser and Hein rich Pommer, both of whom brought in a lot of ideas to improve the code and the speed. FUrthermore, I received advice from Hellmuth Stachel and Wolfgang Rath from the Institute of Geometry at the Technical University of Vienna and Otto Prem from the Handelsakademie St. Johann im Pongau, who also did the proofreading together with Silvio Levy. Suggested Reading The list of books on 3D-graphics is already very long and it is useless to recom mend them all. The books listed below may be useful for a better understanding of this book: • The C Programming Language: [DARN88j, [KERN86j . • Theory of 3D-Graphics: [HEAR86j, [HOSC89j, [NEWM84j, [pLAS86j, [ROGE85j, [ROGE90j, [THAL87j, [FOLE90j, [VINC92j. Contents 1 A Basic Course in Spatial Analytic Geometry 1 1.1 Vectors . . . . · ... · ... · .... 1 1.2 How to Measure Lengths and Angles . . . . .... 9 1.3 Intersections of Lines and Planes · ... · . . . . 11 1.4 'franslations . . . · ......... · .... 18 1.5 Matrices .. .... · .... · ... · .... 20 1.6 Rotations ..... · ... · .... · . · .... 22 2 Projections 25 2.1 Central Projections . · ... 26 2.2 The Viewing Pyramid · .... 29 2.3 Coordinate Systems · ........ 32 2.4 Back and Forth Between Coordinate Systems · .... 37 2.5 Clipping Algorithms · ... . . . . . · ...... 43 3 How to Describe Three-Dimensional Objects 57 3.1 Data Pools . . . · .... · ... · . . ... 58 3.2 The 'Polyhedron' and 'Face' Structures .. 66 3.3 General Convex Objects · ... · ... · .... 68 X Contents 3.4 Surfaces of Revolution . . . 74 3.5 Surfaces of Translation . . . 82 3.6 The Intersection of Objects 85 4 Graphics Output 95 4.1 Graphics Hardware. 95 4.2 System-Dependent Macros and Functions .............. . 96 4.3 How to Create Color Palettes and How to Use Them . . . . . . . . . 99 4.4 Wire Frames and Depth Cuing . . . . . . . 105 4.5 Shading...................... 110 4.6 Basic Graphics Output Algorithms 117 5 A Fast Hidden-Surface Algorithm 125 5.1 Objects with Convex Outlines. . . . . . . . 127 · ........ 5.2 Surfaces of Revolution 129 5.3 Sliced Surfaces . . . . · ........ 131 5.4 Function Graphs .. · ........ 133 5.5 Priority Among Objects · ........ 135 .......... 5.6 Final Priority List 143 5.7 The Creation of Object Groups . . . . . . . . 149 5.8 Bounding Boxes and Separating Planes 150 6 Advanced Features 155 6.1 Convex Hulls ................ . 156 6.2 The Intersection of Convex Hulls ..... . 164 6.3 Shadows....... . ....... . 172 6.4 Reßections................... 177 6.5 Patterns.................... 180 6.6 Refraction, Transparent Objects 182 7 Hidden-Line Removal 185 7.1 A Quick Screen-Oriented Method ................... . 185 7.2 Hidden-Line Removal on Objects with Convex Outlines ...... . 186 7.3 Depth Buffering for Visibility . . . . . . . . . . . . . . . . . . . . . . 194 Contents xi 8 Mathematical Curves and Surfaces 201 8.1 Parametrized Curves ........ . 202 8.2 Classes of Parametrized Surfaces . . 205 8.3 Surfaces Given by Implicit Equations . 210 8.4 Special Curves on Mathematical Surfaces 212 8.5 A More Sophisticated Illumination Model 228 8.6 Shadow Buffering for Shadows .. 231 9 Spline Curves and Spline Surfaces 233 9.1 Interpolating Curves and Surfaces 233 9.2 Approximating Curves and Surfaces 242 9.3 Special Curves on Polygonized Surfaces 247 9.4 Spatial Integral Curves ...... . 249 9.5 SomeExamples of Applications . 253 10 Computer-Generated Movies 255 10.1 An Economical Way of Storing a Movie 255 10.2 A Fast Movie Previewer ......... . 266 11 The Programming Package on Your Disk 267 11.1 The Contents of the Disk ..... . 267 11.2 How to Instali the Program Package 268 11.3 How to Use the Program ...... . 269 11.4 How to Write Data Files and Animation Files . 271 11.5 How Fast Is Your Computer? ......... . 271 12 System Dependencies and Other Programming Languages 279 12.1 How to Change the System-Dependent Commands 279 12.2 'Macromania': C, ANSI C or C++ ? 283 12.3 Pointer Arithmetic in PASCAL 284 References 289 Index 293

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.