1 / 18

O’Rourke Chapter 7 Search & Intersection

UMass Lowell Computer Science 91.504 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

lester-shaw
Télécharger la présentation

O’Rourke Chapter 7 Search & Intersection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UMass Lowell Computer Science 91.504Advanced AlgorithmsComputational GeometryProf. Karen DanielsSpring, 2004 O’Rourke Chapter 7 Search & Intersection

  2. Chapter 7Search & 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

  3. Demo Segment/Segment Intersection http:/cs.smith.edu/~orourke/books/CompGeom/CompGeom.html

  4. Lab c Lcd b d a 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 C=d-c b q(t)=c+tC d A=b-a a p(s)=a+sA Intersection: values of s, t such that p(s) =q(t) : a+sA=c+tC

  5. r p c p N T b a q +-- +-+ ++- +++ --+ -++ -+- Segment-Triangle Intersection • Determine if qr intersects plane p containing triangle T. • Let N=(A,B,C) be normal to p • p :(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’ * avoid degeneracy by projecting out largest coordinate

  6. Demo Point in Polygon http:/cs.smith.edu/~orourke/books/CompGeom/CompGeom.html

  7. q P 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 2p • 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! q P Compare with using LeftOn test when polygon is convex O(n)

  8. Point in Polyhedron P q • 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 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 O(rn) r = number of tries to get nondegenerate intersection

  9. Demo Convex Polygon Intersection http:/cs.smith.edu/~orourke/books/CompGeom/CompGeom.html

  10. 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 Check for termination Update inside flag Advance either A or B depending on geometric conditions until both A and B cycle their polygons Handle cases: /* A is directed edge on P */ /* B is directed edge on Q */ /* A, B “chase” each other */ /* A, Bmeet at each */ /* boundary crossing */ O(n+m)

  11. 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]

  12. 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:

  13. a b Extreme Point of Convex Polygon Algorithm: HIGHEST POINT of CONVEX POLYGON Initialize a and b 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] else if A points down and C points up then [a,b] [c,b] else if A points up and C points up if P[a] is above P[c] then [a,b] [a,c] then [a,b] [c,b] else if A points down and C points down if P[a] is below P[c] then [a,b] [a,c] then [a,b] [c,b] A Geometric Binary Search /* highest point is in [a,b] */ A c C /* highest point is in [a,c] */ /* highest point is in [c,b] */ B Unimodality Allows Binary Search /* highest point is in [c,b] */ /* highest point is in [a,c] */ O(lg n) /* highest point is in [c,b] */

  14. a extreme in + u direction +u y extreme in - u direction x L b 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)

  15. 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 Choose an unmarked node v Mark v and all neighbors of v II U {v} 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 An independent set of a polytope graph of n vertices produced by INDEPENDENT SET has size at least n/18 O(log n)

  16. tetrahedron projected onto xz plane 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 Pi+1 to Pi • Let ai and ai+1 be uniquely highest vertices of 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 p L’i+1 = R’i+1 p’’ P’i+1

  17. 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 = P0, P1,..., Pk 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 if ai = ai+1 then for all edges incident to ai do save extreme edges Li and Ri else (ai = ai+1) compute Li from Li+1 etc... p Extremal Polytope Queries(continued) u Pk P0 After O(n) time and space preprocessing, polytope extreme-point queries can be answered in O(log n) time each

  18. 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

More Related