Computational Geometry
Third Edition
Mark de Berg · Otfried Cheong
Marc van Kreveld · Mark Overmars
Computational Geometry
Algorithms and Applications
Third Edition
123
Prof. Dr. Mark de Berg
Department of Mathematics
and Computer Science
TU Eindhoven
P.O. Box 513
5600 MB Eindhoven
The Netherlands
mdberg@win.tue.nl
Dr. Otfried Cheong, n´e Schwarzkopf
Department of Computer Science
KAIST
Gwahangno 335, Yuseong-gu
Daejeon 305-701
Korea
otfried@kaist.edu
Dr. Marc van Kreveld
Department of Information
and Computing Sciences
Utrecht University
P.O. Box 80.089
3508 TB Utrecht
The Netherlands
marc@cs.uu.nl
Prof. Dr. Mark Overmars
Department of Information
and Computing Sciences
Utrecht University
P.O. Box 80.089
3508 TB Utrecht
The Netherlands
markov@cs.uu.nl
ISBN 978-3-540-77973-5
e-ISBN 978-3-540-77974-2
DOI 10.1007/978-3-540-77974-2
ACM Computing Classification (1998): F.2.2, I.3.5
Library of Congress Control Number: 2008921564
© 2008, 2000, 1997 Springer-Verlag Berlin Heidelberg
This work is subject to copyright. All rights are reserved, whether the whole or part of the material
is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication
of this publication or parts thereof is permitted only under the provisions of the German Copyright
Law of September 9, 1965, in its current version, and permission for use must always be obtained
from Springer. Violations are liable for prosecution under the German Copyright Law.
The use of general descriptive names, 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
protective laws and regulations and therefore free for general use.
Cover design: KünkelLopka, Heidelberg
Printed on acid-free paper
9 8 7 6 5 4 3 2 1
springer.com
Preface
Computational geometry emerged from the field of algorithms design and
analysis in the late 1970s. It has grown into a recognized discipline with its
own journals, conferences, and a large community of active researchers. The
success of the field as a research discipline can on the one hand be explained
from the beauty of the problems studied and the solutions obtained, and, on the
other hand, by the many application domains—computer graphics, geographic
information systems (GIS), robotics, and others—in which geometric algorithms
play a fundamental role.
For many geometric problems the early algorithmic solutions were either
slow or difficult to understand and implement. In recent years a number of new
algorithmic techniques have been developed that improved and simplified many
of the previous approaches. In this textbook we have tried to make these modern
algorithmic solutions accessible to a large audience. The book has been written
as a textbook for a course in computational geometry, but it can also be used for
self-study.
Structure of the book. Each of the sixteen chapters (except the introductory
chapter) starts with a problem arising in one of the application domains. This
problem is then transformed into a purely geometric one, which is solved
using techniques from computational geometry. The geometric problem and the
concepts and techniques needed to solve it are the real topic of each chapter. The
choice of the applications was guided by the topics in computational geometry
we wanted to cover; they are not meant to provide a good coverage of the
application domains. The purpose of the applications is to motivate the reader;
the goal of the chapters is not to provide ready-to-use solutions for them. Having
said this, we believe that knowledge of computational geometry is important
to solve geometric problems in application areas efficiently. We hope that our
book will not only raise the interest of people from the algorithms community,
but also from people in the application areas.
For most geometric problems treated we give just one solution, even when
a number of different solutions exist. In general we have chosen the solution
that is easiest to understand and implement. This is not necessarily the most
efficient solution. We also took care that the book contains a good mixture of
techniques like divide-and-conquer, plane sweep, and randomized algorithms.
We decided not to treat all sorts of variations to the problems; we felt it is more
important to introduce all main topics in computational geometry than to give
more detailed information about a smaller number of topics.
v
PREFACE
Several chapters contain one or more sections marked with a star. They con-
tain improvements of the solution, extensions, or explain the relation between
various problems. They are not essential for understanding the remainder of the
book.
Every chapter concludes with a section that is entitled Notes and Comments.
These sections indicate where the results described in the chapter originated,
mention other solutions, generalizations, and improvements, and provide refer-
ences. They can be skipped, but do contain useful material for those who want
to know more about the topic of the chapter.
At the end of each chapter a number of exercises is provided. These range
from easy tests to check whether the reader understands the material to more
elaborate questions that extend the material covered. Difficult exercises and
exercises about starred sections are indicated with a star.
A course outline. Even though the chapters in this book are largely indepen-
dent, they should preferably not be treated in an arbitrary order. For instance,
Chapter 2 introduces plane sweep algorithms, and it is best to read this chapter
before any of the other chapters that use this technique. Similarly, Chapter 4
should be read before any other chapter that uses randomized algorithms.
For a first course on computational geometry, we advise treating Chapters 1–
10 in the given order. They cover the concepts and techniques that, according
to us, should be present in any course on computational geometry. When more
material can be covered, a selection can be made from the remaining chapters.
Prerequisites. The book can be used as a textbook for a high-level under-
graduate course or a low-level graduate course, depending on the rest of the
curriculum. Readers are assumed to have a basic knowledge of the design and
analysis of algorithms and data structures: they should be familiar with big-Oh
notations and simple algorithmic techniques like sorting, binary search, and
balanced search trees. No knowledge of the application domains is required, and
hardly any knowledge of geometry. The analysis of the randomized algorithms
uses some very elementary probability theory.
Implementations. The algorithms in this book are presented in a pseudo-
code that, although rather high-level, is detailed enough to make it relatively
easy to implement them. In particular we have tried to indicate how to handle
degenerate cases, which are often a source of frustration when it comes to
implementing.
We believe that it is very useful to implement one or more of the algorithms;
it will give a feeling for the complexity of the algorithms in practice. Each
chapter can be seen as a programming project. Depending on the amount of
time available one can either just implement the plain geometric algorithms, or
implement the application as well.
To implement a geometric algorithm a number of basic data types—points,
lines, polygons, and so on—and basic routines that operate on them are needed.
Implementing these basic routines in a robust manner is not easy, and takes a lot
vi
of time. Although it is good to do this at least once, it is useful to have a software
library available that contains the basic data types and routines. Pointers to such
libraries can be found on our Web site.
PREFACE
Web site. This book is accompanied by a Web site, which contains a list of
errata collected for each edition of the book, all figures and the pseudo code for
all algorithms, as well as some other resources. The address is
http://www.cs.uu.nl/geobook/
You can also use the address given on our Web site to send us errors you
have found, or any other comments you have about the book.
About the third edition. This third edition contains two major additions: In
Chapter 7, on Voronoi diagrams, we now also discuss Voronoi diagrams of line
segments and farthest-point Voronoi diagrams. In Chapter 12, we have included
an extra section on binary space partition trees for low-density scenes, as an
introduction to realistic input models. In addition, a large number of small and
some larger errors have been corrected (see the list of errata for the second
edition on the Web site). We have also updated the notes and comments of every
chapter to include references to recent results and recent literature. We have
tried not to change the numbering of sections and exercises, so that it should be
possible for students in a course to still use the second edition.
Acknowledgments. Writing a textbook is a long process, even with four
authors. Many people contributed to the original first edition by providing
useful advice on what to put in the book and what not, by reading chapters and
suggesting changes, and by finding and correcting errors. Many more provided
feedback and found errors in the first two editions. We would like to thank all of
them, in particular Pankaj Agarwal, Helmut Alt, Marshall Bern, Jit Bose, Hazel
Everett, Gerald Farin, Steve Fortune, Geert-Jan Giezeman, Mordecai Golin, Dan
Halperin, Richard Karp, Matthew Katz, Klara Kedem, Nelson Max, Joseph S. B.
Mitchell, Ren´e van Oostrum, G¨unter Rote, Henry Shapiro, Sven Skyum, Jack
Snoeyink, Gert Vegter, Peter Widmayer, Chee Yap, and G¨unther Ziegler. We
also would like to thank Springer-Verlag for their advice and support during the
creation of this book, its new editions, and the translations into other languages
(at the time of writing, Japanese, Chinese, and Polish).
Finally we would like to acknowledge the support of the Netherlands’ Or-
ganization for Scientific Research (N.W.O.) and the Korea Research Founda-
tion (KRF).
January 2008
Mark de Berg
Otfried Cheong
Marc van Kreveld
Mark Overmars
vii
Contents
1 Computational Geometry
Introduction
1.1 An Example: Convex Hulls
1.2 Degeneracies and Robustness
1.3 Application Domains
1.4 Notes and Comments
1.5
Exercises
2 Line Segment Intersection
Line Segment Intersection
The Doubly-Connected Edge List
Thematic Map Overlay
2.1
2.2
2.3 Computing the Overlay of Two Subdivisions
2.4 Boolean Operations
2.5 Notes and Comments
2.6
Exercises
3 Polygon Triangulation
Guarding an Art Gallery
3.1 Guarding and Triangulations
3.2
3.3
3.4 Notes and Comments
3.5
Exercises
Partitioning a Polygon into Monotone Pieces
Triangulating a Monotone Polygon
4 Linear Programming
Manufacturing with Molds
4.1
4.2 Half-Plane Intersection
4.3
Incremental Linear Programming
4.4 Randomized Linear Programming
The Geometry of Casting
1
2
8
10
13
15
19
20
29
33
39
40
41
45
46
49
55
59
60
63
64
66
71
76
ix