UMass%20Lowell%20Computer%20Science%2091.503%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Spring,%202002 - PowerPoint PPT Presentation

View by Category
About This Presentation
Title:

UMass%20Lowell%20Computer%20Science%2091.503%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Spring,%202002

Description:

Science. Applied Computer Science. Applied. Math. Geometry. Computational. Geometry. Efficient ... Add points, one at a time. update hull for each new point ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 44
Provided by: murrayd
Learn more at: http://www.cs.uml.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: UMass%20Lowell%20Computer%20Science%2091.503%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Spring,%202002


1
UMass Lowell Computer Science 91.503 Analysis
of Algorithms Prof. Karen Daniels Spring, 2002
  • Tuesday, 5/7/02
  • Computational Geometry
  • Chapter 33

2
Relevant Sections of Chapter 35
Youre responsible for material in this chapter
that we discuss in lecture. (Note that this
includes all sections.)
Ch33 Computational Geometry
3
Overview
  • Computational Geometry Introduction
  • Line Segment Intersection
  • Convex Hull Algorithms
  • Nearest Neighbors/Closest Points

4
Computational Geometry
Computer Graphics
Visualization Bioinformatics

Design
Analyze
Core Geometric Algorithms
Application-Based Algorithms
Apply
Telecommunications
5
Typical Problems
  • maintaining line arrangements
  • polygon partitioning
  • nearest neighbor search
  • kd-trees
  • bin packing
  • Voronoi diagram
  • simplifying polygons
  • shape similarity
  • convex hull

SOURCE Steve Skienas Algorithm Design Manual
(for problem descriptions, see graphics gallery
at http//www.cs.sunysb.edu/algorith)
6
Common Computational Geometry Structures
source ORourke, Computational Geometry in C
7
Sample Tools of the Trade
Algorithm Design Patterns/Techniques binary
search divide-and-conquer duality randomization sw
eep-line derandomization parallelism Algorithm
Analysis Techniques asymptotic analysis,
amortized analysis Data Structures winged-edge,
quad-edge, range tree, kd-tree Theoretical
Computer Science principles NP-completeness,
hardness
MATH
Sets
Proofs
Geometry
Summations
Linear Algebra
Probability
Growth of Functions
Recurrences
Graph Theory
Combinatorics
8
Computational Geometry in Context
9
Line Segment Intersections (2D)
  • Intersection of 2 Line Segments
  • Intersection of gt 2Line Segments

10
Cross-Product-Based Geometric Primitives
Some fundamental geometric questions
source 91.503 textbook Cormen et al.
(1)
11
Cross-Product-Based Geometric Primitives (1)
33.1
Advantage less sensitive to accumulated
round-off error
source 91.503 textbook Cormen et al.
12
Cross-Product-Based Geometric Primitives (2)
33.2
source 91.503 textbook Cormen et al.
13
Intersection of 2 Line Segments
Step 1 Bounding Box Test
33.3
Step 2 Does each segment straddle the line
containing the other?
source 91.503 textbook Cormen et al.
14
Segment-Segment Intersection
  • Finding the actual intersection point
  • Approach parametric vs. slope/intercept
  • parametric generalizes to more complex
    intersections
  • Parameterize each segment

Lab
c
Lcd
Cd-c
b
q(t)ctC
d
Ab-a
a
p(s)asA
Intersection values of s, t such that p(s) q(t)
asActC
source ORourke, Computational Geometry in C
15
Demo
  • Segment/Segment Intersection
  • http/cs.smith.edu/orourke/books/CompGeom/CompGeo
    m.html

16
Intersection of gt2 Line Segments
Sweep-Line Algorithmic Paradigm
33.4
source 91.503 textbook Cormen et al.
17
Intersection of gt2 Line Segments
Sweep-Line Algorithmic Paradigm
source 91.503 textbook Cormen et al.
18
Intersection of gt2 Line Segments
Time to detect if any 2 segments intersect
O(n lg n)
33.5
source 91.503 textbook Cormen et al.
source 91.503 textbook Cormen et al.
19
Intersection of Segments
  • Goal Output-size sensitive line segment
    intersection algorithm that actually computes
    intersection points
  • Bentley-Ottmann plane sweep O((nk)logn) time
  • k number of intersection points in output
  • Intuition sweep horizontal line downwards
  • just before intersection, 2 segments are adjacent
    in sweep-line intersection structure
  • check for intersection only segments that
    adjacent
  • event types
  • top endpoint of a segment
  • bottom endpoint of a segment
  • intersection between 2 segments

Improved to O(nlognk) Chazelle/Edelsbrunner
source ORourke, Computational Geometry in C
20
Convex Hull Algorithms
  • Definitions
  • Gift Wrapping
  • Graham Scan
  • QuickHull
  • Incremental
  • Divide-and-Conquer
  • Lower Bound in W(nlgn)

21
Convexity Convex Hulls
source ORourke, Computational Geometry in C
  • A convex combination of points x1, ..., xk is a
    sum of the form a1x1... akxk where
  • Convex hull of a set of points is the set of all
    convex combinations of points in the set.

source 91.503 textbook Cormen et al.
22
Naive Algorithms for Extreme Points
O(n4)
source ORourke, Computational Geometry in C
23
Algorithms 2D Gift Wrapping
  • Use one extreme edge as an anchor for finding the
    next

source ORourke, Computational Geometry in C
24
Gift Wrapping
33.9
source 91.503 textbook Cormen et al.
25
Algorithms 3D Gift Wrapping
O(n2) time output sensitive O(nF) for F faces
on hull
CxHull Animations http//www.cse.unsw.edu.au/lam
bert/java/3d/hull.html
26
Algorithms 2D QuickHull
  • Concentrate on points close to hull boundary
  • Named for similarity to Quicksort

source ORourke, Computational Geometry in C
27
Algorithms 3D QuickHull
CxHull Animations http//www.cse.unsw.edu.au/lam
bert/java/3d/hull.html
28
Algorithms Qhull (gt 2D )
http//www.geom.umn.edu/software/qhull/
29
Grahams Algorithm
source ORourke, Computational Geometry in C
  • Points sorted angularly provide star-shaped
    starting point
  • Prevent dents as you go via convexity testing

30
Graham Scan
source 91.503 textbook Cormen et al.
31
Graham Scan
33.7
source 91.503 textbook Cormen et al.
32
Graham Scan
33.7
source 91.503 textbook Cormen et al.
33
Graham Scan
source 91.503 textbook Cormen et al.
34
Graham Scan
source 91.503 textbook Cormen et al.
35
Algorithms 2D Incremental
source ORourke, Computational Geometry in C
  • Add points, one at a time
  • update hull for each new point
  • Key step becomes adding a single point to an
    existing hull.
  • Idea is extended to 3D in Chapter 4.

Algorithm INCREMENTAL ALGORITHM Let H2
ConvexHullp0 , p1 , p2 for k 3 to n - 1
do Hk ConvexHull Hk-1 U pk
O(n2)
can be improved to O(nlgn)
36
Algorithms 3D Incremental
O(n2) time
CxHull Animations http//www.cse.unsw.edu.au/lam
bert/java/3d/hull.html
37
Algorithms 2D Divide-and-Conquer
source ORourke, Computational Geometry in C
  • Divide-and-Conquer in a geometric setting
  • O(n) merge step is the challenge
  • Find upper and lower tangents
  • Lower tangent find rightmost pt of A leftmost
    pt of B then walk it downwards
  • Idea is extended to 3D in Chapter 4.

B
A
Algorithm DIVIDE-and-CONQUER Sort points by x
coordinate Divide points into 2 sets A and B A
contains left n/2 points B contains right n/2
points Compute ConvexHull(A) and ConvexHull(B)
recursively Merge ConvexHull(A) and ConvexHull(B)
O(nlgn)
38
Algorithms 3D Divide and Conquer
O(n log n) time !
CxHull Animations http//www.cse.unsw.edu.au/lam
bert/java/3d/hull.html
39
Lower Bound of O(nlgn)
source ORourke, Computational Geometry in C
  • Worst-case time to find convex hull of n points
    in algebraic decision tree model is in W(nlgn)
  • Proof uses sorting reduction
  • Given unsorted list of n numbers (x1,x2 ,, xn)
  • Form unsorted set of points (xi, xi2) for each
    xi
  • Convex hull of points produces sorted list!
  • Parabola every point is on convex hull
  • Reduction is O(n) (which is o(nlgn))
  • Finding convex hull of n points is therefore at
    least as hard as sorting n points, so worst-case
    time is in W(nlgn)

Parabola for sorting 2,1,3
40
Nearest Neighbor/ Closest Pair of Points
41
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
  • dL, dR are closest-pair distances
  • d min( dL, dR )
  • Combine closest-pair is either d or pair
    straddles partition line L
  • Check for pair straddling partition line L
  • both points must be within d of L
  • create array Y Y without points in 2d
    strip
  • for each point p in Y
  • find (lt 7) points in Y within d of p

source 91.503 textbook Cormen et al.
42
Closest Pair
Correctness
33.11
source 91.503 textbook Cormen et al.
43
Closest Pair
Running Time
Key Point Presort points, then at each step form
sorted subset of sorted array in linear time
source 91.503 textbook Cormen et al.
About PowerShow.com