Umass Lowell Computer Science 91.503: Graduate Algorithms
Umass Lowell Computer Science 91.503: Graduate Algorithms
503
Graduate Algorithms
Prof. Karen Daniels
Spring, 2005
Computational Geometry
Overview from Cormen, et al.
Chapter 33
Overview
Computational Geometry Introduction
Line Segment Intersection
Convex Hull Algorithms
Nearest Neighbors/Closest Points
Introduction
What is
Computational Geometry?
Computational Geometry
Computer
Graphics
Visualization
Design
Analyze
CAD
Apply
Telecommunications
Manufacturing
Bioinformatics
Geographic
Information Systems
Medical
Imaging
Telecommunications
Computer Graphics
Astrophysics
Robotics
Typical Problems
bin packing
Voronoi diagram
simplifying
polygons
shape similarity
maintaining line
arrangements
polygon partitioning
nearest neighbor search
kd-trees
convex hull
Common Computational
Geometry Structures
Convex Hull
Voronoi Diagram
New Point
Delaunay Triangulation
source: ORourke, Computational Geometry in C
divide-and-conquer
sweep-line
parallelism
duality
Data Structures:
Proofs
Geometry
Linear Algebra
Recurrences
Graph Theory
Computational Geometry
in Context
Geometry
Design
Applied
Math
Analyze
Computational
Geometry
Efficient
Geometric Algorithms
Apply
Applied Computer Science
Theoretical
Computer
Science
Computational
Geometry
Linear programming
Integer programming
Lagrangian relaxation
Upper, lower bounding
Dynamic Data
Structures
Convex hulls
Visibility polygons
Arrangements
Mathematical
Programming
Algorithm Analysis
Techniques
Complexity Theory
NP-completeness, hardness
Discrete Math
Minkowski sum
Monotone matrices
Lattices
Set operations: union,
intersection, difference
Cross-Product-Based
Geometric Primitives
Some fundamental geometric questions:
p3
p2
p3
(1)
p4
p2
p1
p0
p2
p1
p1
(2)
(3)
Cross-Product-Based
Geometric Primitives: (1)
p2
33.1
p1
p0
x1
p1 p2 det
y1
x2
x1 y2 x2 y1
y2
(1)
Cross-Product-Based
Geometric Primitives: (2)
p2
p1
33.2
p0
(2)
p2
p4
p1
(3)
Step 2: Does each
segment straddle
the line containing
the other?
33.3
Segment-Segment Intersection
Lcd
Demo
Segment/Segment Intersection
http://cs.smith.edu/~orourke/books/CompGeom/CompGeom.html
33.4
33.5
source:
91.503
textbook
Cormenet
et al.
al.
source:
91.503
textbook
Cormen
Intersection of Segments
Definitions
Gift Wrapping
Graham Scan
QuickHull
Incremental
Divide-and-Conquer
Lower Bound in (nlgn)
i 0 i and 1 k 1
nonconvex polygon
Naive Algorithms
for Extreme Points
Algorithm: INTERIOR POINTS
for each i do
for each j = i do
for each k = j = i do
for each L = k = j = i do
if pL in triangle(pi, pj, pk)
then pL is nonextreme
Algorithm: EXTREME EDGES
for each i do
for each j = i do
for each k = j = i do
if pk is not left or on (pi, pj)
then (pi , pj) is not extreme
O(n4)
O(n3)
O(n )
Gift Wrapping
33.9
O(n2) time
[output sensitive: O(nF) for F faces on hull]
CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html
Algorithms: 2D QuickHull
Concentrate on points close to
hull boundary
Named for similarity to
Quicksort
a
b
A
c
Algorithms: 3D QuickHull
Algorithms: >= 2D
Convex Hull
boundary is
intersection of
hyperplanes, so
worst-case
combinatorial size
(not necessarily running
time) complexity is
in:
Qhull: http://www.geom.umn.edu/software/qhull/
( n
d / 2
Grahams Algorithm
source: ORourke, Computational Geometry in C
p0
O(nlgn)
Graham Scan
Graham Scan
33.7
Graham Scan
33.7
Graham Scan
Graham Scan
Algorithms: 2D Incremental
source: ORourke, Computational Geometry in C
Find 2 tangents
3 to n - 1 do
Hk
ConvexHull{ Hk-1 U pk }
O(n2)
can be improved to O(nlgn)
Algorithms: 3D Incremental
O(n2) time
CxHull Animations: http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html
Algorithms:
2D Divide-and-Conquer
O(nlgn)
Algorithms:
3D Divide and Conquer
Nearest Neighbor/
Closest Pair of Points
Closest Pair
Goal: Given n (2D) points in a set Q, find the closest pair
under the Euclidean metric in O(n lgn) time.
Divide-and-Conquer Strategy:
-X = points sorted by increasing x
-Y = points sorted by increasing y
-Divide: partition with vertical line L into PL, PR
-Conquer: recursively find closest pair in PL, PR
L, R are closest-pair distances
min( L, R )
-Combine: closest-pair is either or pair straddles partition line L
Check for pair straddling partition line L
both points must be within of L
create array Y = Y with only points in 2 strip
for each point p in Y
find (<= 7) points in Y within of p
source: 91.503 textbook Cormen et al.
Closest Pair
Correctness
33.11
Closest Pair
Running Time:
2T (n / 2) O(n) if n 3
T ( n)
O(n lg n)
O(1)
if n 3