Você está na página 1de 3

CS661 Geometric Algorithms EXAM 2

PRASANTHI KORNEPATI - 815269423


3.12) The pockets of a simple polygon are the areas outside the polygon, but inside its convex hull. Let P1 be a simple polygon with m vertices, and assume that a triangulation of P1 as well as its pockets is given. Let P2 be a convex polygon with n vertices. Show that the intersection P1 P2 can be computed in O(m+n) time.

Solution: First obtain the convex hull H1 of P1 by traversing the outer boundary of the triangulation of P1 and its pockets. This takes time O(m). Next, compute the convex hull H2 of H1 and P2 in O(m + n) time There are three cases: H1 H2 = P2 Then the intersection P1 P2 = P1. Simply report P1. P2 H2 = H1 Pick a vertex v1 of P2, and locate the triangle 1 in the triangulation of H1 which contains v1. Starting at v1, traverse the boundary of P2 counterclockwise. During the traversal, keep track of the triangles entered and exited. If the entry or exit edge of the current triangle is an edge of the polygon, compute its intersection with the edge of P2 being visited. A full traversal of P2 results in the computation of the intersections p1, p2, . . . , pk of its boundary with the edges ei1, . . . eik of P1, respectively, where each edge eij has been recorded as an entry or exit edge (and the corresponding intersection pj as the entry or exit intersection). Starting at every entry

intersection pj , traverse the polygon P1 by following the corresponding edge eij into the interior of P2. The traversal will end at the exit intersection pj+1. This has extracted one connected component of the intersection P1 P2. Move on to the entry vertex pj+2. The k/2 traversals together find all connected components. P2 In other words, neither convex hull is contained in the other. There must be two edges e1 and e2 each connecting two vertices from different polygons. Pick one such edge, say e1, and start at its defining vertex from P2. As in the previous case, traverse the polygon P2 and compute all entry and exit edges of P1 as well as their intersections with P2 based on the triangulation. Finally, traverse the boundary sections starting at all entry intersections to extract the connected components of P1 P2. Every triangle in the triangulation of P1 and its pockets is entered and exited at most once by the traversal of the boundary of P2. So there are no more than O(m + n) intersections to be computed. The traversals together take time O(m + n).

6.7) A polygon P is called star-shaped if a point p in the interior of P exists such that, for any other point q in P, the line segment pq lies in P. Assume that such a point p is given with the star-shaped polygon P. As in the previous two exercises the vertices of P are given in sorted order along the boundary in an array. Show that, given a query point q, it can be tested in time O(log n) whether q lies inside P. What if P is star-shaped, but the point p is not given?

Solution:

That is a harder question. An easy solution is the following: to each edge of the perimeter corresponds a partition into half planes and by turning around the perimeter, a consistent orientation for these partitions is determined. If a special point q exists, then it must be on the same side of every one of these partitions, so it suffices to intersect all "inside" half-planes determined by the edges of the polygon. If the result is empty, then the claim that the polygon was star-shaped was false; otherwise, any point within the convex polygon that is the intersection is a valid choice. The cost is O(nlogn) using our divideand-conquer algorithm for half-plane intersection. The real question, then, is whether we can exploit the nature of the problem to run faster.

Você também pode gostar