UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection.

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Geometry Introduction
Polygon Triangulation
Computational Geometry
Computational Geometry
Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing.
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
Brute-Force Triangulation
Convex Hull obstacle start end Convex Hull Convex Hull
One of the most important problems is Computational Geometry is to find an efficient way to decide, given a subdivision of E n and a point P, in which.
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.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Zoo-Keeper’s Problem An O(nlogn) algorithm for the zoo-keeper’s problem Sergei Bespamyatnikh Computational Geometry 24 (2003), pp th CGC Workshop.
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
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,
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 4 Chapter 6: Arrangements Monday,
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
UMass Lowell Computer Science Graduate Algorithms Prof. Karen Daniels Spring, 2005 Computational Geometry Overview from Cormen, et al. Chapter 33.
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 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Chapter 4: 3D Convex Hulls Friday, 2/9/07.
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
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Tuesday, 5/7/02 Computational Geometry Chapter 33.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 8 Motion Planning.
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
Voronoi Diagrams.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 2 Chapter 2: Polygon Partitioning.
UMass Lowell Computer Science Graduate Algorithms Prof. Karen Daniels Spring, 2009 Computational Geometry Overview from Cormen, et al. Chapter 33.
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 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 O’Rourke Chapter 8 Motion Planning.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
Collision handling: detection and response
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 7 Search & Intersection.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 O’Rourke Chapter 7 Search & Intersection.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
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.
1 Triangulation Supplemental From O’Rourke (Chs. 1&2) Fall 2005.
Computational Geometry Piyush Kumar (Lecture 10: Point Location) Welcome to CIS5930.
Computational Geometry: Intersection Search Joseph S. B. Mitchell Stony Brook University.
An Introduction to Computational Geometry Joseph S. B. Mitchell Stony Brook University.
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
February 17, 2005Lecture 6: Point Location Point Location (most slides by Sergi Elizalde and David Pritchard)
1 Point Location Strategies Idit Haran
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 O’Rourke Chapter 6 with some material.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Polygon Triangulation
Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry
An Introduction to Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry Capter:1-2.1
I. The Problem of Molding
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
Prof. Harriet Fell Fall 2011 Lecture 9 – September 26, 2011
Presentation transcript:

UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection

Chapter 7 Search & Intersection Segment-Segment Intersection Segment-Triangle Intersection Point in Polygon Point in Polyhedron Intersection of Convex Polygons Intersection of Segments Intersection of Nonconvex Polygons Extreme Point of Convex Polygon Extremal Polytope Queries Planar Point Location

Demo Segment/Segment Intersection

Segment-Segment Intersection ä Finding the actual intersection point ä Approach: parametric vs. slope/intercept ä parametric generalizes to more complex intersections ä Parameterize each segment a b c d L ab L cd a b c d L ab L cd A=b-a p(s)=a+sA Intersection: values of s, t such that p(s) =q(t) : a+sA=c+tC q(t)=c+tC C=d-c

Segment-Triangle Intersection  Determine if qr intersects plane  containing triangle T.  Let N=(A,B,C) be normal to    :(x,y,z)dot(A,B,C)=D ä find N using cross-products involving a,b,c ä parameterize qr: p(t) = q + t(r-q) ä solve for t: ä using t, find point of intersection p if it exists ä Classify relationship between p and T ä p is in T iff it is in a projection* T’ of T to xy, xz or yz-plane  T a b c qrN p * avoid degeneracy by projecting out largest coordinate T’

Demo Point in Polygon

ä Winding number ä standing at q, turn to follow border of P ä sum rotation to create signed angular turn + ccw - cw  divide by 2  ä elegant but not practical: O(n) with large constant ä Ray crossings ä extend horizontal ray from q ä count number of intersections with P ä even q is outside P ä odd q is inside P ä beware degenerate intersections! Compare with using LeftOn test when polygon is convex q P q P O(n)

Point in Polyhedron ä Winding number generalizes to 3D ä uses solid angle (fraction of sphere used by cone at point) ä Ray crossing generalizes to 3D ä q inside P if odd number of crossings ä q outside P if even number of crossings Algorithm: POINT in POLYHEDRON Compute bounding radius R loop forever r 0 = random ray of length R r 0 = random ray of length R r = q + r 0 r = q + r 0 crossings = 0 crossings = 0 for each triangle T of polyhedron P do for each triangle T of polyhedron P do SegTriInt(T, q, r) if degenerate intersection if degenerate intersection then go back to loop then go back to loop else increment crossings appropriately else increment crossings appropriately if crossings odd if crossings odd then q is inside P then q is inside P else q is outside P else q is outside P Exit Exit q P O(  n)  = number of tries to get nondegenerate intersection

Demo Convex Polygon Intersection

Intersection of Convex Polygons ä For n-vertex P and m-vertex Q, the worst- case size complexity of is in ä For convex P, Q, size is only in and can be computed in time Algorithm: INTERSECTION of CONVEX POLYGONS Choose A and B arbitrarily repeat if A intersects B then if A intersects B then Check for termination Update inside flag Advance either A or B Advance either A or B depending on geometric conditions until both A and B cycle their polygons Handle cases: O(n+m) /* A, B “chase” each other */ /* A is directed edge on P */ /* B is directed edge on Q */ /* A, B meet at each */ /* boundary crossing */

Intersection of Segments ä Goal: “Output-size sensitive” polygon intersection algorithm ä Core Problem: “Output-size sensitive” line segment intersection algorithm ä Bentley-Ottmann plane sweep: 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 segments that adjacent ä event types: ä top endpoint of a segment ä bottom endpoint of a segment ä intersection between 2 segments Improved to O(nlogn+k) [Chazelle/Edelsbrunner]

Intersection of Nonconvex Polygons ä Variation on Bentley- Ottmann sweep ä Maintain status for each piece of sweep line ä 0: exterior to P, Q ä P: inside P, outside Q ä Q: inside Q, outside P ä PQ: inside P, inside Q For n-vertex P, m-vertex Q, O((n+m)log(n+m)+k) time to compute:

Extreme Point of Convex Polygon Algorithm: HIGHEST POINT of CONVEX POLYGON Initialize a and b repeat forever c index midway from a to b c index midway from a to b if P[c] is locally highest then return c if P[c] is locally highest then return c if A points up and C points down if A points up and C points down then [a,b] [a,c] then [a,b] [a,c] else if A points down and C points up else if A points down and C points up then [a,b] [c,b] else if A points up and C points up else if A points up and C points up if P[a] is above P[c] then [a,b] [a,c] then [a,b] [a,c] then [a,b] [c,b] then [a,b] [c,b] else if A points down and C points down else if A points down and C points down if P[a] is below P[c] then [a,b] [a,c] then [a,b] [a,c] then [a,b] [c,b] then [a,b] [c,b] A Geometric Binary Search b a A B C c /* highest point is in [a,c] */ /* highest point is in [c,b] */ /* highest point is in [a,b] */ /* highest point is in [a,c] */ /* highest point is in [c,b] */ UnimodalityAllows Binary Search O(lg n)

Stabbing a Convex Polygon Extreme-Finding algorithm can stab a convex polygon If a and b straddle L, binary search on [a,b] yields x binary search on [b,a] yields y O(lg n) extreme in + u direction bax L +u y extreme in - u direction

Extremal Polytope Queries ä Form sequence of O(log n) simpler nested polytopes in O(n) time ä To answer a query in O(logn) time: ä Find extreme with respect to inner polytope, then work outwards ä Need only check small number of candidate vertices in next polytope ä Key idea: ä independent sets in planar graphs are “large”; vertices of “low” degree ä to construct next (inner) polytope, remove independent set of vertices ä deleting constant fraction of vertices at each step produces O(logn) polytopes O(log n) An independent set of a polytope graph of n vertices produced by INDEPENDENT SET has size at least n/18 Algorithm: INDEPENDENT SET Input: graph G Output: independent set I I 0 Mark all nodes of G of degree >= 9 while some nodes remain unmarked do do Choose an unmarked node v Choose an unmarked node v Mark v and all neighbors of v Mark v and all neighbors of v I I U {v} I I U {v}

Extremal Polytope Queries (continued) ä To use nested polytope hierarchy to answer an extreme point query: ä Find extreme with respect to inner polytope (brute-force search) ä Moving from polytope P i+1 to P i ä Let a i and a i+1 be uniquely highest vertices of P i and P i+1. Then either a i = a i+1 or ä a i+1 is the highest among the vertices adjacent to a i ä a i is the highest among the parents of the extreme edges L i+1 and R i+1  P’ i+1 tetrahedronprojected onto xz plane ’’’’’’’’ L’ i+1 = R’ i+1

Extremal Polytope Queries (continued)  Algorithm: EXTREME POINT of a POLYTOPE Input: polytope P and direction vector u Output: vertex a of P extreme in u direction Construct nested polytope hierarchy P = P 0, P 1,..., P k a k vertex of P k extreme in u direction Compute L k and R k for i = k - 1, k - 2,...,1, 0 do a i extreme vertex among a i+1 and parents of L i+1 and R i+1 a i extreme vertex among a i+1 and parents of L i+1 and R i+1 if a i = a i+1 then if a i = a i+1 then for all edges incident to a i do for all edges incident to a i do save extreme edges L i and R i else (a i = a i+1 ) compute L i from L i+1 etc... else (a i = a i+1 ) compute L i from L i+1 etc... After O(n) time and space preprocessing, polytope extreme-point queries can be answered in O(log n) time each u P0P0P0P0 PkPkPkPk

Planar Point Location ä Goal: Given a planar subdivision of n vertices, preprocess it so that point location query can be quickly answered. ä A polygonal planar subdivision can be preprocessed in O(n) time and space for O(log n) query. ä 2D version/variant of independent set/nested approach ä Monotone subdivision approach ä Randomized trapezoidal decomposition