Hs-cmlpg-94 - Computing minimum length paths of a given homotopy class John Hershberger Jack Snoeyink Department of Computer Science University of

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computing minimum length paths of a given homotopy class John Hershberger Jack Snoeyink Department of Computer Science University of British Columbia DEC Systems Research Center Abstract In this paper, we show that the universal covering space of a surface can be used to unify previous results on computing paths in a simple polygon. We optimize a given path among obstacles in the plane under the Euclidean and link metrics and under polygonal convex distance functions. Besides revealing connections between the minimum paths under these three distance functions, the framework provided by the universal cover leads to simpli ed linear-time algorithms for shortest path trees, for minimum-link paths in simple polygons, and for paths restricted to c given orientations. 1 Introduction If a wire, a pipe, or a robot must traverse a path among obstacles in the plane, then one might ask what is the best route to take. For the wire, perhaps the shortest distance is best for the pipe, perhaps the fewest straight-line segments. For the robot, either might be best depending on the relative costs of turning and moving. In this paper, we nd shortest paths and shortest closed curves that wind around the obstacles in a prescribed fashion|that have a certain homotopy type. We consider the Euclidean and link metrics for paths, and convex and link distance functions for paths that are restricted to use c given orientations, such as rectilinear paths. Our work presents these distance functions in a unifying framework, a triangulation of the unversal covering space. In this framework, we can generalize results for simple polygons to compute shortest paths of a given homotopy class. We also simplify proofs and replace complicated data structures such as nger search trees by simple arrays and stacks. We organize the paper around four variants on shortest path problems: Euclidean shortest paths and shortest path trees in section 3, minimum-link paths in section 4, shortest closed loops in section 5, and paths with restricted orientations in section 6. In the remainder of this section we review previous results on these problems and summarize our results using the universal cover. Section 2 gives formal de nitions of the universal covering space and of triangulated manifolds, homotopy classes, and distance metrics|the important topological tools for our algorithms. 1.1 Euclidean shortest paths Many researchers have investigated the problems of nding Euclidean shortest paths in simple polygons. Chazelle 7] and Lee and Preparata 33] gave a funnel algorithm that, in a triangulated polygon, computes the shortest Euclidean path between two points in linear time. The funnel algorithm has been extended to handle one of the tractable cases of river routing in VLSI. Cole and Siegel 10], Leiserson and Maley 34], and Gao et al. 18] give algorithms for routing wires with xed terminals among xed obstacles when a sketch of the wires is given|that is, when a homotopy class is speci ed for each wire. When no sketch is given or when the terminals are not xed, the resulting problems are usually NP-hard 35, 42, 45]. Leiserson and Maley and Gao et al. use the funnel algorithm to compute the rubber-band equivalent of each wire as a basic preprocessing step. In section 3.1 we describe the application of the funnel algorithm in the universal cover of a triangulated manifold. Then, in section 3.2, we extend it to e ciently maintain the shortest path homotopic to a Portions of the second author's research were performed at Stanford and Utrecht Universities. 1 path that is given on-line. Both of these algorithms take time proportional to the time needed to trace the representative of the path through the triangulation and both use simple data structures|arrays and stacks. Guibas et al. 23] used nger-search trees to compute the tree of all shortest paths from one polygon vertex to all other vertices in linear time they use this as a preprocessing step to solve several shortest path and visibility query problems. Our on-line shortest path algorithm can compute this shortest path tree using simpler data structures. Finding minimumpaths among obstacles when the homotopy class is not given is a more di cult problem, and is one that we will not discuss. For the Euclidean metric, one typically builds the visibility graph and searches it with Dijkstra's algorithm 16] see Ghosh and Mount 21] and Kapoor and Maheshwari 31] for e cient algorithms. 1.2 Link shortest paths Researchers have also looked at nding minimumpaths in simple polygons under the link metric, in which the length of a path is the number of its line segments. Suri 48] developed a linear time algorithm for computing the minimum path between two points in a simple polygon. Ghosh 19] recently gave a linear time algorithm as a consequence of his work on computing the visibility polygon from a convex set. Both algorithms are based on a triangulation and the shortest path tree algorithm of Guibas et al. 23]. We show how to extend our Euclidean minimum path algorithm to compute the minimum-link path in time proportional to the number of triangles that this path intersects. This gives yet another linear-time algorithm in a simple polygon, but one that is more direct and also has application to paths of given homotopy class among obstacles. When the homotopy type is not speci ed, Mitchell, Rote, and Woeginger 37] have given an algorithm that runs in O(E (n) log2 n), where n is the number of vertices, E is the size of the visibility graph, and (n) is the inverse of Ackermann's function. Other recent work has considered combining link and Euclidean metrics 2, 36]. 1.3 Shortest loops There are special closed loops of interest to computational geometers that t within the framework of this research. Under the Euclidean metric, the shortest loop enclosing a set of points or line segments is the convex hull of the set. The shortest loop enclosing a set and contained in the interior of a polygon is the relative convex hull of the set. Toussaint and others have studied relative convex hulls, also called geodesic hulls, in connection with the separability of polygons under translation 5, 12, 51, 52, 53]. Czyzowicz et al. 11] have solved the \Aquarium Keeper's Problem," a generalization of the problem of computing the minimum perimeter polygon that touches each edge of a given convex polygon. Essentially, they use the re ection principle to convert this problem to one of computing the shortest loop around a triangulated annulus or Mobius strip. Our results on closed loops simplify these solutions and generalize them slightly. Minimum-link loops enclosing a set and contained in a polygon separate the set and polygon using the smallest number of line segments. Aggarwal et al. 1] considered nding a minimum-link convex polygon separating two convex polygons with n total vertices. They obtained an O(n log k) algorithm that nds the minimum polygon of k line segments. They also give a simple O(n) algorithm for nding a polygon with at most one segment more than the minimum. Wang and Chan 54, 55] show that the algorithm of Aggarwal et al. can nd the minimum-link convex polygon that encloses a convex polygon lying in the kernel of a star-shaped polygon. They reduce two polygons with a total of n vertices to this case in O(n log n) time. Ghosh 19] computes the reduction in linear time, allowing the computation of the minimum-link convex separator in O(n log k) time. For non-convex polygons, Suri and O'Rourke 49] compute a minimumlink polygon separating an m-gon and its enclosing n-gon in O(mn) time we note (as did Ghosh and Maheshwari 20]) that this is actually the easy case and can be solved in linear time. 1.4 Paths restricted to c orientations In some applications, most notably VLSI, the orientations of paths are restricted. Rectilinear paths are the most important and, thus, the most studied. 2 For computing rectilinear shortest paths among rectilinear barriers under the Manhattan, or L1 , metric, researchers have developed algorithms that work in simple polygons (e.g. 46]) and in the presence of obstacles 9, 15, 32]. Mark de Berg 13] has given an algorithm that nds a path that is both a minimum-link and an L1 shortest path in a simple polygon. He and others 14] give a quadratic algorithm for a combined link and L1 metric for paths among obstacles. The fastest algorithms for the (globally) shortest path among rectilinear obstacles have subquadratic worst-case complexity: O(n log n) if the obstacles are disjoint 15] and O(n log2 n) if they are not 9]. Guting 29] de ned c-oriented polygons as a generalization of rectangles he and others 30, 44, 50] have looked at various geometry problems with restricted orientations. The recent survey of Nilsson et al. 40] summarizes many results. We show that the universal cover is also a useful tool to compute shortest and minimum-link c-oriented paths of a given homotopy type. Speci cally, we show (in section 6.2) that the shortest Euclidean path, measured under a convex distance function, has the length of the shortest c-oriented path. In section 6.3, we give an algorithm to compute minimum-link c-oriented paths and also show how to use it to compute a shortest c-oriented path from the shortest Euclidean path. We also look at conditions when a c-oriented path is simultaneously shortest and minimum-link (section 6.4). 1.5 Improved data structures for simple polygons The algorithms that we develop for the universal cover have implications in the special case of triangulated simple polygons. Section 3.2 By developing a dynamic version of the funnel algorithm, we obtain a linear time algorithm for shortest path trees that uses only a xed size deque (doubly-ended queue) and a stack for storage. Section 4 For minimum-link paths, where distance is measured by the number of line segments, we develop an output-sensitive algorithm that runs in linear time in a simple polygon and uses deques and stacks rather than visibility maps and shortest path trees. Section 5.1 By walking around a loop two or four times, we compute the Euclidean shortest loop in both orientable and non-orientable manifolds without using shortest path trees. Section 6 We compute minimum length and/or link paths restricted to c orientations in O(n log c) time. 2 Preliminaries We begin by de ning some important topological objects: triangulated manifolds, homotopy classes, metrics, and covering spaces. 2.1 Manifolds and simplicial complexes Our results apply to boundary-triangulated 2-manifolds (BTMs), which we de ne below. BTMs are slightly more general than polygonal regions in the Euclidean plane. We consider them primarily because every BTM has a simply-connected covering BTM such that paths have a unique lift into the covering space. First, recall that a two-dimensional manifold with boundary (a 2-manifold ) is a topological space in which each point has an open neighborhood homeomorphic to a two-dimensional ball or half-ball. The former are interior points and the latter are boundary points. A two-dimensional simplicial complex is a triangulated 2-manifold. Spelled out, a two-dimensional simplicial complex is a collection of triangles, edges, and vertices such that any two triangles either do not intersect, intersect at a vertex, or intersect at two vertices and their common edge no other intersections are permitted. At most two triangles are incident to an edge edges incident to a single triangle are boundary edges. Furthermore, all the triangles and edges incident to a vertex can be ordered so that boundary edges are adjacent to their triangles in the ordering. All vertices are either boundary vertices with two incident boundary edges, or interior vertices with none. Finally, a boundary-triangulated 2-manifold or BTM is a simplicial complex in which all vertices are boundary vertices. Figure 1 depicts two simplicial complexes the second is a BTM. Because vertices are the 3 a. b. Figure 1: Two triangulated manifolds the one on the right is a boundary-triangulated 2-manifold (BTM) only source of curvature in a piecewise-linear surface, this implies that a BTM is at|the neighborhood of any point looks like a portion of the Euclidean plane 28, 41]. One can represent a BTM, or any other 2-d simplicial complex, in a computer using Guibas and Stol 's quad-edge structure 25], Baumgart's winged-edge structure 4], or the dual graph of the simplicial complex. In our algorithms, we require that each triangle of M be able to access its incident edges and each edge of M its incident triangles in constant time. If a polygonal region R is given, we can triangulate R and construct one of the above representations of the triangulation in O(n log n) time by a sweepline algorithm 43] or, if R has a constant number of boundary components, in linear time by Chazelle's algorithm 8]. A useful example of a BTM is a triangulated polygonal region R in the Euclidean plane: a set bounded by n line segments with disjoint interiors. Informally, if one considers the line segments as obstacles and looks at paths avoiding the obstacles, then one can form equivalence classes of paths by relating paths that can be deformed to each other within R|relating paths that are homotopic. 2.2 Homotopy classes The topological concept of homotopy formally captures the notion of deforming paths. Let and be functions from a topological space X to a topological space Y that are continuous that is, the preimage ;1(A) of an open set A Y is open. Functions and are homotopic if there is a continuous function ;: X 0 1] ! Y such that ;(x 0) = (x) and ;(x 1) = (x). One can see that homotopy is an equivalence relation 3, 39]. In this paper, the range set Y is always a boundary-triangulated 2-manifold M under the subspace topology. We specify the set X in two di erent ways. First and most importantly, we consider paths joining two given points, p and q: a path in M is the range of a continuous function : 0 1] ! M . We set X = 0 1] and require that the endpoints of a path be xed at (0) = p and (1) = q. Two paths are path homotopic if one can be deformed to the other in M while keeping the endpoints xed. Formally, paths and are path homotopic if there is a continuous map ;: 0 1] 0 1] ! M such that ;(x 0) = (x) and ;(x 1) = (x), and ;(0 y) = (0) = (0) and ;(1 y) = (1) = (1). Second, we de ne a closed loop to be the image of a circle under a continuous map into M . Thus, we set X = S 1 : the unit circle under the standard topology. Two loops with maps and are homotopic if there is a continuous map ;: S 1 0 1] ! M such that ;(x 0) = (x) and ;(x 1) = (x). We use this de nition only in section 5. (A closed loop is di erent from a path with the starting and ending points identit ed, because our de nition of path homotopy never moves the endpoints of a path.) One could go on to de ne homotopy in M for two subdivisions and |indeed, we do so in a paper with Guibas and Mitchell 27] and show that computing minimum-link subdivisions is NP-hard. A homotopy relation partitions paths or closed loops into equivalence classes. Thus, we can describe a homotopy class by giving a representative path or loop . Given , we seek to compute a minimum length 4 representative of 's class under the Euclidean and link metrics. Let's look at one concrete example of a path homotopy. In a BTM, a path gives a sequence of triangulation edges we can form a canonical path that visits the midpoints of triangulation edges in the same sequence. It is easy to see that a path is homotopic to its corresponding canonical path|at times we will nd it convenient to use the canonical path as the representative of a homotopy class. We can concatenate two paths if one ends where the other begins. The next theorem is a well-known tool for studying paths. Theorem 2.1 ( 3, 39]) The operation of path concatenation has group properties: associativity, identities, and inverses. This has an easy corollary for simply-connected 2-manifolds, in which every loop is homotopic to a point. Corollary 2.2 In a simply connected manifold, any two paths with the same starting and ending points are homotopic. 2.3 Path complexity and metrics In computer applications, paths are most often speci ed as a sequence of line segments or pieces of low-degree polynomials. We de ne the complexity of a path , denoted C , to be the number of pieces that compose . For a path in a BTM M we also count , the number of times that crosses a triangulation edge of M . For the canonical path de ned above, we have C = , but, in general, either one of the two quantities could be greater. We assume that is represented in the computer in some form that can be traced through the BTM data structure in time proportional to O(C + ). For example, if is piecewise linear, then for each segment in each triangle we can compute a constant number of segment/segment intersection points to determine whether we need to advance to the next segment or to the next triangle. Storing the vertices of in an array and the BTM M in any of the data structures mentioned above permits tracing in O(C + ) time. We consider two metrics for unrestricted paths in a BTM: the Euclidean and link metrics. The Euclidean metric is the usual L2 metric the length of a path or loop is the sum of the lengths of its pieces in all the triangles it intersects. In the link metric, the length of a path or loop is the number of its line segments. Because BTMs are at, the minimum length paths under both metrics are composed of line segments. In applying the link metric, we would like to consider two adjacent triangles of a BTM to be coplanar, even if they are not. Thus, contiguous \line segments" that would be collinear if the triangles they passed through were laid out at in the plane are counted as a single segment. This unfolding process is what is used to nd shortest paths on the surface of a polyhedron 38, 47]. For some applications, such as VLSI, the paths constructed must use a constant number of xed directions or orientations. Rectilinear paths with the four orientations of north, south, east and west are the most common. When paths are restricted, the link metric remains the number of line segment of a path. The Euclidean metric, however, should be replaced by a distance function that gives the length of the shortest restricted path between two points. We discuss this more fully in section 6. 2.4 Covering spaces Informally, a topological space U is a covering space of a space X if, at each point u 2 U , there is a corresponding point x 2 X such that things around u and x look the same in their respective spaces, but there may be many points of U mapping to the same point x. Formally, let p: U ! X be a continuous and onto map between connected topological spaces U and X . If S every point x 2 X has an open neighborhood N where the inverse image p;1 (N ) is a union i Ui of disjoint open sets of U and the restriction pjUi is a homeomorphism from Ui onto N , then p is a covering map and U is a covering space of X . A space is always a covering space of itself under the identity map. For a more useful example, consider the covering space of a BTM M formed by the following procedure (see gure 2): Choose a base triangle of M , copy it, and make its edges active. Now, any triangle t with an active edge e is a copy of some triangle t0 2 M and of an edge e0 of t0 . There is another triangle u0 2 M incident to e0 |copy it, forming u, and attach u to t along edge e. Make edge e inactive and the other two edges of u active. One can see that the 5 function that sends the copy of a point to its original is a covering map. The covering space thus formed is the universal covering space of M . The dual graph of the universal covering space, the graph with a node for each triangle and an arc joining nodes that correspond to triangles that are incident to the same edge, is an in nite tree rooted at a copy of the base triangle. One can show that the dual graph, considered as an unrooted tree, is not a ected by the base triangle chosen, so the universal cover does not depend on the base triangle. Furthermore, the universal cover is simply connected|it has no holes: Lemma 2.3 The universal covering space U of a BTM is simply connected. Proof: Consider any path starting and ending at a point p in the universal covering space U of the BTM M . The path intersects some connected subset of the tri- Figure 2: A portion of the universal cover angles of the covering space. If intersects only one triangle, then collapses to the point p by the homotopy f (t) = (1 ; t) + tp. Otherwise, we can consider the triangle containing p as the base triangle for the covering space. The dual graph of the space is a tree, so the dual of the connected subset of triangles that intersects must also be a tree. In any leaf, subpaths of start and end at the same edge we can deform these subpaths to the edge by an easy homotopy and trim the leaves. By induction, can be contracted to p. Thus, the universal covering space is simply connected. Figure 3: The lift of Any path that begins in the base triangle has a unique lifting to the covering space, as indicated in gure 3. Formally, let p: U ! M be a covering map. If a function f from a space W to the BTM M is one-to-one and continuous, then a lifting of f is a map f^: W ! U such that the composition pf^ = f . When we lift a path , we use U U to denote the BTM composed of the triangles of the universal cover U that intersect the path ^ . One last lemma pulls all of the constructs in this section together: Lemma 2.4 If is a path in a BTM, M , then we can construct U , the portion of the universal covering space of M that contains the lift of , in O(C + ) time. Proof: The construction algorithm is simple: Begin with U equal to a copy of the triangle of M that contains the starting point of the path . Then trace through M and, simultaneously, trace the lift of through the covering space|when crosses a triangulation edge into a triangle of M , add a copy of the triangle to U if the lift has never crossed the corresponding edge before. (Otherwise, the triangle is already present.) We can trace the path through the triangles of M in the stated time bound. 6 3 The Euclidean metric We begin by applying these topological tools to the funnel algorithm, developed by Lee and Preparata 33] and Chazelle 7] and used by many researchers to nd shortest paths 18, 23, 26, 34]. Section 3.1 reviews this algorithm and remarks that it can be used to nd shortest paths between two points of a given homotopy type. Section 3.2 extends this algorithm to maintain the shortest path homotopic to a path that is given on-line. As a by-product, we can nd shortest path trees in linear time without using nger search trees. This simpli es an important algorithm of Guibas et al. 23]. 3.1 Funnels and the shortest path between two points u First we review funnels, de ned by Lee and Preparata 33]. Let p be a point and uv be a line segment in a simply connected BTM. The shortest paths from p to v and from p to u may travel together for a while. At some point a they diverge and are concave until they reach u and v, as illustrated in gure 4. The region bounded by uv and the concave chains to a is called the funnel a is the apex of the funnel. We store the vertices of a funnel in a double-ended p a v queue, a deque. Figure 5 shows that the extensions of funnel edges de ne wedges. If we cross the segment uv into a triangle 4uvw, then we Figure 4: A funnel would like to obtain the shortest path to w to construct the funnel for the segment uw or vw. To nd the funnel for uw, we pop points from the v end of the deque until we reach b, the apex of the wedge that contains w, then we push w. If the apex of the previous funnel is popped during the process, then b becomes the new funnel apex. Notice that the edge bw is on the shortest path from p to w. The shortest path algorithms of Chazelle 7] and Lee and Preparata 33] both look for a path in a sleeve polygon|a triangulated simple polygon whose dual tree u is a simple path. We shall look for a path in a sleeve BTM. Lemma 3.1 Let be a path from p to q. One can compute, in O(C + ) time and space, a sleeve BTM that contains the Euclidean shortest path homotopic to . Proof: Choose the triangle that contains p as the w base triangle and construct U , the portion of the universal cover that contains the lift of , according b to lemma 2.4. In the dual tree of U , there is a unique path a to the triangle containing the lift of q let 0 be the v canonical path in U that corresponds to this dual path. Since U is simply connected, the lift of Figure 5: Splitting a funnel about w and 0 are homotopic (corollary 2.2). The BTM U U is a sleeve. A boundary edge e of U may separate the universal cover but can not separate p from q. Any path homotopic to 0 that crosses e does so twice and can be shortened 0 0 7 by following e. Thus, the shortest path from p to q homotopic to 0 (and, under projection, to ) is contained in U . Trace the canonical path 0 through U and maintain the funnel of the triangulation edges crossed. The set of all edges added to the funnel comprises the shortest path tree rooted at p, that is, the union of all shortest paths from p to vertices of U . From this tree it is easy to recover the shortest path from p to q. Thus, we have obtained Theorem 3.2 The Euclidean shortest path that is homotopic to a given path can be computed in O(C + ) time and jU j space. 0 0 0 3.2 On-line shortest paths and shortest path trees In this section, we show how to maintain the deque that represents the funnel for a path that is given on-line. We wish to trace through the universal cover in O(C + ) time, as above. Since, however, we do not know the entire path ahead of time, we must be able to handle doubling back over the same triangle edge many times we cannot a ord to do more than a constant amount of work to update the deque each time. Besides being useful for interactive applications, this procedure can be adapted to compute shortest path trees in a simply connected BTM. (The shortest path tree from a point p is the union of all shortest paths from p to vertices of the BTM.) Guibas et al. 23] compute the shortest path tree of any triangulated simple polygon by splitting funnels|they use nger search trees to nd the splitting vertices and split the funnels e ciently. We nd the shortest path tree by tracing the boundary and maintaining the funnel the edges added to the funnel compose the tree. Our algorithm uses arrays in place of nger search trees and still runs in linear time. We describe rst the data structure and then the algorithm that uses it. We use an array and a history stack to support ve operations on a deque that stores a funnel. Length(deque ) Return the number of items in the deque. Index(deque i ) Return the ith item in the deque. Add(f deque x ) Add the item x to the f=front (or b=back) of the deque. Split(f deque i ) Return the items in f=front (or b=back) of and including item i and discard the other half of the deque. Undo(deque ) Undo the most recent Add() or Split() operation. We store the deque in the entries of an array with indices from rst through last . When we perform an Add() or Split(), we record the previous values of changed array entries and/or indices in a history stack so that the Undo() operation can return the array to the previous state. The code fragments in table 1 indicate that the operations can be implemented to run in constant time. If we begin with an empty deque, denoted by indices rst = n and last = n ; 1, and perform at most n Add() operations, then an array of size 2n is su cient to hold the deque. Length(deque ) return last ; rst + 1 Add(f deque x ) decrement rst push (Add f deque rst ]) to stack Index(deque i ) check 0 i < Length(deque ) return deque i + rst ] Undo(deque ) if stack top is (Add f x) set deque rst ] x increment rst else stack top is (Split f i) set last i set deque rst ] x Split(f deque i ) check 0 i < Length(deque ) push (Split f last ) to stack set last i + rst Table 1: Code fragments for the front-of-deque operations 8 Suppose the path begins at point p in a BTM M . The algorithm will trace through the universal cover according to lemma 2.4|beginning with the base triangle that contains p. Notice that whenever the lift of is in the base triangle, the funnel deque should consist only of p. Whenever the lift of crosses an edge uv out of the base triangle, we add the endpoints to the funnel deque by Add(f deque u ) and Add(b deque v ). Suppose the path crosses an edge uv into a new triangle 4uvw that is added to U . If later leaves through one of the other edges of 4uvw, then the current funnel is split into the funnels de ned by uw and by vw as illustrated in gure 5. The key observation is that whenever the lift of is in 4uvw, the index i of where the deque is to split is the same. We use an increasing increment search to compute this index i: check the extension of the 1st, 2nd, 4th, 8th, etc., edge of the funnel until we pass the point w, then perform binary search to nd the wedge containing w. By searching from the front and back simultaneously, we nd the splitting index in O(log d) steps, where d = minfi Length(deque ) ; i g. Finger search trees were used in 23] to implement the simultaneous increasing-increment search, but arrays avoid the extra pointer complexity. We store this splitting index with 4uvw in U . Now, consider the dual graph of U |the triangles of the universal cover that intersect the lift of |as a tree rooted at and directed toward the base triangle. When the path encounters a triangulation edge, is heading either away from or toward the base triangle. If is heading away, then we perform a Split() indicated by the index stored in the current triangle and Add() the new triangle vertex to obtain the next funnel. If is heading toward the base, then we Undo() the last two operations: usually a split/add pair, but an add/add when is returning to the base triangle. Lemma 3.3 establishes that this on-line algorithm and the previous section's o -line algorithm compute the same funnel. Lemma 3.3 For a curve from p to q in a BTM M , the on-line algorithm computes the funnel corresponding to the sleeve of the path from p to q in the universal cover of M . Proof: We prove this lemma by induction on the number of triangulation edges that crosses. The induction hypothesis is that the pairs of operations that have been placed on the history stack are exactly those that would be performed by the o -line algorithm. This is trivially true if is entirely contained in the base triangle. Suppose the invariant holds for all paths crossing k triangulation edges, and let be the concatenation of 0 , which crosses k triangulation edges, and 00, which crosses one edge. If 00 traverses an edge away from the base triangle, then the sleeve of is the sleeve of 0 with one new triangle added to the end. The split/add (or add/add) performed and put on the history stack establishes the hypothesis for . Otherwise, 00 traverses an edge towards the base triangle. Since the sleeve of is the sleeve of 0 minus the last triangle, undoing the last two operations performed and removing them from the history stack does the right thing. Except for nding the splitting index|which one does once for each triangle of the universal cover U | one does a constant amount of work when visiting a triangle. The analysis of Guibas et al. 23] can be applied here to show that the time to nd the splitting indices is linear in . In brief, the time to compute splitting indices for the triangles of U is bounded by T ( ) where T (n) miax T (i) + T (n ; i) + log minfi n ; ig : Thus, we have established the following theorem. Theorem 3.4 One can trace a path through the universal cover of a BTM and maintain the funnel in O(C + ) time and space. If P is a triangulated simple polygon and is the path from a vertex p around the boundary of P and back to p, then the algorithm computes the edges of the shortest paths from p to each of the vertices of the polygon|that is, the shortest path tree of P . 4 The link metric In this section we show how to compute the minimum-link path, 0 , homotopic to a given path in time proportional to C + + , the complexity of the path plus the number of triangles intersected by 0 9 both paths. Our approach is inspired by Ghosh's 19] observations about the relationship between minimum Euclidean and link paths in simple polygons. We compute the Euclidean shortest path and then use a greedy approach to minimize the number of line segments. Our algorithm is output-sensitive and is simpler than that of Ghosh in the simple polygon case it avoids his middle step of computing a visibility polygon. First, some de nitions: Since we have enough time, O(C + ), to compute the Euclidean shortest path in the homotopy class of , we may assume that is the shortest path from p to q. (The shortest path has complexity at most , so we perform all remaining complexity analysis in terms of .) As before, U is the universal covering space and U consists of the triangles of U that intersect . Traversing from p to q, we can label each vertex as a left or right turn. We call an edge tu of an in ection edge if the labels of t and q u di er edges incident to p and to q can also be called in ection edges. (Ghosh calls such edges eaves.) The extension of a line segment tu in U , denoted ext (tu), is the line segment, a t v s ray, or in nite line formed by extending tu unu b til it hits boundary points of U . In a simple polygon, Ghosh observed that there is always a minimum-link path including one line segment from the extension of each in ection edge. This is also true in the universal cover: Lemma 4.1 If tu is an in ection edge of a p 0 0 Euclidean shortest path , then a minimumlink path homotopic to can be assumed to use a subsegment of ext (tu). Figure 6: Extension ext (tu) separates U Proof: Let s and v be the endpoints of the extension ext (tu) so that these points appear in order s, t, u, v. Each of the segments st, tu, and uv separates p from q in the universal covering space U , so any path from p to q must cross all three segments, as shown in gure 6. If a path 0 from p to q intersects st at a and uv at b, we can shortcut 0 with the segment ab ext (tu). Since some line segment of 0 intersected tu, this shortcut does not increase the number of segments on the path. Thus we can assume that any in ection edges are included in the minimum-link path. We have reduced our problem to one of nding the minimal link path from uv, a segment extending one in ection edge, to u0v0 , a segment extending another, where the shortest path from u to u0 is concave see gure 7. If the extension segments uv and u0v0 intersect in U , then no additional segments are needed. Otherwise, consider the Euclidean shortest path from v to v0 in U the path from u to u0 and form what has been called the hourglass of uv and u0 v0 . The path helps nd a segment of the minimum-link path. Lemma 4.2 The minimum-link path joining uv and u0 v0 either has zero or one segments or it can be chosen to include an in ection edge of , the shortest path from v to v0 . Proof: If is concave, then the concave chains can be separated by a line one segment can join uv to u0 v0 . Otherwise, has an in ection edge. Let bc be the in ection edge closest to v as shown in gure 7. (We consider v to be labeled opposite u so that b may be v.) Because the paths from u to c and v to c are both concave, the extension of bc intersects uv at some point a. Let cd be the extension of bc through c in U . Any path from uv to u0v0 must intersect both bc and cd. If we shortcut the path by following the subsegment of ad from a, through c, to the intersection of the path with cd, then we do not increase the number of line segments on the path. Finally, we discover the in ection edge bc, if it exists, in time proportional to the number of triangles that ac intersects by the procedure outlined in table 2 and described in the rest of this section. Notice that ac is tangent to the concave chain. We nd ac by moving the point a up the edge uv and maintaining the point c tangent to the chain. We stop the motion when one of three cases occurs: 10 Variables: Points a, c, c0 : a sweeps \upward" along segment uv. ac is tangent to the concave chain at c. Point c0 follows c on the concave chain. * Edge e: the rst (t-edge) hit by av Data structure: (H b ): the convex hull and the point having a tangent of slope ( gure 8) Description: Uses Graham scan 22] to maintain the convex hull of endpoints of triangulation edges (t-edges) Operations: Add(p f or b): Add points to front or back of H ChangeSlope( ): Change slope to and recalculate b Initialize a u, c next (a), and c0 * next (c) e the rst t-edge hit by av for each t-edge crossing ac in order from a to c if an endpoint p lies in 6 vac then Add(p b) b the last point Add()ed to H repeat ChangeSlope(slope of ac) move a along uv, rotating ac around c until case 1: if ac is part of u0 v0 use ac as the last link in the path exit program case 2: a reaches v. use vc in the minimum-link path exit loop case 3: Line segment ac hits b use ac in the minimum-link path exit loop case 4: slope of ac points into H at b ChangeSlope(slope of ac) case 5: a hits e if an endpoint p lies in 6 vac then Add(p f ) * e rst t-edge hit by av case 6: a, c, and c0 become collinear For each t-edge that hits cc0 in order from c to c0 if an endpoint p lies in 6 vac0 then Add(p b) change pivot c c0, c0 next (c0) loop if c 6= u0 , repeat program using ext (ac) as uv H v b e c u Figure 8: The hull H Table 2: Computing the minimum-link path between in ection edges uv and u0v0 11 c a v a b c d u v u Figure 7: The path has in ection edge bc 1. The tangent * becomes a segment of u0 v0 : no extra segments are needed. ac 2. The moving point a reaches the polygon boundary, which implies a = v: the segment vc is the in ection edge of . 3. The tangent * encounters a point b between a and c: the segment bc is the in ection edge. ac The third case is the most di cult to detect we use the following technical lemma: Lemma 4.3 The point b rst encountered by the sweeping tangent is the endpoint of a triangulation edge that crosses the segment ua or the chain from u to c. Proof: Because a triangulation has no re ex angles, the tangent segment ac must cross a triangulab tion edge incident to b before it touches b. Since the v segments ua and ac and the concave chain from u to c form a closed region, shown in gure 9, the lemma a holds. c Lemma 4.3 implies that we need look only at the convex hull of the endpoints of triangulation edges that we encounter during the sweep. These endpoints appear on the hull above ac in the same order as their edges appear along ac. Points are added only at the ends of the segment ac, so we can maintain the convex hull by a Graham scan 22] in a deque. Furthermore, the slope of ac changes monotonically, so we can also maintain b , the u point of the hull having a tangent with this slope. When ac hits b , then b c is an in ection edge that lemma 4.2 Figure 9: The sweep stops at b says can be used in a minimum-link path. These arguments establish the correctness of the algorithm outlined in table 2. To establish the running time, notice that the amount of work required to nd a segment of the minimum-link path is proportional to the number of triangulation edges that intersect the region depicted in gure 9. Since this region is free of points, these edges must intersect either ua or ac. Since these segments are part of the minimum-link path, we can charge this work to the number of triangles crossed by the computed path and obtain theorem 4.4. 12 Theorem 4.4 A minimum-link path 0, homotopic to , can be computed in space and time proportional to O(C + + ). In a simply connected BTM, a minimum-link path can cross any triangulation edge at most three times: any path that crosses a triangulation edge e four or more times can be shortcut by a portion of e, decreasing its length without changing its homotopy class since all paths with the same starting and ending point have the same homotopy class. Thus, the total time to compute minimum-link paths in simple polygons is linear. Among many obstacles, a minimum-link path with k segments can intersect (kn) triangulation edges, as shown in gure 10. 0 5 Loops The algorithms of the previous section can be used to nd the Figure 10: The k-link minimum path shortest and minimum-link closed path whose starting and end- intersects (kn) edges ing points coincide|that is, for a loop that is pinned to the starting point. For completeness, we show how to use the universal cover to help nd shortest and minimum-link loops of a given homotopy class that is not pinned to pass through any given point. We compute Euclidean shortest loops in section 5.1 by simply walking around the loop at most four times this can be applied to compute relative convex hulls 12, 51, 53] and minimumperimeter inpolygons 11]. For minimum-link loops, section 5.2, we have nothing new to add except the obvious generalizations from nested polygons to BTMs. 5.1 Euclidean shortest loops The funnel algorithm, outlined in section 3.1, computed a shortest path in a sleeve polygon|a triangulated polygon whose dual was a path. For shortest loops, we de ne a band analogously as a BTM whose dual is a single cycle. In this section, we rst reduce the problem of computing the shortest loop of a given homotopy type to the problem of nding the shortest loop around a band. A band is orientable if and only if the boundaries of its triangles can be be traversed so that each internal edge is traversed once in each direction. Orientable bands have two boundary cycles and non-orientable bands have only one. Subsections 5.1.1 and 5.1.2 deal with the orientable and non-orientable cases of the reduced problem. Lemma 5.1 In a BTM M with a loop , we can compute a band whose shortest loop is the lift of the shortest loop homotopic to in M . Computation time and space is O( ). 13 Proof: Choose any point p on and nd the sleeve of the path from p to p along . An initial sequence of triangles and triangulation edges of this sleeve will appear in reverse order at the end of the sleeve, as shown in gure 11. Remove all but the last of these common triangles, and glue those together. The result is either a single p triangle, in which case is homotopic to a point, or else it is a 2-manifold M 0 whose dual has a single cycle|M 0 is a band. We must show that the band M 0 contains the lift of the shortest loop homotopic to . We can begin with the band and perform the universal cover construction to obtain a 2-manifold of genus one Figure 11: Constructing a band that contains the lift of . Suppose we remove an edge from this manifold. We either separate the manifold or, if the edge is an internal edge of the band, we reduce the genus to zero. This proves that edges internal to the band must be crossed an odd number of times and all other edges must be crossed an even number of time by any loop homotopic to . But, just as in lemma 3.1, this implies that the shortest path crosses internal edges once and no other edges. Thus, the band contains the shortest loop homotopic to . Before we solve the problem of computing the shortest loop around a band, we de ne the concepts of turn angles and cut manifolds. The turn angle ( gure 12) of an oriented piecewise-linear path with given starting and ending points in a BTM M is measured by following the orientation of the path and summing the angles of its turns. Each turn has an angle ; < < (locally) right turns are negative and left are positive. The turn angle of a loop is the turn angle of the path around the loop starting and ending at the orientation of some edge|which edge is chosen does not a ect the angle. If we cut a band M along any non-boundary triangulation edge e, we obtain a simply connected manifold Mcut whose boundary has two copies of e. The shortest loop around M becomes a shortest path in Mcut between two copies of a point p 2 e. (Czyzowicz et al. 11] show how to use shortest path maps to compute the shortest path between the two copies of e in linear time|we will use somewhat lighter artillery.) Around the boundary of Mcut , the copies of e Figure 12: Turn angle have the same or opposite orientations, depending on whether the band M was orientable or non-orientable. We will handle these cases separately in the following two subsections. 5.1.1 Orientable bands In this section, we show how to nd the shortest loop around an orientable band. After de ning the inner boundary of the band, we state a procedure using the funnel algorithm 33] to compute the shortest loop by walking around the inner boundary twice. We prove its correctness in the rest of the section. The boundary of an orientable band M consists of two closed curves, R to the right and L to the left of M 's cycle. According to the next lemma, the turn angle of the shortest loop in an orientable band equals the turn angle of the canonical loop or either boundary curve. Lemma 5.2 In an orientable BTM, two simple (i.e., non-self-intersecting) oriented loops that are homotopic have the same turn angle. If the turn angle of M is negative, then we say that R is the inner boundary, otherwise L is the inner boundary. In the gures, the triangles are laid out at in the plane, which would give turn angles of 2 . Manifolds that cannot be embedded in the plane give rise to other turn angles. 14 The following procedure computes the shortest loop: 1. Let uv be a line segment of the inner boundary. 2. Use the funnel algorithm to compute the shortest path from u to v that winds around the band twice. (See gure 13.) 3. Let p be a vertex that appears twice on the path the path from p to p is the shortest loop. This algorithm is based on the fact that once we identify a point p on a shortest loop, we can compute the loop by computing the shortest path from p back around to p. Lemma 5.3 says that there is a shortest loop touching a vertex of the inner boundary. Lemma 5.3 There is a shortest loop that touches a vertex of the inner boundary. Proof: If the turn angle of a band M is positive, then the Figure 13: Around the inner boundary shortest loop must make a left turn. It can only do so by turning at a vertex of the left or inner boundary. The case of a negative turn angle is symmetric. If the turn angle of the band M is zero then any shortest loop turns as much to the right as to the left. Thus, if it turns at all, it turns at vertices of both the inner and outer boundaries. If the shortest loop does not turn, then cut the band M along a triangulation edge e|the two copies of e are parallel and the shortest loop becomes a straight line segment ` between corresponding points of the copies of e. Without changing the length of the segment `, one can translate ` to the left until it touches a vertex of the inner boundary. With this lemma, we can prove correctness. Theorem 5.4 Given an orientable band M composed of n triangles, the procedure above correctly computes the shortest loop around M in linear time. Proof: Let p be the vertex on the inner boundary of some shortest loop whose existence is proved by lemma 5.3. The shortest path from u starts on or inside this shortest loop and reaches p before going completely around the band. Similarly, the shortest path from v reaches p before going around the band in the other direction. Thus, p is reached twice. The path can thus be decomposed into three pieces: the shortest path from u to p, denoted u the shortest loop around the band, denoted and the shortest path from p to v, denoted v . The vertices of are obviously the vertices of the shortest loop. Together u and v compose the shortest path from u around to v|a vertex appears on this path only once. Thus, any vertex that appears twice on is on the shortest loop and can be used in place of p. 5.1.2 Non-orientable bands One might think that computing the shortest loop in a non-orientable band would be more di cult. In this section, however, we show how to nd the shortest loop that winds twice around the band by a reduction to an orientable band. We then show how to obtain the shortest loop from this curve. The result is theorem 5.5. Theorem 5.5 Given a non-orientable band M composed of n triangles, one can compute the shortest loop around M in linear time. We can conceptually take two copies of Mcut , reverse one left-to-right, and paste them into a single band Mdouble, as shown in gure 14. The band Mdouble is orientable and has turn angle zero: starting from triangulation edge e, you travel through one copy of Mcut until you encounter the reversed copy, denoted eR . Then you travel through the reversed copy of Mcut until you reach e again. The turn angles in each copy of Mcut have opposite sign. We can use the procedure of the previous section to nd the shortest loop in Mdouble that touches the left boundary|call it . Notice that is the shortest loop that winds around 15 M twice, so its length is at most double the length of the shortest loop in M . We shall see that the length is exactly double. Suppose intersects e at a point p. Then the shortest loop touching the right boundary is the shortest path starting and ending at the corresponding point pR 2 eR . In other words, the shortest loop in Mdouble touching the right boundary is R |the loop viewed from the perspective of edge eR . This should not be surprising as M has only one boundary. We now consider two cases depicted in gure 14. First, if the shortest loop in Mdouble makes any turns, then makes p p q turns on vertices of both the right and left boundaries. Since e e the shortest loop touching a given boundary is unique, both loops and R are identical. Therefore, passes through the point pR 2 eR |that is, winds around the shortest loop in λ λ M twice. λ p Second, if the shortest loop makes no turns, then by q cutting the manifold Mdouble along e, we see that the loops e e touching the left and right boundaries, and R , form two parallel lines. If the intersections with e are points p on the left and q on the right, as shown in gure 14b, then the intersections with eR are the corresponding points qR on the left and pR on the right. The line 0 parallel to and R e e p p and passing through the midpoint of the segment pq is also q a shortest loop in Mdouble. Moreover, 0 also passes through the midpoint of qRpR . But these two midpoints are just the Figure 14: Cases for the shortest loop in corresponding points on two copies of e. As a result, 0 winds Mdouble around the shortest loop in M twice. R R R R R 5.2 Minimum-link loops As in section 5.1, if we know a vertex or edge of a minimum-link loop, we can use the path algorithm to compute it. When a minimum-link loop is convex, however, it seems di cult to nd such a vertex or edge. Because of the algorithm of section 5.1, we can assume that our loop is the minimum Euclidean curve of its homotopy class. If has an in ection edge, then we can use the path algorithm of table 2 to nd the paths between in ection edges|a fact that has also been noted by Ghosh and Maheshwari 20]. Lemma 4.1 implies that the resulting loop is a minimum-link curve. If has no in ection edges, then all minimum-link loops are convex. One can use the technique of Aggarwal et al. 1] as extended by Wang 54] and Ghosh 19] to nd a minimum-link loop. Brie y, one nds an initial loop nding a minimum-link path from p around to p the resulting path has at most one segment more than the minimum. One then rotates this loop, keeping track of its points of contact with the inner and outer chains, to see if one can shorten the loop. The algorithm nds a minimum-link loop with k line segments in O(n log k) time. It would be interesting to discover a matching lower bound. 6 Paths with restricted orientations For some applications, such as VLSI, the paths are restricted to c xed directions we call such paths coriented. Rectilinear paths with the four orientations of north, south, east and west are the most common. In this section, we show that the universal cover is also a good tool for nding minimal c-oriented paths of a given homotopy class. First, in section 6.1, we de ne convex polygonal distance functions appropriate to a given set of orientations. Then we show in section 6.2 that the length, under a convex distance function, of the Euclidean shortest path computed in section 3.1 equals the length of the shortest c-oriented path. Section 6.3 shows how to modify the minimum-link algorithm of section 4 to compute minimum-link c-oriented paths. Finally, section 6.4 shows that for paths restricted to three directions and for rectilinear paths, each homotopy class 16 has a shortest path that is also a minimum-link path. Mark de Berg 13] has independently noted this fact for rectilinear paths in simple polygons. In each of the following sections, when we wish to construct paths restricted to c orientations explicitly, then we also restrict the boundary of the obstacles to the same set of c orientations. With such a restriction, there is always a path with at most O(n) segments that follows obstacle boundaries. Without such a restriction, one can construct examples where any c-oriented path joining a given pair of points has in nitely many line segments. 6.1 Metrics versus distance functions When paths are restricted, the link metric remains the number of line segment of a path. We can replace the Euclidean metric, however, by a distance function that gives the length of the shortest restricted path between two points. The Manhattan or L1 metric, in which the length of a vector v is the sum of the lengths of the projections of v on the horizontal and vertical axes, is an example of a distance function for rectilinear paths. More generally, we can use Minkowski's convex distance functions 6]. Let A be a convex set whose interior contains the origin. The length of a vector v with respect to A is the amount that A must be scaled to include v that is, kvkA = inf f 0 : v 2 Ag. The distance from point r to s is ks ; rkA . The distance function need not induce a metric because it need not be symmetric: kvkA may not equal k ; vkA . It does, however, satisfy the triangle inequality 6]: if u + v = w then kukA + kvkA kwkA . The points of the boundary of A are precisely the unit vectors of the distance function k kA . Choosing A to be the unit circle gives the Euclidean metric choosing A to be the diamond de ned by the four unit vectors in the axial directions gives the L1 metric. For a c-oriented path, which is a path restricted to follow the orientations of c unit-length basis vectors u1 u2 : : : uc, we choose A to be the convex hull of f~ u1 : : : ucg. We assume that the ui appear on A in the order listed. 0 As an aside, if the origin ~ is on the boundary of A then vectors that are not contained in the angle 0 formed by the boundary of A at ~ have in nite length. They cannot be reached by a c-oriented path because 0 they cannot be expressed as a positive linear combination of the basis vectors. A path that follows c chosen orientations has the same length under the Euclidean metric and under the associated convex distance function. More importantly, a vector v measured under a convex distance function has the length of the shortest c-oriented path from the origin to v|we show this in the next lemma. Lemma 6.1 Let A be the convex hull of fu1 u2 : : : ucg, a circularly-ordered set of basis vectors and let v be a vector in the wedge de ned by adjacent basis vectores ui and ui+1 . Vector v = aui + bui+1 i kvkA = a + b. Proof: This is true for the unit vectors of the distance function kvkA = 1, which are on segments, ui + (1 ; )ui+1 for 0 1, that join adjacent basis vectors on the boundary of the convex hull. Since length scales with the vector, it remains true for arbitrary vectors v. 6.2 Shortest paths under a convex distance function We use lemma 6.1 to nd the length of the shortest path of a given homotopy type under a convex distance function. As before, we rst compute the Euclidean shortest path from p to q and use it as the representative of the homotopy class. This takes O(C + ) time. The proofs leading to theorem 3.2 use only the triangle inequality to show that the path computed in section 3.1 is minimum under the Euclidean metric. But this implies that Theorem 6.2 The Euclidean shortest path computed in section 3.1 is a shortest path under any convex distance function. Lemma 6.1 implies that if we replace each segment of the Euclidean shortest path by a \zig-zag" or \staircase" made from the two adjacent basis vectors, then we will have a c-oriented path of the same (minimum) length. By cutting the Euclidean shortest path at all points with tangent vectors that are among the c basis vectors and computing c-oriented \staircases" for the resulting pieces we will nd a shortest c-oriented path that has the fewest possible links. 17 Lemma 6.3 Let t be a point of the Euclidean shortest path having a basis vector u as a tangent vector. Any minimum length path under the convex distance function goes through t. Proof: Slice the universal cover into three pieces by a line segment through t and parallel to u. Any path from p to q rst crosses this segment at or before t and last crosses it at or after t. By applying lemma 6.1 to the wedge containing u alone, we see that the shortest path under the convex distance function is inside this segment from the rst to last crossing and therefore passes through t. We can perform this cutting by simply traversing the Euclidean path|think of driving a car along the path, as in Guibas, Ramshaw, and Stol 's kinetic framework for computational geometry 24]|and cutting it whenever the direction of travel is one of the c basis vectors. (If c is not considered a constant, then we can use binary search to nd the wedges that contain the slopes of edges. The time complexity becomes O(C log c).) The slopes on each resulting path lie in a wedge de ned by two adjacent basis vectors. Thus, by lemma 6.1, each path should be replaced by a path using only those two orientations. If we are unconcerned about the number of links then, using the two orientations, we can remain within an arbitrarily small neighborhood of the Euclidean shortest path. More likely, however, one would want to construct a shortest c-oriented path using the smallest number of links. The next section develops an algorithm for the more general problem of computing minimum-link c-oriented paths. Section 6.4 mentions how this algorithm can be simpli ed when there are only two directions of interest and also discusses when a minimum link path can also be a shortest path under the convex distance function. 6.3 Minimum-link c-oriented paths This section develops a greedy algorithm to compute a minimum-link c-oriented path homotopic to a path from p to q: Each link (line segment) reaches as far as possible towards q, guided by the Euclidean shortest path. De ne the i-link region of p, denoted Ri(p), to be the set of all points of the universal cover that can be reached by a c-oriented path of i links from p. If q is not in Ri(p) then we shall nd two c-oriented segments on the boundary @ (Ri(p)) with adjacent orientations that separate p from q in the universal cover. We compute the two segments of @ (Ri+1 (p)) that separate p from q from the two segments of @ (Ri (p)). Section 4 used essentially this greedy approach to compute an unrestricted minimum-link path. In that case, however, the boundary of the i-link region is a single line segment and one can compute the links of the path in time proportional to the number of triangles that the path crosses. In this section we will have to explore two possible ways to reach the goal q. This di culty arises already in rectilinear paths, where one must decide whether to begin with a horizontal or a vertical step. (It is interesting that, even with more allowed orientations, no more than two paths need be considered at any time.) The time required by our algorithm will therefore be proportional to the number of triangles explored, which may be greater than the number of triangles intersected by the nal path. The worst-case bounds are similar to those of section 4: If c is a constant, O(nk) time is su cient to construct a k link path of a given homotopy class and O(n + k) time is su cient in a simple polygon. If c is not a constant but the basis vector directions are initially sorted, then the algorithm can be implemented to run in O(nk log c) and O(n + k log c) time, respectively. Lemma 6.4 Let be a Euclidean shortest path from p to q in a BTM M , and let U be the universal covering space of M . Suppose Q is the connected component of U ; Ri(p) that contains q. Then @ (Q) ; @ (U ) consists of at most two segments from a point r that have adjacent orientations u and v. Proof: We prove this by induction. The 1-link region R1(p) consists of maximallength segments radiating out from p in the permitted orientations. If we cut the universal cover U along these segments and look at the component Q that contains q, we nd that @ (Q) contains a portion of one of these segments in degenerate cases or two adjacent segments meeting at p in non-degenerate cases. Now, assume that the i-link region has boundary segments ru and rv that come from the point r in directions u and v, as depicted in gure 15. Without loss of generality, we can assume that u is clockwise of v and that the Euclidean path turns to the right. Any minimum-link c-oriented path that is homotopic to must cross one of the segments ru or rv by cutting the path at this crossing point and replacing the initial portion with an i link path, we can assume that uses part of ru or rv as its ith link. 18 There are two cases to consider when extending the path by one link, depending on whether there is some c-oriented segment from ru or rv that is tangent to the Euclidean shortest path or not. r rv v ru r ru u s t rv s orientations t a. α α b. Figure 15: Computing part of @ (Ri+1 (p)) from @ (Ri (p)), shaded Suppose, rst, that there is no such tangent, as in gure 15a. Imagine drawing maximal length segments in Q from rv in direction u there will be some segment s that that is the last one crossed by en route to q. Similarly, draw the segment t from ru in direction v that is last crossed by . We notice that segments s and t intersect: If hits s after t, as in gure 15a, then ru , rv , s and bound a simply connected region in U that t enters by crossing . Since t cannot cross ru or rv or recross , t must cross s. Let r0 = s \ t. The (i + 1)-link region is bounded by the portions of s and t in the directions of u and v from r0 because they are the extremal segments in the directions of u and v and segments in other orientations cannot reach from ru or rv to the segments from r0 . This establishes the lemma for the rst case. Second, suppose that there is a c-oriented tangent to from rv . Let t be the c-oriented tangent furthest clockwise from v, as shown in gure 15b. Tangent t U has an end on rv , is tangent to at b, and has maximal length. Now, draw segments from rv in the next orientation clockwise from the orientation of t and let s be the last segment crossed by . Let r0 = s \ t. If r0 lies between rv and b on t, then the (i + 1)-link region is bounded by the segment of t following b. Otherwise, r0 follows b on t and the (i + 1)-link region is bounded by the two segments from r0 in the directions of s and t. This lemma and its proof indicate a way to start from p and obtain a sequence of points, each of which a minimum-link c-oriented path can pass through in one of two adjacent directions. If we can compute these points and directions, then we can construct the minimum-link path as follows: Begin at r = p with the at most two candidate paths whose initial orientations delimit the smallest wedge containing the orientation of the rst segment of the Euclidean shortest path . Obtain the next point r0 and the pair of directions, which come from non-tangents in the rst case of lemma 6.4 and from a tangent and a non-tangent in the second case. In the rst case, both candidate paths are extended by one link. In the second, the candidate path that cannot be extended by a tangent is discarded and the path up through r is xed. Then new candidate paths are begun that pass through r0 in two directions and the process continues. The algorithm stops with a minimum-link c-oriented path when one of the candidate paths reaches q|a fact that can be detected by the tangent- nding algorithm. To compute the sequence of points and directions we need to nd extreme c-oriented tangents to , if they exist, and nd extreme segments of xed orientations that connect the old link region boundary to . Both of these tasks can be performed by a modi cation of the minimum-link path algorithm presented in table 2. Since this algorithm nds the extreme tangent by sweeping a tangent segment and recording in a convex hull the endpoints of triangulation edges that cross the sweep, there is little modi cation required to nd an extreme c-oriented tangent. In gure 15a, the sweep would begin at the intersection of and ru and maintain a tangent segment to as the other endpoint moved up to r and then along rv . When the extreme tangent is found, the extreme c-oriented tangent, if any, can be reported by searching the list of orientations. The same idea|sweeping a segment and maintaining the endpoints of triangulation edges that cross the 19 sweep|applies to nd the extreme segment with a given orientation. Since the orientation is xed, one does not need to record the convex hull of the endpoints ahead of the sweep. Storing the rst endpoint that will be encountered is su cient. The extra exploring means that we do not have output-sensitive bounds for c-oriented paths. Theorem 6.5 One can construct a minimum-link c-oriented path homotopic to in time and space proportional to the number of triangles that contain candidate segments for the minimum-link path. If the c allowed orientations are initially sorted, then the worst-case time bound to compute a k-link path in a BTM with n triangles is O(nk log c). This analysis can be sharpened for a simply connected BTM if there are two opposite basis vectors. If we use the algorithm of Fournier and Montuno 17] to change the triangulation to a trapezoidation with sides parallel to these basis vectors, then c-oriented paths can follow the edges of the trapezoids. Any trapezoid edge that intersected more than three edges of a path could be used to shorten the path. Thus, each trapezoid is explored a constant number of times. The running time of the algorithm in this case is O(n + k log c). 6.4 Simultaneous minimization of length and links In the c-oriented case, as in the unrestricted case, a minimum-link path is usually not the shortest path and vice versa. A \long" straight detour can generally save several turns. In this section we remark that a simpli ed version of the minimum-link path algorithm can compute the path with fewest links of all shortest c-oriented paths. For rectilinear paths and paths restricted to three directions, we prove that this path is also a minimum-link path|that length and links are minimized simultaneously. Section 6.2 showed that the shortest c-oriented path under a convex distance function can be obtained by breaking the Euclidean shortest path at all vertices with basis vector tangents and approximating each piece by a path that follows two adjacent orientations. But this breaking implies that only the rst case for extending a path can arise in lemma 6.4. Therefore, we can compute such paths entirely by sweeping segments with xed orientations|we need not maintain convex hulls to determine where the sweep ends. We do need to try both candidate paths, however, and merge collinear segments from separate pieces to compute the shortest c-oriented path with the fewest links. To determine when this path is also a minimum-link path, we make the following de nition. A member u of a set of basis vectors B satis es the halfplane condition if there is a halfplane that contains all of B except u. Now, consider driving along the Euclidean shortest path, moving and turning in accordance to Guibas, Ramshaw, and Stol 's kinetic framework for computational geometry 24], and noting in which basis vector orientations you face during a turn about a vertex. If the basis vector tangent at a vertex has the halfplane condition, then shortest and minimum-link paths can both pass through that vertex in the direction of the basis vector. Lemma 6.6 If a tangent basis vector, u, of a point t on the Euclidean shortest path satis es the halfplane condition, then a minimum-link c-oriented path homotopic to has an edge passing through t in direction u. Figure 16: The halfplane condition 20 Proof: Cut the universal cover through t along a line that de nes a halfplane containing all the basis vectors except u, as illustrated in gure 16. If any c-oriented path crosses this cut at t, then it must do so in direction u by the halfplane condition and the fact that u is a tangent basis vector. If the crossing is not at t, then we can move it to t without increasing the number of links as follows. Because of the halfplane condition, a c-oriented path must cross the cut using an edge e that is parallel to u. Separate the universal cover into three pieces by a line segment through t and parallel to u. We can shorten the path by a portion of this line segment the number of links does not increase because edge e is cut o the path. For rectilinear paths and any convex distance function de ned by three vectors, all vectors satisfy the halfplane condition and lemma 6.6 implies that a minimum-link path goes through all the points with tangents that are basis vectors. To compute the minimum-link c-oriented path, we could cut the Euclidean shortest path at all these points and compute the path greedily. This, however, is precisely the computation of the shortest path with fewest links|the path computed is minimum with respect to the convex distance function and the link metric simultaneously. 7 Conclusions We have shown that the universal covering space of a triangulated region gives a useful framework for optimizing paths in the region under the Euclidean and link metrics. We have given simple, direct algorithms for Euclidean shortest path trees and minimum-link paths that use arrays in place of nger search trees. We have also given new algorithms for computing minimum length and minimum link c-oriented paths. Acknowledgements We would like to thank Joseph Mitchell and Leonidas Guibas for discussions on these and related problems, and the referees for their comments. This research has been supported by Digital Equipment Corporation, ESPRIT Basic Research Action No. 3075 (project ALCOM) and an NSERC Research Grant (Canada). References 1] A. Aggarwal, H. Booth, J. O'Rourke, S. Suri, and C. K. Yap. Finding minimal convex nested polygons. Information and Computation, 83(1):98{110, Oct. 1989. 2] E. M. Arkin, J. S. B. Mitchell, and C. D. Piatko. Bicriteria shortest path problems in the plane. In Proceedings of the Third Canadian Conference on Computational Geometry, pages 153{156, Simon Fraser University, Vancouver, 1991. 3] M. A. Armstrong. Basic Topology. McGraw-Hill, London, 1979. 4] B. Baumgart. A polyhedral representation for computer vision. In Proceedings of the AFIPS National Computer Conference, pages 589{596, 1975. 5] B. Bhattacharya and G. T. Toussaint. A linear algorithm for determining translation separability of two simple polygons. Technical Report SOCS{86.1, School of Computer Science, McGill University, Montreal, 1986. 6] J. W. S. Cassels. An Introduction to the Geometry of Numbers. Springer-Verlag, Berlin, 1959. 7] B. Chazelle. A theorem on polygon cutting with applications. In Proceedings of the 23rd IEEE Symposium on Foundations of Computer Science, pages 339{349, 1982. 8] B. Chazelle. Triangulating a simple polygon in linear time. Discrete & Computational Geometry, 6:485{524, 1991. 9] K. L. Clarkson, S. Kapoor, and P. M. Vaidya. Rectilinear shortest paths through polygonal obstacles in O(n log2 n) time. In Proceedings of the Third Annual ACM Symposium on Computational Geometry, pages 251{257, 1987. 10] R. Cole and A. Siegel. River routing every which way, but loose. In Proceedings of the 25th IEEE Symposium on Foundations of Computer Science, pages 65{73, 1984. 11] J. Czyzowicz, P. Egyed, H. Everett, D. Rappaport, T. Shermer, D. Souvaine, G. Toussaint, and J. Urrutia. The aquarium keeper's problem. In Proceedings of the Second Annual ACM-SIAM Symposium on Discrete Algorithms, pages 459{464, Jan. 1991. 21 12] M. de Berg. Translating polygons with applications to hidden surface removal. In SWAT 90: Second Scandinavian Workshop on Algorithm Theory, number 447 in Lecture Notes in Computer Science, pages 60{70. Springer-Verlag, 1990. 13] M. de Berg. On rectilinear link distance. Computational Geometry: Theory and Applications, 1:13{34, 1991. 14] M. de Berg, M. van Kreveld, M. Overmars, and B. Nilsson. Finding shortest paths in the presence of orthogonal obstacles using a combined L1 and link metric. In SWAT 90: Second Scandinavian Workshop on Algorithm Theory, number 447 in Lecture Notes in Computer Science, pages 211{224. Springer-Verlag, 1990. 15] P. J. de Rezende, D. T. Lee, and Y. F. Wu. Rectilinear shortest paths with rectangular barriers. Discrete & Computational Geometry, 4:41{53, 1989. 16] E. Dijkstra. A note on two problems in connection with graphs. Numerische Mathematik, 1:269{271, 1959. 17] A. Fournier and D. Y. Montuno. Triangulating simple polygons and equivalent problems. ACM Transactions on Graphics, 3(2):153{174, 1984. 18] S. Gao, M. Jerrum, M. Kaufmann, K. Mehlhorn, W. Rulling, and C. Storb. On continuous homotopic one layer routing. In Proceedings of the Third Annual ACM Symposium on Computational Geometry, pages 392{402, 1987. 19] S. K. Ghosh. Computing the visibility polygon from a convex set and related problems. Journal of Algorithms, 12:75{95, 1991. 20] S. K. Ghosh and A. Maheshwari. An optimal algorithm for computing a minimum nested nonconvex polygon. Information Processing Letters, 36:277{280, 1990. 21] S. K. Ghosh and D. M. Mount. An output sensitive algorithm for computing visibility graphs. SIAM Journal on Computing, 20(5):888{910, 1991. 22] R. Graham. An e cient algorithm for determining the convex hull of a nite planar set. Information Processing Letters, 1:132{133, 1972. 23] L. Guibas, J. Hershberger, D. Leven, M. Sharir, and R. Tarjan. Linear time algorithms for visibility and shortest path problems inside triangulated simple polygons. Algorithmica, 2:209{233, 1987. 24] L. Guibas, L. Ramshaw, and J. Stol . A kinetic framework for computational geometry. In Proceedings of the 24th IEEE Symposium on Foundations of Computer Science, pages 100{111, 1983. 25] L. Guibas and J. Stol . Primitives for the manipulation of general subdivisions and the computation of Voronoi diagrams. ACM Transactions on Graphics, 4(2):74{123, 1985. 26] L. J. Guibas and J. Hershberger. Optimal shortest path queries in a simple polygon. Journal of Computer and System Sciences, 39(2):126{152, Oct. 1989. 27] L. J. Guibas, J. E. Hershberger, J. S. B. Mitchell, and J. S. Snoeyink. Minimum-link approximation of polygons and subdivisions. In W. L. Hsu and R. C. T. Lee, editors, ISA `91 Algorithms, number 557 in Lecture Notes in Computer Science, pages 151{162. Springer-Verlag, 1991. 28] V. W. Guillemin and A. Pollack. Di erential Topology. Prentice Hall, Englewood Cli s, NJ, 1974. 29] R. H. Guting. Conquering Contours: E cient Algorithms for Computational Geometry. PhD thesis, Dortmund, 1983. 30] R. H. Gutting and T. Ottmann. New algorithms for special cases of hidden line elimination problem. Computer Vision, Graphics, and Image Processing, 40:188{204, 1987. 31] S. Kapoor and S. N. Maheshwari. E cient algorithms for Euclidean shortest path and visibility problems with polygonal obstacles. In Proceedings of the Fourth Annual ACM Symposium on Computational Geometry, pages 172{182, 1988. 32] R. C. Larson and V. O. Li. Finding minimum rectilinear paths in the presence of barriers. Networks, 11:285{304, 1981. 33] D. T. Lee and F. P. Preparata. Euclidean shortest paths in the presence of rectilinear barriers. Networks, 14(3):393{410, 1984. 34] C. E. Leiserson and F. M. Maley. Algorithms for routing and testing routability of planar VLSI layouts. In Proceedings of the 17th Annual ACM Symposium on Theory of Computing, pages 69{78, 1985. 35] C. E. Leiserson and R. Y. Pinter. Optimal placement for river routing. SIAM Journal on Computing, 12(3):447{ 462, 1983. 22 36] J. S. B. Mitchell, C. Piatko, and E. M. Arkin. Computing a shortest k-link path in a polygon. In Proceedings of the 33rd IEEE Symposium on Foundations of Computer Science, pages 573{582, 1992. 37] J. S. B. Mitchell, G. Rote, and G. Woeginger. Minimum-link paths among obstacles in the plane. In Proceedings of the Sixth Annual ACM Symposium on Computational Geometry, pages 63{72, 1990. 38] D. M. Mount. The number of shortest paths on the surface of a polyhedron. SIAM Journal on Computing, 19(4):593{611, Aug. 1990. 39] J. R. Munkres. Topology: A First Course. Prentice-Hall, Englewood Cli s, N.J., 1975. 40] B. Nilsson, T. Ottmann, S. Schuierer, and C. Icking. Restricted orientation computational geometry. In Data structures and e cient algorithms., number 594 in Lecture Notes in Computer Science, pages 148{185. SpringerVerlag, 1992. 41] B. O'Neill. Elementary Di erential Geometry. Academic Press, New York, 1966. 42] R. Y. Pinter. River routing: Methodology and analysis. In R. Bryant, editor, The Third Caltech Conference on Very Large Scale Integration. Computer Science Press, Rockville, Maryland, 1983. 43] F. P. Preparata and M. I. Shamos. Computational Geometry|An Introduction. Springer-Verlag, New York, 1985. 44] G. J. E. Rawlins and D. Wood. Optimal computation of nitely oriented convex hulls. Information and Computation, 72:150{166, 1987. 45] D. Richards. Complexity of single-layer routing. IEEE Transactions on Computers, C-33(3):286{288, Mar. 1984. 46] J.-R. Sack. Rectilinear Computational Geometry. PhD thesis, McGill University, 1984. 47] M. Sharir and A. Schorr. On shortest paths in polyhedral spaces. SIAM Journal on Computing, 15:193{215, 1986. 48] S. Suri. A linear time algorithm for minimum link paths inside a simple polygon. Computer Vision, Graphics, and Image Processing, 35:99{110, 1986. 49] S. Suri and J. O'Rourke. Finding minimal nested polygons. In Proceedings of the 23rd Annual Allerton Conference on Communication, Control and Computing, pages 470{479, 1985. 50] X.-H. Tan, T. Hirata, and Y. Inagaki. The intersection searching problem for c-oriented polygons. Information Processing Letters, 37:201{204, 1991. 51] G. Toussaint. On separating two simple polygons by a single translation. Discrete & Computational Geometry, 4:265{278, 1989. 52] G. T. Toussaint. Movable separability of sets. In G. T. Toussaint, editor, Computational Geometry, pages 335{376. North Holland, Amsterdam, 1985. 53] G. T. Toussaint. Computing geodesic properties inside a simple polygon. Revue D'Intelligence Arti cielle, 3(2):9{42, 1989. Also available as technical report SOCS 88.20, School of Computer Science, McGill University. 54] C. A. Wang. Finding minimal nested polygons. BIT, 31:230{236, 1991. 55] C. A. Wang and E. P. F. Chan. Finding the minimum visible vertex distance between two nonintersecting simple polygons. In Proceedings of the Second Annual ACM Symposium on Computational Geometry, pages 34{42, 1986. 23 ...
View Full Document

This note was uploaded on 01/24/2012 for the course CS 598 taught by Professor Staff during the Fall '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online