UMass Lowell Computer Science 91.503 Graduate Algorithms Prof. Karen Daniels Spring, 2005 Computational Geometry Overview from Cormen, et al. Chapter 33.

Slides:



Advertisements
Similar presentations
Geometry Introduction
Advertisements

Computational Geometry
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
C o m p u t i n g C O N V E X H U L L S by Kok Lim Low 10 Nov 1998 COMP Presentation.
The Divide-and-Conquer Strategy
1 Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
CS4413 Divide-and-Conquer
Ruslana Mys Delaunay Triangulation Delaunay Triangulation (DT)  Introduction  Delaunay-Voronoi based method  Algorithms to compute the convex hull 
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Divide and Conquer.
1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)
Computational Geometry
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 Lecture 2 Polygon Partitioning Thursday,
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/4/01.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2005 Lecture 1 (Part 1) Introduction/Overview Tuesday, 1/25/05.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2009 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Th. 9/3/2009.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection.
Chapter 4 Divide-and-Conquer Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Chapter 5: Voronoi Diagrams Wednesday,
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2003 Review Lecture Tuesday, 5/6/03.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Chapter 4: 3D Convex Hulls Friday, 2/9/07.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/3/02.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Lecture 2 Chapter 2: Polygon Partitioning.
Computational Geometry Overview from Cormen, et al. Chapter 33
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Review Lecture Tuesday, 12/10/02.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Tuesday, 5/7/02 Computational Geometry Chapter 33.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 1 Introduction/Overview Wed. 9/5/01.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 1 Course Introduction.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 2 Chapter 2: Polygon Partitioning.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2005 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 9/7/05.
UMass Lowell Computer Science Graduate Algorithms Prof. Karen Daniels Spring, 2009 Computational Geometry Overview from Cormen, et al. Chapter 33.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 1 (Part 1) Introduction/Overview Wednesday, 9/8/04.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Chapter 4: 3D Convex Hulls Monday, 2/23/04.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2007 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 1/24/07.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 1 Introduction/Overview Wed. 1/31/01.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2000 Lecture 1 Introduction/Overview Wed. 9/6/00.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 3 Chapter 4: 3D Convex Hulls Chapter.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 (Part 1) Introduction/Overview Tuesday, 1/29/02.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Thurs.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 7 Search & Intersection.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 O’Rourke Chapter 7 Search & Intersection.
Computational Geometry (35/33) Line Segments and cross-product Segment intersection and Sweep Line Convex Hull and Graham’s Scan, Jarvis’s march Divide-and-Conquer.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 5 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
5 -1 Chapter 5 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
Computational Geometry Course Summary (First Half) Spring 2008 Pay special attention to: algorithm details (able to explain correctness and carry out a.
C o m p u t i n g C O N V E X H U L L S. Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Lecture 1 (Part 1) Introduction/Overview Tuesday, 1/27/09.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 4: 3D Convex Hulls Thursday,
Computational Geometry 2D Convex Hulls
Lecture 15 Computational Geometry Geometry sweeping Geometric preliminaries Some basics geometry algorithms.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Review Lecture Tuesday, 12/11/01.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 6 with some material.
CMPS 3130/6130 Computational Geometry Spring 2017
Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/9/08
Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 1/28/04
CSCE350 Algorithms and Data Structure
Algorithm design techniques Dr. M. Gavrilova
Computational Geometry (35/33)
CHAPTER 33 Computational Geometry
Presentation transcript:

UMass Lowell Computer Science 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 Telecommunications Visualization Manufacturing ComputerGraphics Design Analyze Apply CAD

Sample Application Areas Computer Graphics Geographic Information Systems Robotics Bioinformatics Astrophysics MedicalImaging Telecommunications Data Mining & Visualization

Typical Problems ä bin packing ä Voronoi diagram ä simplifying polygons ä shape similarity ä convex hull ä maintaining line arrangements ä polygon partitioning ä nearest neighbor search ä kd-trees SOURCE: Steve Skiena’s Algorithm Design Manual (for problem descriptions, see graphics gallery at ) (for problem descriptions, see graphics gallery at

Common Computational Geometry Structures Voronoi Diagram Convex Hull New Point source: O’Rourke, Computational Geometry in C Delaunay Triangulation

Sample Tools of the Trade Algorithm Design Patterns/Techniques: binary searchdivide-and-conquerduality randomizationsweep-line derandomizationparallelism Algorithm Analysis Techniques: asymptotic analysis, amortized analysis Data Structures: winged-edge, quad-edge, range tree, kd-tree Theoretical Computer Science principles: NP-completeness, hardness Growth of Functions Summations Recurrences Sets Probability MATH Proofs Geometry Graph Theory Combinatorics Linear Algebra

Computational Geometry in Context TheoreticalComputerScience Applied Computer Science AppliedMath Geometry ComputationalGeometryEfficient Geometric Algorithms Design Analyze Apply

Sample of Supporting Algorithmic & Math Areas & Techniques ä Computational Geometry ä Convex hulls ä Visibility polygons ä Arrangements ä Mathematical Programming ä Linear programming ä Integer programming ä Lagrangian relaxation ä Upper, lower bounding ä Dynamic Data Structures ä Algorithm Design Patterns ä search space subdivision ä binary search ä divide-and-conquer ä sweep-line ä discrete-event simulation ä Algorithm Analysis Techniques ä Complexity Theory ä NP-completeness, hardness ä Discrete Math ä Minkowski sum ä Monotone matrices ä Lattices ä Set operations: union, intersection, difference

Line Segment Intersections (2D) Intersection of 2 Line Segments Intersection of > 2Line Segments

Cross-Product-Based Geometric Primitives source: textbook Cormen et al. p0p0p0p0 p2p2p2p2 p1p1p1p1 (1) p1p1p1p1 p3p3p3p3 p2p2p2p2 (2) p2p2p2p2 p1p1p1p1 p3p3p3p3 p4p4p4p4 (3) Some fundamental geometric questions:

Cross-Product-Based Geometric Primitives: (1) source: textbook Cormen et al. Advantage: less sensitive to accumulated round-off error p0p0p0p0 p2p2p2p2 p1p1p1p1 (1) 33.1

Cross-Product-Based Geometric Primitives: (2) source: textbook Cormen et al. p0p0p0p0 p2p2p2p2 p1p1p1p1 (2) 33.2

Intersection of 2 Line Segments source: textbook Cormen et al. p2p2p2p2 p1p1p1p1 p3p3p3p3 p4p4p4p4 (3) Step 1: Bounding Box Test Step 2: Does each segment straddle the line containing the other? 33.3 p3 and p4 on opposite sides of p1p2

Segment-Segment Intersection ä Finding the actual intersection point ä Approach: parametric vs. slope/intercept ä parametric generalizes to more complex intersections ä e.g. segment/triangle ä Parameterize each segment Intersection: values of s, t such that p(s) =q(t) : a+sA=c+tC a b c d L ab L cd a b c d L ab L cd A=b-a p(s)=a+sA q(t)=c+tC C=d-c source: O’Rourke, Computational Geometry in C 2 equations in unknowns s, t : 1 for x, 1 for y

Demo Segment/Segment Intersection

Intersection of >2 Line Segments source: textbook Cormen et al. Sweep-Line Algorithmic Paradigm: 33.4

Intersection of >2 Line Segments source: textbook Cormen et al. Sweep-Line Algorithmic Paradigm:

Intersection of >2 Line Segments source: textbook Cormen et al. Time to detect if any 2 segments intersect: O(n lg n) source: textbook Cormen et al Note that it exits as soon as one intersection is detected. Balanced BST stores segments in order of intersection with sweep line. Associated operations take O(lgn) time.

Intersection of Segments ä Goal: “Output-size sensitive” line segment intersection algorithm that actually computes all intersection points ä Bentley-Ottmann plane sweep: O((n+k)log(n+k))= O((n+k)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 adjacent segments ä insert intersection event into sweep-line structure ä event types: ä top endpoint of a segment ä bottom endpoint of a segment ä intersection between 2 segments ä swap order Improved to O(nlogn+k) [Chazelle/Edelsbrunner] source: O’Rourke, Computational Geometry in C

Convex Hull Algorithms Definitions Gift Wrapping Graham Scan QuickHullIncrementalDivide-and-Conquer Lower Bound in  (nlgn)

Convexity & Convex Hulls  A convex combination of points x 1,..., x k is a sum of the form  1 x  k x k where ä Convex hull of a set of points is the set of all convex combinations of points in the set. nonconvex polygon convex hull of a point set source: O’Rourke, Computational Geometry in C source: textbook Cormen et al.

Naive Algorithms for Extreme Points Algorithm: INTERIOR POINTS for each i do for each j = i do for each j = i do for each k = j = i do for each k = j = i do for each L = k = j = i do for each L = k = j = i do if p L in triangle(p i, p j, p k ) then p L is nonextreme O(n 4 ) Algorithm: EXTREME EDGES for each i do for each j = i do for each j = i do for each k = j = i do for each k = j = i do if p k is not left or on (p i, p j ) if p k is not left or on (p i, p j ) then (p i, p j ) is not extreme O(n 3 ) source: O’Rourke, Computational Geometry in C

Algorithms: 2D Gift Wrapping ä Use one extreme edge as an anchor for finding the next  O(n 2 ) Algorithm: GIFT WRAPPING i 0 index of the lowest point i i 0 repeat for each j = i for each j = i Compute counterclockwise angle  from previous hull edge Compute counterclockwise angle  from previous hull edge k index of point with smallest  k index of point with smallest  Output (p i, p k ) as a hull edge Output (p i, p k ) as a hull edge i k i k until i = i 0 source: O’Rourke, Computational Geometry in C

Gift Wrapping source: textbook Cormen et al Output Sensitivity: O(n 2 ) run-time is actually O(nh) where h is the number of vertices of the convex hull.

Algorithms: 3D Gift Wrapping CxHull Animations: O(n 2 ) time [output sensitive: O(nF) for F faces on hull]

Algorithms: 2D QuickHull ä Concentrate on points close to hull boundary ä Named for similarity to Quicksort a b O(n 2 ) Algorithm: QUICK HULL function QuickHull(a,b,S) if S = 0 return() if S = 0 return() else else c index of point with max distance from ab c index of point with max distance from ab A points strictly right of (a,c) A points strictly right of (a,c) B points strictly right of (c,b) B points strictly right of (c,b) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) return QuickHull(a,c,A) + (c) + QuickHull(c,b,B) source: O’Rourke, Computational Geometry in C finds one of upper or lower hull c A

Algorithms: 3D QuickHull CxHull Animations:

Algorithms: >= 2D Qhull: Convex Hull boundary is intersection of hyperplanes, so worst-case combinatorial size (not necessarily running time) complexity is in:

Graham’s Algorithm ä Points sorted angularly provide “star-shaped” starting point ä Prevent “dents” as you go via convexity testing O(nlgn) Algorithm: GRAHAM SCAN, Version B Find rightmost lowest point; label it p 0. Sort all other points angularly about p 0. In case of tie, delete point(s) closer to p 0. In case of tie, delete point(s) closer to p 0. Stack S (p 1, p 0 ) = (p t, p t-1 ); t indexes top i 2 while i < n do if p i is strictly left of p t-1 p t then Push(p i, S) and set i i +1 else Pop(S)  source: O’Rourke, Computational Geometry in C “multipop” p0p0p0p0

Graham Scan source: textbook Cormen et al.

Graham Scan source: textbook Cormen et al. 33.7

Graham Scan source: textbook Cormen et al. 33.7

Graham Scan source: textbook Cormen et al.

Graham Scan source: textbook Cormen et al.

Algorithms: 2D Incremental ä Add points, one at a time ä update hull for each new point ä Key step becomes adding a single point to an existing hull. ä Find 2 tangents ä Results of 2 consecutive LEFT tests differ ä Idea can be extended to 3D. O(n 2 ) Algorithm: INCREMENTAL ALGORITHM Let H 2 ConvexHull{p 0, p 1, p 2 } for k 3 to n - 1 do H k ConvexHull{ H k-1 U p k } H k ConvexHull{ H k-1 U p k } can be improved to O(nlgn) source: O’Rourke, Computational Geometry in C

Algorithms: 3D Incremental CxHull Animations: O(n 2 ) time

Algorithms: 2D Divide-and-Conquer ä 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 can be extended to 3D. 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) A B source: O’Rourke, Computational Geometry in C

Algorithms: 3D Divide and Conquer CxHull Animations: O(n log n) time !

Lower Bound of O(nlgn)  Worst-case time to find convex hull of n points in algebraic decision tree model is in  (nlgn) ä Proof uses sorting reduction: ä Given unsorted list of n numbers: (x 1,x 2,…, x n ) ä Form unsorted set of points: (x i, x i 2 ) for each x i ä Convex hull of points produces sorted list! ä Parabola: every point is on convex hull ä Reduction is O(n) (which is in o(nlgn))  Finding convex hull of n points is therefore at least as hard as sorting n points, so worst-case time is in  (nlgn) Parabola for sorting 2,1,3 source: O’Rourke, Computational Geometry in C

Nearest Neighbor/ Closest Pair of Points

Closest Pair source: textbook Cormen et al. 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 P L, P R - -Conquer: recursively find closest pair in P L, P R - -  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

Closest Pair source: textbook Cormen et al. Correctness 33.11

Closest Pair Running Time: Key Point: Presort points, then at each step form sorted subset of sorted array in linear time Like opposite of MERGE step in MERGESORT… source: textbook Cormen et al. R L

Additional Computational Geometry Resources ä Computational Geometry in C ä second edition ä by Joseph O’Rourke ä Cambridge University Press ä 1998 Web Site: See also Course Web Site: