Geometric Tools for
Computer Graphics
The Morgan Kaufmann Series in Computer Graphics and Geometric Modeling
Series Editor: Brian A. Barsky, University of California, Berkeley
Geometric Tools for Computer Graphics
Philip Schneider and David Eberly
Level of Detail for 3D Graphics
David Luebke, Martin Reddy, Jonathan D. Cohen,
Amitabh Varshney, Benjamin Watson, and Robert
Huebner
Texturing & Modeling: A Procedural Approach,
Third Edition
David S. Ebert, F. Kenton Musgrave, Darwyn Peachey,
Ken Perlin, and Steven Worley
Jim Blinn’s Corner: Notation, Notation, Notation
Jim Blinn
Understanding Virtual Reality
William Sherman and Alan Craig
Digital Video and HDTV Algorithms and Interfaces
Charles Poynton
Pyramid Algorithms: A Dynamic Programming Ap-
proach to Curves and Surfaces for Geometric Modeling
Ron Goldman
Non-Photorealistic Computer Graphics: Modeling,
Rendering, and Animation
Thomas Strothotte and Stefan Schlechtweg
Curves and Surfaces for CAGD: A Practical Guide,
Fifth Edition
Gerald Farin
Subdivision Methods for Geometric Design: A
Constructive Approach
Joe Warren and Henrik Weimer
Computer Animation: Algorithms and Techniques
Rick Parent
The Computer Animator’s Technical Handbook
Lynn Pocock and Judson Rosebush
Andrew Glassner’s Notebook: Recreational Computer
Graphics
Andrew S. Glassner
Warping and Morphing of Graphical Objects
Jonas Gomes, Lucia Darsa, Bruno Costa, and Luiz
Velho
Jim Blinn’s Corner: Dirty Pixels
Jim Blinn
Rendering with Radiance: The Art and Science of
Lighting Visualization
Greg Ward Larson and Rob Shakespeare
Introduction to Implicit Surfaces
Edited by Jules Bloomenthal
Jim Blinn’s Corner: A Trip Down the Graphics Pipeline
Jim Blinn
Interactive Curves and Surfaces: A Multimedia Tutorial
on CAGD
Alyn Rockwood and Peter Chambers
Wavelets for Computer Graphics: Theory and Applica-
tions
Eric J. Stollnitz, Tony D. DeRose, and David H. Salesin
Principles of Digital Image Synthesis
Andrew S. Glassner
Radiosity & Global Illumination
Fran¸cois X. Sillion and Claude Puech
Knotty: A B-Spline Visualization Program
Jonathan Yen
User Interface Management Systems: Models and
Algorithms
Dan R. Olsen, Jr.
Making Them Move: Mechanics, Control, and
Animation of Articulated Figures
Edited by Norman I. Badler, Brian A. Barsky, and
David Zeltzer
Advanced RenderMan: Creating CGI for Motion Pictures
Anthony A. Apodaca and Larry Gritz
Geometric and Solid Modeling: An Introduction
Christoph M. Hoffmann
Curves and Surfaces in Geometric Modeling: Theory and
Algorithms
Jean Gallier
An Introduction to Splines for Use in Computer Graphics
and Geometric Modeling
Richard H. Bartels, John C. Beatty, and Brian A. Barsky
Geometric Tools for
Computer Graphics
Philip J. Schneider
David H. Eberly
Publishing Director Diane Cerra
Publishing Services Manager Edward Wade
Senior Developmental Editor Belinda Breyer
Project Management Elisabeth Beller
Cover Design Ross Carron Design
Cover Image Getty/Spencer Jones
Text Design Rebecca Evans & Associates
Composition Windfall Software, using ZzTEX
Technical Illustration and Figure Revision Dartmouth Publishing, Inc.
Copyeditor Ken DellaPenta
Proofreader
Indexer
Printer The Maple-Vail Book Manufacturing Group
Jennifer McClain
Steve Rath
Designations used by companies to distinguish their products are often claimed as trademarks
or registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a
claim, the product names appear in initial capital or all capital letters. Readers, however, should
contact the appropriate companies for more complete information regarding trademarks and
registration.
Morgan Kaufmann Publishers
An imprint of Elsevier Science
340 Pine Street, Sixth Floor
San Francisco, CA 94104-3205
www.mkp.com
© 2003 by Elsevier Science (USA)
All rights reserved
Printed in the United States of America
07
06
05
04
03
5
4
3
2
1
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means—electronic, mechanical, photocopying, recording, or otherwise—
without the prior written permission of the publisher.
Library of Congress Control Number: 2002107242
ISBN: 1-55860-594-0
This book is printed on acid-free paper.
To my wife, Suzanne, and my sons, Dakota and Jordan —PS
To my wife, Shelly, for her patience through yet another book —DE
Foreword
Eric Haines
On my shelf is an old book called A Programmer’s Geometry, by Bowyer and Wood-
wark. It was published in 1983, reprinted twice in 1984 and 1985, but then discontin-
ued. Over the years I have guarded my copy, keeping careful track of who borrowed
it. Checking on the Web today, I found six used copies ranging in price from $50 to
$100. This is a high price range for a paperback book only 140 pages in length. The
reason the book is worth this much is that it describes how to program various op-
erations related to 2D geometry. It does not just present geometric formulae; it also
describes efficient ways to accomplish tasks and gives code snippets (in FORTRAN).
Now, almost two decades later, we have a worthy successor to that slim volume.
The book before you distills a huge amount of literature on geometry into that which
is most useful to programmers. The field of computer graphics has evolved consid-
erably since 1983, and this volume reflects those advances. Due to the continuing
improvement in computer processor performance, operations that once were only
part of offline analysis packages are now commonly done in interactive programs.
Polygon triangulation, collision detection and response, and surface modelling and
modification are now possible at real-time rates. This book gives solid explanations
and code to perform these and many other algorithms.
Beyond providing a solid reference for a wide range of geometry-related tasks, this
volume also presents the underpinnings of the theory behind the algorithms. Rather
than employ a pure cookbook approach, which can leave the reader with runnable
code and no comprehension of how it works, the authors explain key concepts. This
approach makes each algorithm a tool that, further on, can be recombined with other
tools.
The dynamic nature of computer graphics makes it a particularly interesting area
of study. Research and implementation of rendering methods respond to changes
in the underlying hardware. For example, in the field of interactive rendering, the
emerging programmable nature of the graphics accelerator has changed the relative
costs of different techniques. On a broader scale, the evolution of the CPU has made
memory access and caching rise in importance, compared to the older practice of
minimizing the number of operations (e.g., counting multiplies and adds). However,
the underlying theory and algorithms for, say, finding the convex hull of an object are
considerably more long-lasting, less affected by changes. Of course, more efficient
algorithms are found over time, and hardware influences which method currently is
considered the fastest, but the basic principles remain the same. Years after you have
vii
viii
Foreword
shed your books on DirectX 9 or Intel’s 64-bit Itanium architecture, you are likely to
have some edition of this book on your shelf.
Another reason this book will have increased staying power is the Internet. I am
the archivist for the “Graphics Gems” series code repository. The code for this series
of books, including code by Philip Schneider, was wisely made free for reuse when
the series was published in the early 1990s. Over the years readers have sent in bug
fixes and improvements to the code base, so benefiting all. Similarly, Dave Eberly
has carefully maintained his “Magic Software” Web site (www.magic-software.com),
which includes working versions of many of the algorithms presented in this volume.
Called “a national treasure” by a leading researcher in computer graphics, this site
allows addenda and corrigenda to be made available instantly whenever they are
needed. Code does not rust; it improves with age when properly supported. This
is particularly true for algorithms in this book as they are not tied to particular
hardware, network protocols, or other transient objects.
Over the years I and many others have used algorithms and code by the authors
in products and research projects. An hour of a programmer’s time often costs more
than the price of a book. By this measure, you hold a volume potentially worth
thousands of dollars. That it can be purchased for a fraction of this cost I consider
a modern miracle. The amount of information crammed into this book is incredible.
The mathematics may be slow going at times, but the alternative would be to include
wordier and less precise descriptions of fewer algorithms. If you are looking for a
lightweight text you can read through and check off your list, keep searching. This
book sometimes requires effort and struggle to fully comprehend but then, so do
most of the worthwhile things in the world.