Download presentation
Presentation is loading. Please wait.
1
UMass Lowell Computer Science 91.504 Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection
2
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
3
Demo Segment/Segment Intersection http:/cs.smith.edu/~orourke/books/CompGeom/CompGeom.html
4
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
5
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’
6
Demo Point in Polygon http:/cs.smith.edu/~orourke/books/CompGeom/CompGeom.html
7
ä 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)
8
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
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 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 */
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
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)
14
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
15
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}
16
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
17
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
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.