This preview shows page 1. Sign up to view the full content.
Unformatted text preview: UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry
Prof. Karen Daniels
Spring, 2010 Spring O'Rourke Chapter 7 Search & Intersection Chapter Ch t 7 Search & Intersection
SegmentSegmentSegment Intersection SegmentSegmentTriangle 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 SegmentSegment Intersection
Finding the actual intersection point Approach: parametric vs. slope/intercept
p parametric generalizes to more complex g p intersections i i Parameterize each segment
Lcd c b a d Lab Lcd c C=dC=dc Lab b q(t)=c+tC d A=bA=ba a p( ) p(s)=a+sA Intersection: values of s, t such that p(s) =q(t) : a+sA=c+tC a+sA= SegmentTriangle Intersection Determine if qr intersects plane containing q p g triangle T. Let N=(A,B,C) be normal to :(x,y,z) (A,B,C)=D (i.e. = Ax + By + Cy = D) (A,B,C) D Find normal N using crossproducts involving a, b, c crossparameterize qr: p(t) = q + t(rq) qr: t(rq solve for t : t = Dr (q)N ) (  N using t, find point of intersection p if it exists p is in T iff its projection p' is in a projection* T' of T +to xy, xz or yzplane yz r c a T
N p b q Classify relationship between p and T Barycentric coordinates Check results of 3 "left of edge tests for p' with left edge" respect to T': +++ means p' inside T'. T': ++++ ++ +++ T'
+ + * avoid degeneracy by projecting out largest coordinate + ++ Point in Polygon
P q Winding number
standing at q, turn to follow border of P sum rotation to create signed angular turn + ccw  cw divide by 2 2 elegant but not practical: O(n) with large constant Ray R crossings i
extend horizontal ray from q count number of intersections with P even odd q is outside P q is inside P q P beware degenerate intersections!
O(n) Compare with using LeftOn test when polygon is convex Point in Polyhedron P q r Winding number generalizes to 3D uses solid angle Assume each face is a triangle. ( (fraction of sphere surface p used by cone at point) Ray crossing generalizes to 3D q inside P if odd number of crossings q outside P if even id number of crossings Expected time O(n) O( = expected number of tries to get nondegenerate intersection Algorithm: Algorithm: POINT in POLYHEDRON (P, R, q) g ( Compute bounding radius R loop forever r0 = random ray of length R r = q + r0 crossings = 0 for each triangle T of polyhedron P do SegTriInt(T, q, r) if degenerate intersection then go back to loop else increment crossings appropriately if crossings odd then q is inside P else q is outside P Exit Intersection of Convex Polygons For nonconvex nvertex P and mvertex Q, the worstcase size complexity of P Q h worsti l i f is in (nm) For convex P, Q, size is only in O(n + m) and can be computed in O(n + m) time
A Q P B Algorithm: Algorithm: INTERSECTION of CONVEX POLYGONS /* A is directed edge on P */ Choose A and B arbitrarily /* B is directed edge on Q */ repeat /* A, B "chase" each other */ if A intersects B then /* A, B meet at each */ t t h Check for termination /* boundary crossing */ Update inside flag Advance either A or B depending on geometric conditions until both A and B cycle their polygons Handle cases: P Q P Q P Q = 0 O(n+m) / Intersection of Segments Goal: "OutputGoal: "Outputsize sensitive" p polygon intersection algorithm Core Problem: "Outputsize Problem: "Outputsensitive" line segment intersection sensitive algorithm BentleyBentleyOttmann plane sweep: O((n+k)logn) time k = number of intersection points in output Intuition: s eep Int ition: sweep line (discrete event e ent simulation) First, review algorithm that returns TRUE iff there exists an intersection Intersection of >2 Line Segments
SweepSweepLine Algorithmic Paradigm: 33.4 source: 91.503 textbook Cormen et al. Intersection of >2 Line Segments
SweepSweepLine Algorithmic Paradigm: source: 91.503 textbook Cormen et al. Intersection of >2 Line Segments
Time to decide if any 2 segments intersect:O(n lg n) Balanced BST stores segments in order of intersection with sweep line. Associated operations take O(lgn) time. Note that it exits as soon as one intersection is detected. 33.5 source: 91.503 textbook Cormen et al. source: 91.503 textbook Cormen et al. Intersection of Segments Goal: "Outputsize sensitive" line segment intersection algorithm Goal: "Outputp g g that actually computes all intersection points BentleyOttmann plane sweep: O((n+k)log(n+k))= O((n+k)logn) time Bentley k = number of intersection points in output Intuition: sweep vertical line rightwards just before intersection, 2 segments are adjacent in sweepline intersection structure sweepcheck for intersection only adjacent segments y j g insert intersection event into sweepline structure sweepevent types: left endpoint of a segment right endpoint of a segment intersection between 2 segments swap order Improved to O(nlogn+k) [Chazelle/Edelsbrunner] I d t O( l k) [Ch ll /Ed l b ]
source: O'Rourke, Computational Geometry in C Intersection of Nonconvex Polygons Variation on BentleyBentleyOttmann sweep Maintain status for each piece of sweep line: 0: t i t 0 exterior to P, Q P: inside P, outside Q Q: inside Q, outside P PQ: inside P , inside Q For nvertex P, mvertex Q, O((n+m)log(n+m)+k) time to compute: P Q P Q P\Q Extreme Point of Convex Polygon
Algorithm: Algorithm: HIGHEST POINT of CONVEX POLYGON /* highest point i i [ b] */ hi h t i t is in [a,b] Initialize I iti li a and b d repeat forever c index midway from a to b if P[c] is locally highest then return c if A points up and C points down then [a,b] [a,c] /* highest point is in [a,c] */ else if A points down and C points up then [a,b] [c,b] /* highest point is in [c,b] */ else if A points up and C points up if P[a] is above P[c] then [a,b] [a,c] else [a,b] [c,b] /* highest point is in [c,b] */ else if A points down and C points down p p if P[a] is below P[c] then [a,b] [a,c] /* highest point is in [a,c] */ else [a,b] [c,b] /* highest point is in [c,b] */ A Geometric Binary Search
A c C a b B Unimodality Allows Binary Search O(lg n) Stabbing a Convex Polygon
ExtremeExtremeFinding algorithm can stab a convex polygon
a extreme in + u direction
+u y L x b extreme in  u direction If a and b straddle L, binary search on [a b] yields x [a,b] binary search on [b,a] yields y O(lg n) Extremal Polytope Queries: Main Idea Form sequence of O(log n) simpler nested polytopes in O(n) time To answer a query in O(logn) time: O(logn) Find extreme with respect to inner polytope, polytope, then work outwards Need only check small number of candidate vertices in next polytope independent sets in planar graphs are "large"; vertices of "low" degree to construct next (inner) polytope, remove polytope, independent set of vertices deleting constant fraction of vertices at each step produces O(logn) polytopes (derivation) O(logn) derivation) O(log n) Key idea: K id An independent set of a polytope graph of n vertices produced by INDEPENDENT SET has size at least n/18 Extremal Polytope Queries
Main Idea (continued) To use nested polytope hierarchy to answer an extreme point query: Find extreme with respect to inner p polytope Pk (bruteforce search) (brute Move from polytope Pi+1 to Pi L ai and ai+1 b uniquely highest vertices of Let d be i l hi h i f Pi and Pi+1. Then either ai = ai+1 or
Yields bounds on # edges to check. P = P0 ai+1 is the highest among the vertices adjacent to ai ai is the highest among the parents of the extreme edges Li+1 and Ri+1 L'i+1 = R'i+1 ' P'i+1 tetrahedron projected onto xz plane Extremal Polytope Queries Details
Maximum Independent Set is NPcomplete, NPbut b t greedy h i ti performs well. d heuristic f ll Choose vertex of lowest degree, not adjacent to vertices already chosen. Algorithm 7.4: INDEPENDENT SET 7.4: Input: Input: graph G Output: Output: independent set I I 0 Mark all nodes of G of d M k ll d f f degree > 9 >= while some nodes remain unmarked do Choose an unmarked node v Mark v and all neighbors of v I I U {v}
triangulate. triangulate Icosahedron Schlegel diagram: 5 triangles meet at each vertex. There exist at least n/2 vertices of degree at most 8 (d i ti ) t t (derivation). (d derivation). An independent set of a polytope graph of n vertices produced by INDEPENDENT SET has size at least n/18 (derivation). (derivation). Extremal Polytope Queries Details D il (continued) i i +1 Extremal Polytope Queries Details ( ti d) (continued) Extremal Polytope Queries
Main Idea (repeated in more detail) To use nested polytope hierarchy to answer an extreme point query: Find extreme with respect to inner p polytope Pk (bruteforce search) (brute Move from polytope Pi+1 to Pi
Yields bounds on # edges to check.
(Assume w.l.o.g. vertical query direction) w.l.o.g. L ai and ai+1 b uniquely hi h vertices of Let d be i l highest i f Pi and Pi+1. Then either ai = ai+1 or ai+1 is the highest among the vertices adjacent to ai ai is the highest among the parents of the extreme edges Li+1 and Ri+1 L'i+1 = R'i+1 (See proof sketch in future slide.) (See definition of L, R in future slide.) ' P'i+1 tetrahedron projected onto xz plane (Plane effect : see next slide) Extremal Polytope Queries Details D il (continued) For maximal z query: query: Moving from Pi+1 to Pi is like raising a plane orthogonal to z axis from ai+1 to ai...a0 i 1 Extremal Polytope Queries
Main Id ( ti d) M i Idea (continued)
Algorithm: Algorithm: EXTREME POINT of a POLYTOPE Input: Input: polytope P and direction vector u Output: Output: vertex a of P extreme in u direction Construct nested polytope hierarchy P = P0, P1,..., Pk p y p y , , ak vertex of Pk extreme in u direction Compute Lk and Rk for i = k  1, k  2, ...,1, 0 do ai extreme vertex among ai+1 and parents of Li+1 and Ri+1 for all edges incident to ai do save extreme edges Li and Ri else (ai = ai+1) compute Li f l (a t from Li+1 etc... t if ai = ai+1 then i 1 u Pk P0 After O(n) time and space preprocessing, polytope extremeextremepoint queries can be answered in O(log n) time each Extremal Polytope Queries Details (continued) D t il ( i d) Lemma 7.10.2: (repeated) Let ai and ai+1 be uniquely highest vertices 7.10.2: of Pi and Pi+1. Th either: f d Then ith ai = ai+1 or ai+1 is the highest among the vertices adjacent to ai Proof Sketch: (by cases) Sketch: ai is vertex of both Pi and Pi+1 ai = ai+1 else ai deleted in construction of Pi+1 Let bi+1 = highest vertex of Pi+1 among those adjacent to ai in Pi Claim: bi+1 is highest vertex of Pi+1 But B t we still need b till d bound on # d vertices adjacent to ai+1... Extremal Polytope Queries Details (continued) D t il ( i d) Lemma 7.10.3: Let ai and ai+1 be uniquely highest vertices of Pi and 7.10.3: Pi+1. Then either ai = ai+1 or ai is the highest among the parents of the extreme edges Li+1 and g g p g Ri+1 Proof Sketch: Sketch: Project Pi+1 onto plane orthogonal to (e.g. xz plane) Let Li+1, Ri+1 = 2 edges of Pi+1 projecting to 2 edges of P'i+1 incident to a i+1 P a' Parents of edge of are vertices of Pi from L'i+1 = R'i+1 which they derive. ' tetrahedron New extreme edges are "close" to the old. d l h ld See p. 281283 for remaining details. 281P'i+1
projected onto xz plane Extremal Polytope Queries
Main Idea (again) M i Id ( i )
Algorithm: Algorithm: EXTREME POINT of a POLYTOPE Input: Input: polytope P and direction vector u Output: Output: vertex a of P extreme in u direction Construct nested polytope hierarchy P = P0, P1,..., Pk p y p y , , ak vertex of Pk extreme in u direction Compute Lk and Rk for i = k  1, k  2, ...,1, 0 do ai extreme vertex among ai+1 and parents of Li+1 and Ri+1 for all edges incident to ai do save extreme edges Li and Ri else (ai = ai+1) compute Li f l (a t from Li+1 etc... t if ai = ai+1 then i 1 u Pk P0 After O(n) time and space preprocessing, polytope extremeextremepoint queries can be answered in O(log n) time each Planar Point Location Goal: Goal: Given a planar subdivision of n vertices, preprocess it so that point location query can be quickly answered 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 ( may need to triangulate polygonal faces) Monotone subdivision approach pp Randomized trapezoidal decomposition Planar Point Location (continued) Monotone subdivision approach: Partition subdivision (e.g. Voronoi diagram) into "horizontal" strips. "h i t l" t i Double binary search: Vertical search on strips to locate query point between 2 separators Horizontal search to locate it within 1 strip O(log2n) query time Planar Point Location (continued) And now for something completely different... g p y As foreshadowed in Ch. 2 (polygon partitioning) Seidel's randomized trapezoidal decomposition for noncrossing nonsegments:
Assume no 2 points are at same height. O(nlogn) O(nlogn) construction time: extend
horizontal line through each endpoint. O(logn) O(logn) query time. Planar Point Location (continued) Lemma allows us to incrementally build binary search tree. 3 types of nodes:
1. 2. 3. internal X nodes, which branch left or right of a segment si internal Y nodes, which branch above or below a segment endpoint Leaf trapezoid nodes. Planar Point Location (continued) Planar Point Location (continued) Planar Point Location (continued) ...
View
Full
Document
This note was uploaded on 02/13/2012 for the course CS 91.504 taught by Professor Daniels during the Spring '10 term at UMass Lowell.
 Spring '10
 DANIELS
 Algorithms

Click to edit the document details