Optimal Shortest Path and Minimum-Link Path Queries in the Presence of Obstacles ?
(Extended Abstract)
Yi-Jen Chiang and Roberto Tamassia Department of Computer Science Brown University Providence, R. I. 02912{1910
fyjc,
[email protected]
Abstract. We present ecient algorithms for shortest-path and minimumlink-path queries between two convex polygons inside a simple polygon, which acts as an obstacle to be avoided. We also extend our results to the dynamic case, and give a uni ed data structure that supports both queries for convex polygons in the same region of a connected planar subdivision. Performing shortest-path queries is a variation of the wellstudied separation problem, which has not been eciently solved before in the presence of obstacles. Also, it was not previously known how to perform minimum-link-path queries in a dynamic environment, even for two-point queries.
1 Introduction
In this paper we present ecient algorithms for shortest-path and minimumlink-path queries between two convex polygons inside a simple polygon, which acts as an obstacle to be avoided. We give ecient techniques for both the static and dynamic versions of the problem. Let R1 and R2 be two convex polygons with a total of h vertices that lie inside a simple polygon P with n vertices. The (geodesic) shortest path G(R1 ; R2) is the polygonal chain with the shortest length among all polygonal chains joining a point of R1 and a point of R2 without crossing edges of P . A minimum-link path L (R1; R2) is a polygonal chain with the minimum number of edges (called links) among all polygonal chains joining a point of R1 and a point of R2 without crossing edges of P . The number of links in L (R1; R2) is called the link distance dL(R1; R2). The related problem of computing the length of the shortest path between two polygons R1 and R2 without obstacle P has been extensively studied; this problem is also known as nding the separation of the two polygons, denoted by (R1; R2). If both R1 and R2 are convex their separation can be computed ?
Research supported in part by the National Science Foundation under grant CCR9007851, by the U.S. Army Research Oce under grants DAAL03-91-G-0035 and DAAH04{93{0134, and by the Oce of Naval Research and the Defense Advanced Research Projects Agency under contract N00014-91-J-4052, ARPA order 8225.
in O(log h) time (see, e.g., [4, 7]); if only one of them is convex an O(h)-time algorithm is given in [7]; if neither is convex, an optimal O(h)-time algorithm is recently given by Amato [1]. Although there has been a lot of work on the separation problem, the more general shortest-path problem for two objects in the presence of obstacle P has been previously studied only for the simple case when the objects are points, for which there exist ecient static [10] and dynamic [5, 9] solutions. The static technique of [10] supports two-point shortest-path queries in optimal O(log n) time (plus O(k) if the k edges of the path are reported), employing a data structure that uses O(n) space and can be built in linear time. The dynamic technique of [5] performs shortest-path queries between two points in the same region of a connected planar subdivision S with n vertices in O(log3 n) time (plus O(k) to report the k edges of the path), using a data structure with O(n log n) space that can support updates (insertions and deletions of edges and vertices) of S each in O(log3 n) time. The recent result of [9] improves the query and update times to O(log2 n), with space complexity also improved to O(n). The minimum-link path problem between two points has been extensively studied. In many applications such as robotics, motion planning, VLSI and computer vision, the link distance often provides a more natural measure of path complexity than the Euclidean distance. For example, in a robot system, a straight-line navigation is often much cheaper than rotation, thus it is desirable to minimize the number of turns in path planning [13, 14]. Also, in graph drawing, it is often desirable to minimize the number of bends [15]. All previously known techniques for the minimum-link path problem are restricted to the static case. The best known results are due to Arkin et al. [2]. Their data structure uses O(n3 ) space and preprocessing time, and supports minimum-link-path queries between two points and between two segments in optimal O(log n) time (plus O(k) if the k links are reported). Their technique can also perform queries between two convex polygons, however, in suboptimal O(log h log n) time. Our main results are outlined as follows, where all bounds are worst-case. (i) Let P be a simple polygon with n vertices. There exists an optimal data structure that supports shortest-path queries between two convex polygons with a total of h vertices inside P in time O(log h + log n) (plus O(k) if the k links of the path are reported), using O(n) space and preprocessing time. (ii) Let P be a simple polygon with n vertices. There exists a data structure that supports minimumlink-path queries between two convex polygons with a total of h vertices inside P in optimal time O(log h+log n) (plus O(k) if the k links of the path are reported), using O(n3) space and preprocessing time. (iii) Let S be a connected planar subdivision whose current number of vertices is n. Shortest-path and minimumlink-path queries between two convex polygons with a total of h vertices that lie in the same region of S can be performed in time O(log h + log2 n) (plus O(k) to report the k links of the path) and O(log h + k log2 n), respectively, using a fully dynamic data structure that uses O(n) space and supports insertions and deletions of vertices and edges each in O(log2 n) time. 2
The contributions of this work can be summarized as follows. (i) We provide the rst optimal data structure for shortest-path queries between two convex polygons inside a simple polygon P that acts as an obstacle. No ecient data structure was known before to support such queries. All previous techniques either consider the case where P is not present or the case where the query objects are points. (ii) We provide the rst data structure for minimum-linkpath queries between two convex polygons inside a simple polygon P in optimal O(log h + log n) time. The previous best result [2] has query time O(log h log n) (and the same space and preprocessing time as ours). (iii) We provide the rst fully dynamic data structure for shortest-path queries between two convex polygons in the same region of a connected planar subdivision S . No such data structure was known before even for the static version. (iv) We provide the rst fully dynamic data structure for minimum-link-path queries between two convex polygons in the same region of a connected planar subdivision S . No such data structure was known before even for two-point queries. We brie y outline our techniques. Given the available static techniques with optimal query time for shortest paths and minimum-link paths between two points, our main task in performing the two-polygon queries is to nd two points p 2 R1 and q 2 R2 such that their shortest path or minimum-link path gives the desired path. The notion of geodesic hourglass is central to our method. The geodesic hourglass is open if R1 and R2 are mutually visible, and closed otherwise. As for shortest-path queries, the case where R1 and R2 are mutually visible is a basic case that, surprisingly, turns out to be nontrivial, and our solution makes use of interesting geometric properties. If R1 and R2 are not visible, then the geodesic hourglass gives two points p1 and p2 that are respectively visible from R1 and R2 such that the shortest path between any point of R1 and any point of R2 must go through p1 and p2. Then the shortest path G (R1; R2) is the union of the shortest paths between R1 and p1 , between p2 and R2 (both are basic cases), and between two points p1 and p2 . The geodesic hourglass also gives useful information for minimum-link-path queries. When it is open, a minimumlink path is just a single segment; if it is closed, then it gives two edges such that extending them to intersect R1 and R2 gives the desired points p and q whose minimum-link path is a minimum-link path L(R1; R2). However, it seems dicult to compute the geodesic hourglass in optimal time. Interestingly, we can get around this diculty by computing a pseudo hourglass that gives all the information we need about the geodesic hourglass. We also extend these results to the dynamic case, by giving the rst dynamic method for minimumlink-path queries between two points. For the geometric terminology used in this paper, see [12]. A cusp of a polygonal chain is a vertex v whose adjacent vertices are both strictly above or below v. Given two points p and q in a simple polygon P , it is well known that their shortest path G (p; q) is unique while a minimum-link path is not. Adopting the terminology of [14], we de ne the (unique) greedy minimum-link path L (p; q) to be the minimum-link path whose rst and last links are respectively the extensions of the rst and last links of G(p; q), and whose other links are the 3
extensions of the windows of the window partition of p [14]. In the following we use the term \window" to refer to both a window and its extension. Given a shortest path G (p; q), an edge e 2 G(p; q) is an in ection edge if its predecessor and its successor lie on opposite sides of e. It is easily seen that an edge e 2 G(p; q) is an in ection edge if and only if it is an internal common tangent of the boundaries of P . In this extended abstract proofs and technical details are omitted. They can be found in the full version [6].
2 Shortest Path Queries
Now we discuss how to compute the shortest path G(R1; R2). The data structure of [10] computes the length and an implicit representation of the shortest path between any two points inside P in O(log n) time, using O(n) space and preprocessing time after triangulating P (again in O(n) time by [3]). We modify this data structure so that associated with the implicit representation of a shortest path G, there are two balanced binary trees respectively maintaining the in ection edges and the cusps on G in their path order. With this data structure, our task is to nd points p 2 R1 and q 2 R2 such that G(p; q) = G (R1; R2). We say that p and q realize G(R1 ; R2). To get a better intuition, let us imagine surrounding R1 and R2 with a rubber band inside P . The resulting shape is called the relative convex hull of R1 and R2 . It is formed by four pieces: shortest paths 1 = G (a1 ; a2), 2 = G (b1; b2) (a1 ; b1 2 R1 and a2 ; b2 2 R2 ), and the boundaries of R1 and R2 farther away from each other. We call a1; b1; a2, and b2 the geodesic tangent points. Let s1 = (a1; b1) and s2 = (a2 ; b2). If we replace R1 and R2 with s1 and s2 , then the relative convex hull of s1 and s2 is an hourglass H (s1 ; s2) bounded by s1 ; s2 ; 1, and 2 . We call H (s1 ; s2) the geodesic hourglass. We say that H (s1 ; s2 ) is open if 1 and 2 do not intersect, and closed otherwise. When H (s1 ; s2) is closed, there is a vertex p1 at which 1 and 2 join together, and a vertex p2 at which the two paths separate (possibly p1 = p2 ); we call p1 and p2 the apices of H (s1 ; s2) (see Fig. 1(b)). Also, we say that G (a1 ; p1) and G (b1; p1) form a funnel F (s1 ). The only internal common tangent 1 of P among all edges of F (s1 ) is called the penetration of F (s1 ), and similarly for 2 in funnel F (s2 ) (see Fig. 1(b)). Hereafter we use HG to denote the geodesic hourglass, and a1; b1 (2 R1), a2; b2 (2 R2) to denote the geodesic tangent points. We say that R1 and R1 are mutually visible if there exists a line l connecting R1 and R2 without crossing any edge of P ; we call l a visibility link. Observe that HG is open if and only if R1 and R2 are mutually visible (see Fig. 1(a)). If HG is closed, then G(R1 ; R2) must go through p1 and p2 (see Fig. 1(b)), i.e., G (R1; R2) = G (R1; p1) [ G (p1; p2) [ G (p2 ; R2). Note that p1 and p2 are respectively visible from R1 and R2. In summary, there are two main tasks: (i) deciding whether HG is open or closed, and nding apices p1 and p2 when HG is closed, and (ii) computing G(R1 ; R2) when R1 and R2 are mutually visible. 4
(a)
(b) u1
l1
R1
a1
s1
a1"=v' b1
v
r1
R1
a2 R1
s2 w' CL1=πaG(l1, w) R 2 2
b2
s1
y1
CR1=πG(r1, x2) C'R1=πG(y1, ya21)
Fig.1. Geodesic hourglass HG : (a) HG is BL open; (b) HG is closed.
w=y2
p2
b1
s2 R2
b2 ρ2
ρ1 p1 BR
x2
x1 Fig. 2. A running example for Algorithm Pseudo-Hourglass in the case where has no cusps and CL1 \ R1 = ;. CR2=πG(r2, x2)
The Pseudo Geodesic Hourglass We rst discuss howRto2compute the inforCL2the =πgeodesic mation we need about hourglass G(l2, x 1) l2HG . In addition to the above infor- r mation, the data below are also needed for minimum-link d2paths (see Section 3): 2
a visibility link between R1 and R2 when HG is open, and the penetrations of when it is closed. As shown in [2], computing HG takes O(log h log n) time, which is suboptimal. To achieve optimal time, we do not compute HG exactly, but rather obtain all the needed information by computing a pseudo hourglass H 00 such that if H 00 is open then HG is open, and if H 00 is closed then HG is closed with the same penetrations and apices. The following algorithm performs the described function in time O(log h + log n). HG
Algorithm Pseudo-Hourglass
1. Ignore P and compute the ordinary external common tangents (a01 ; a02) and (b01 ; b02) between R1 and R2 using algorithm [11], where a01 ; b01 2 R1 and a02 ; b02 2 R2. Let s01 = (a01 ; b01) and s02 = (a02; b02). Compute shortest paths 1 = G(a01 ; a02) and 2 = G (b01; b02). If they are disjoint then s01 and s02 (and also R1 and R2) are mutually visible. Compute an internal common tangent l between 1 and 2 , report fopen with visibility link lg and stop. 2. Else (1 and 2 are not disjoint), let u1 and d1 be the highest and lowest vertices of R1, respectively, and similarly de ne u2 and d2 for R2. Compute shortest paths G(u1 ; u2), G(u1 ; d2), G (d1; u2) and G(d1 ; d2). Take as the one with the largest number of cusps (break ties arbitrarily). From Ri; i = 1; 2, compute horizontal projection points li and ri respectively on the left and right boundaries BL and BR of P , depending on the information about the cusps on (see Fig. 2 and 3(b)). 3. Compute shortest paths l = G (l1 ; l2) and r = G (r1; r2). Extract the \left bounding convex chain" CL1 for R1 as the portion of l from l1 to x, 5
(a)
(b) C
a2 r1 l1 CL1 u BL u q'q R2 BR z s R R1 1 2 1"=v" ' vertex v1 on BR orathe wheret1x ist2thet2 rst rst point c with y(c) = y(l1 ) or t1' the second cusp c2 , whichever is closest to Ra11, or x = l2 if none of v1 ; c and c2 exists. Similarly extract CR1 for R1 from r . The chains CL2 and CR2 for b2 Fig. 2). R2 are computed analogously (see b s 4. Compute pseudo tangent points a001 ; b001 2 R1 and a002 ; b002 2 R2 such that the z R 2 00 00 00 00 00 00 00 00 00 b hourglass H formed by G (a1 ; a2 ); G(b1 ; b2 ); s1 = (a1 ; b1 ) and s2 = pseudo (a002D ; b00 from R1 and CL1 by 2 ) has the desired property. Point a00100is computed the following steps (and analogously for b1 ; a002 and b002 ). r2 l (a) Check whether R intersects C (viewing C = (l ; x)2as a con-
a1 aR11" s1 BL
b1
p' p a1 w
1
L1
L1
G
1
vex polygon with edge (l1 ; x) added) using the algorithm [4], which also reports a common point g inside both R1 w" and CL1 if they intersect. If R1 \ CL1 = ;, nd the internal common tangent t = (v; w) between R1 and CL1 (see Fig. 2). (i) t \ CR1 = ;. Set a001 := v. (ii) t \ CR1 = fy1 ; y2g. Let CR0 1 be the portion of CR1 between y1 and y2 . Find the external comC1L1 =CπR0G1 ,(land b) a001 := v0C= mon tangent (v0 ; w0) between R and (see π Fig.(b, 2). z) 1, set (b) Else (R1 \CL1 6= ;, with a common point g inside both R1 and CL1),Gthen there is only one edge of CL1 intersecting R1. Compute this edge (u; b) using the fact that segment (g; u1) intersects only (u; b) among the edges of CL1. Suppose b is closer to R2 than u. (i) b is on the left boundary BL . Compute a001 as the tangent point from b to R1 (see Fig. 3(a)). (ii) b is on the right boundary BR . Take C as the convex portion of l (oriented from R1 to R2 ) from b to z , where z is the rst vertex v10 on BL again or the rst point c0 with y(c0 ) = y(b) or the second cusp c02 after b, whichever is closest to R1. Find the external common tangent (v00 ; w00) between R1 and C , and set a001 := v00 (see Fig. 3(b)). 5. Compute shortest paths 1 = G (a001 ; a002 ) and 2 = G (b001 ; b002 ) to form pseudo hourglass H 00. If H 00 is open, then compute an internal common tangent l between 1 and 2 , report fopen with visibility link lg and stop. Else (H 00 is closed), extract the penetrations 1 and 2 and apices p1 and p2 of H 00, report fclosed with penetrations 1 and 2 and apices p1 and p2 g, and stop.
Fig. 3. Steps 4b(i){(ii) of Algorithm Pseudo-Hourglass: (a) b 2 BL ; (b) b 2 BR .
Fig. 4. Lemma 1 6
a1
q' C
a2
C2=(v,..., q') R C1=(u,..., t2') Visible t1t2Query The Case of RMutually ' t Polygons We now discuss 2how to 1 p' compute G (R1; R2) when R1 and R23 are mutually visible. Ignoring s2 0P and 0 2 R1 and computing the sseparation of R and R , we can nd p 1 2 θi z compute (qp0 ; q20).RIf2 with length(p0 ; q0)1= (w R1; R2) in O(log h) time.vNow we G i G(p0 ; q0) has only one link, then (p0 ; q0) is the shortest path G (R1; R2). Othq'=b erwise G(p0 ; q0) must touch the boundary of φP , and vthere are two 2 cases: (1) i-1 t i 0 0 b1 only oneθofi-1 G(p ; q ) touches G(a1 ; a2) and 4G (bt1; b2); or (2) G (p0 ; q0) touches 2 both G(a1 ; a2) and G(b1 ; b2). D 0; q0 ) with p0 2 R1 and v 1. Let the geodesic hourglass HG be open and φ(pi-1 t1'Lemma 0 q 2 R2 be the shortest path between R1 and R2 without obstacle P . If G (p0; q0) touches only one of G (a1 ; a2) and G (b1; b2), say G(a1 ; a2), then G (R1; R2) touches uG (a1; a2) but does not touch G (b1 ; b2). (See Fig. 4.) Therefore in the above situation (see Fig. 4), if t01 and t02 are the points of obstacle C where G(p0 ; q0) rst touches C and nally leaves C , respectively, and t1 and t2 are the points of C where G (p; q) rst touches C and nally leaves C (recall that G(p; q) = G(R1; R2)), then t2 is the point where the shortest path G(t01 ; R2) from t01 to R2 nally leaves C , and similarly for t1. We say that t2 2 C and q 2 R2 realize G(t01 ; R2), and similarly for the other side. It is clear that G (R1; R2) consists of (p; t1); G(t1 ; t2) and (t2 ; q). So we only need to independently compute t2 2 C and q 2 R2 that realize G (t01 ; R2), and t1 and p that realize G(t02 ; R1). The other case where G(p0 ; q0) touches both G (a1; a2 ) and G (b1; b2) can be handled in the same way: Lemma 2. Let the geodesic hourglass HG be open and (p0; q0 ) with p0 2 R1 and q0 2 R2 be the shortest path between R1 and R2 without obstacle P . If G (p0; q0) touches both G(a1 ; a2) and G(b1 ; b2), say rst G (a1 ; a2) (entering at point t1 and leaving at point t3 ) and then G (b1; b2) (entering at t4 and leaving at t2 ), then G (R1; R2) = G(R1 ; t3) [ (t3 ; t4) [ G (t4 ; R2). (See Fig. 5.)
Fig.5. Lemma 2
Fig. 6. Lemma 3
We now discuss how to compute t2 2 C and q 2 R2 that realize G (t01; R2) in the situation of Fig. 4. We only need to consider the two convex chains G(u; t02) 7
(b)
(a) q'
θj+1
θj+1 C2
θ'
(denoted by C1) and the clockwise boundary v; :::; q0) ofq') R2 (denoted by C2 ), C2(=(v,..., where (u; v' v) is the external common tangent between R2 and the convex hull of r' u 2 C and v 2 R2 . Our algorithm uses the following θ'properties. C with
q uj+1Lemma 3. Let v' order. v1 ; v2; :::; vk be a sequence of points on C2 in clockwise C2If C1=(u,..., t ') 2 u =t ' v" θ we draw a tangent to kC1 from and make angles i and i (see Fig. 6), 2 j each vφi i+1 t1' then (1) 1 < 2 < ::: < k and 1 > 2 > ::: > k ; and (2) if i 2 then 0 0 0 θ" 0 i ; t1) < G (vi?1; t1) < , and if i 2 then G (vi ; t1) < G(vi+1 ; t1) < t2=uj G;(vand 0 u with i 2 and iq 2 . (3) minr" w2C2 G (w; t1) occursθat w = vi j+1 i u C θ i+1 1 i+1 uj-1 t1' t1' φi v" θ i-1 t2=uj ui θ" v uj-1 φi-1 ui-1 u1=u
C1
Fig. 7. Lemma 4
Fig. 8. Lemma 4 part (2)
Lemma 4. Let u1 = u; u2; :::; uk = t02 be the vertices of C1 in counterclockwise
order. If we extend each edge (ui?1 ; ui) to intersect C2 and make angles i and i (see Fig. 7), then (1) 2 < 3 < ::: < k and 2 > 3 > ::: > k ; and (2) if t2 2 C1 and q 2 C2 realize G (t01 ; C2), where t2 is some vertex uj , then j < 2 and j +1 > 2 (see Fig. 8).
The following algorithm computes t2 2 C1 and q 2 C2 that realize G (t01; C2) in time O(log h + log n). Algorithm Double-Search
1. If either j C1 j= 1 or j C2 j 2 then go to step 3. 2. Else, let v and w be the median vertices of current C1 and C2. Prune the wiggly portion(s) as shown in Fig. 9, and go to step 1. 3. Now j C1 j= 1 or j C2 j 2. (a) j C2 j= 1. The only vertex of C2 is q. Compute the tangent from q to C1 and take t2 as the tangent point. Report q and t2, and stop. (b) j C2 j= 2. Let C2 = (w1 ; w2) with the interior of R2 to the right of ray (w1; w2). From w1 and w2 compute tangents (w1; v1) and (w2; v2 ) of C1, where v1 ; v2 2 C1. Let 1 = 6 v1 w1w2 and 2 = 6 v2 w2w1 . (i) 1 2 . Report q = w1, t2 = v1 and stop. (ii) 2 2 . Report q = w2, t2 = v2 , and stop. (iii) 1 < 2 and 2 < 2 . Perform a binary search on C1 to nd vertex t2 with (t2 ; q) tangent to C1, where q is the projection point of t2 on (w1; w2). Report t2 and q, and stop. (c) j C1 j= 1. The only vertex of C1 is t2 . Perform a binary search on C2 to nd the point q 2 C2 such 8
θj
(b)
(a)
w'
w' C1
C2
C1
that length(t2 ; q) iswthe shortest distance from t2 to C2. Report t2 and q, and stop. θ θ
x
v
v'
v'
v
C2
w x
(d)
(c)
C1
C1 v
v'
θ
θ v'
w'
x w
v
C2
x w'
C2
w
Fig.9. The cases (a){(f) in step 2 of Algorithm Double-Search, depending on whether
x
(e)
is below, above, or on (w; w ) and 2 or not. 0
(f)
The algorithm below computes G (R1; R2) for R1 and R2 mutually visible in time O(log h + log n) (plus O(k) to report the k links of the path). Algorithm Visible-Path
1. Ignore P and compute (R1; R2) by any method (e.g., [7]), giving also p0 2 w'2 with length(p0; q0) = (R1; R2). C1 R1 and q0 2 R 2. Compute (p0 ; q0). If G (p0; q0) has only one link, then report G (R1; R2) = w' C1 (p0 ; q0) and Gstop. θ x 3. Otherwise, let (p0; t01) and (t02; q0) be the rst and last links of G (p0; q0). (a) v'Find the external 0 0 0 0 There is noθin ection C edge in ( p ; q ). Let C = ( t ; t ). G G 1 2 2 v common tangent x (u; v) between C and R2 with u 2 C and v 2 R2; let C1 w bevG(u; t02) and C2 be the clockwise boundary (v; :::; q0) of R2. Compute 0 t2 2 C and q 2 R that realize ( t ; R ) by applying Double-Search on C 2 G 1 2 1 w v' and C2, and similarly t1 2 C and p 2 R1 that realize G (t02; R1). Report G (R1; R2) = (p; t1) [ G(t1 ; t2) [ (t2; q) and stop. (b) There is an in ection edge (t3 ; t4) in G (p0; q0 ). Use Double-Search to compute two pairs of points 9
C2
that realize G(R1 ; t3) and G (t4; R2). Report G (R1; R2) = (t3 ; t4) [ G (t4; R2) and stop.
G(R1 ; t3)
[
The Overall Algorithm The following algorithm computes G(R1; R2).
1. Perform Pseudo-Hourglass to decide if HG is open or closed (with apices p1 (closer to R1 ) and p2 (closer to R2)). 2. If HG is open, apply Visible-Path to report G (R1; R2) and stop. 3. Else, apply Visible-Path to nd G (R1; p1) and G (p2; R2). Compute G (p1; p2), report G(R1 ; R2) = G(R1 ; p1) [ G(p1 ; p2) [ G (p2 ; R2) and stop.
Theorem 5. Let P be a simple polygon with n vertices. There exists an optimal data structure that supports shortest-path queries between two convex polygons with a total of h vertices inside P in time O(log h + log n) (plus O(k) if the k links of the path are reported), using O(n) space and preprocessing time.
In a dynamic environment, we use the data structure of [9] to support two-point shortest-path queries within the two-polygon shortest-path query algorithm.
Theorem 6. Let S be a connected planar subdivision whose current number of vertices is n. Shortest-path queries between two convex polygons with a total of h vertices that lie in the same region of S can be performed in time O(log h +log2 n) (plus O(k) to report the k links of the path), using a fully dynamic data structure that uses O(n) space and supports updates of S in O(log2 n) time.
3 Minimum-Link Path Queries
Given R1 and R2 inside P , we want to compute their minimum-linkpath L (R1; R2). The data structure of [2] supports minimum-link-path queries between two points inside P in O(log n) time (plus O(k) if the k links are reported), using O(n3) space and preprocessing time. We now show how to perform two-polygon queries in optimal time, using the same data structure.
Lemma 7. Let HG be the geodesic hourglass between R1 and R2. If HG is closed, then there exists a minimum-link path L (R1; R2) that uses the penetrations of HG as the rst and last links.
We now give the algorithm for computing a minimum-link path L (R1; R2). 1. Use Pseudo-Hourglass to decide if HG is open (with a visibility link l) or closed (with penetrations 1 (closer to R1) and 2 (closer to R2)). 2. If HG is open, then report L(R1 ; R2) = l, dL (R1; R2) = 1 and stop. 3. Otherwise, extend 1 and 2 to intersect R1 and R2 respectively at p and q, and compute L(p; q) (and dL (p; q)). Report L (R1; R2) = L(p; q), dL(R1 ; R2) = dL(p; q) and stop.
Theorem 8. Let P be a simple polygon with n vertices. There exists a data structure that supports minimum-link-path queries between two convex polygons with a total of h vertices inside P in optimal time O(log h + log n) (plus O(k) if the k links of the path are reported), using O(n3 ) space and preprocessing time. 10
Now we show that the dynamic data structure of Theorem 6 can also support minimum-link-path queries between two convex polygons.
Dynamic Two Point Queries Let p and q be two points in the same region P of the planar subdivision. Let e1 ; ; ej be the in ection edges of the shortest path G(p; q). Then e1 ; ; ej partition G(p; q) into inward convex subchains. It is shown that every in ection edge e 2 G (p; q) must be contained in L (p; q) [2,
8]. Hence, extending each in ection edge of G (p; q) by ray shooting on both sides, together with the extensions of the rst and last links of G (p; q), we have xed windows W1 ; ; Wj +2. Now the task in computing L (p; q) is to connect consecutive xed windows. In particular, each Wi has a portion (u; v) 2 G(p; q), with u closer to p than v in G(p; q). Let the endpoints of Wi be u0 and v0 such that Wi = (u0 ; u; v; v0). We call (u0; u) the front of Wi and (v; v0 ) the rear of Wi . We want to connect the rear of Wi with the front of Wi+1 for each i = 1; ; j +1.
Lemma 9. Let Wi and Wi+1 be consecutive xed windows, W the front of Wi+1 , and w the rear of Wi (or a window between the rear of Wi and W ). If the hourglass H (w; W ) is closed, then the window w0 following w is the penetration of funnel F (w). The following algorithm for computing L (p; q) runs in time O(k log2 n), where k is the number of links in L(p; q).
Algorithm Point-Query
1. Compute G (p; q). If G(p; q) has only one link, report L(p; q) = (p; q), dL (p; q) = 1 and stop. 2. Else, perform ray-shooting queries to extend the in ection edges and the rst and last links of G(p; q) to obtain xed windows W1 ; ; Wj . 3. For each pair of non-intersecting Wi and Wi+1 , repeat step 4 to compute the windows connecting Wi and Wi+1 . 4. Initially, let w be the rear of Wi . Let W = (a2 ; b2) be the front of Wi+1 with a2 2 G(p; q). (a) Assume that w = (a1; b1) with a1 on G(p; q). Compute G (b1 ; b2). (b) If G (b1; b2) has no in ection edges, then H (w; W ) is open. Compute an internal common tangent t between G (a1; a2) and G (b1; b2), set t to be the window following w and exit step 4. (c) Else (G (b1; b2) has in ection edges), extract the penetration and apex p1 of funnel F (w). Extend in both directions (hitting w at v and P at u) to obtain the window (v; u) following w. Set w := (p1 ; u) and go to step 4(a). 5. Now there are windows w1 ; ; wk connecting p and q. Let vi = wi \ wi+1 , i = 1; ; k ? 1. Report L (p; q) = (p; v1; ; vk?1; q), dL (p; q) = k and stop. Now we can use Algorithm Point-Query to support two-point queries within the two-polygon minimum-link-path query algorithm.
Theorem10. Let S be a connected planar subdivision whose current number of vertices is n. Minimum-link-path queries between two convex polygons with a total of h vertices that lie in the same region of S can be performed in time 11
2
O(log h + k log n)
(where k is the number of links in the reported path), using a fully dynamic data structure that uses O(n) space and supports updates of S in O(log2 n) time.
References
1. Nancy M. Amato. An optimal algorithm for nding the separation of simple polygons. In Proc. 3rd Workshop Algorithms Data Struct., volume 709 of Lecture Notes in Computer Science, pages 48{59. Springer-Verlag, 1993. 2. E. M. Arkin, J. S. B. Mitchell, and S. Suri. Optimal link path queries in a simple polygon. In Proc. 3rd ACM-SIAM Sympos. Discrete Algorithms, pages 269{279, 1992. 3. B. Chazelle. Triangulating a simple polygon in linear time. Discrete Comput. Geom., 6:485{524, 1991. 4. B. Chazelle and D. P. Dobkin. Intersection of convex objects in two and three dimensions. J. ACM, 34:1{27, 1987. 5. Y.-J. Chiang, F. P. Preparata, and R. Tamassia. A uni ed approach to dynamic point location, ray shooting, and shortest paths in planar maps. In Proc. 4th ACM-SIAM Sympos. Discrete Algorithms, pages 44{53, 1993. 6. Y.-J. Chiang and R. Tamassia. Optimal shortest path and minimum-link path queries between two convex polygons in the presence of obstacles. Report CS-9403, Comput. Sci. Dept., Brown Univ., Providence, RI, 1994. 7. F. Chin and C. A. Wang. Optimal algorithms for the intersection and the minimum distance problems between planar polygons. IEEE Trans. Comput., C32(12):1203{1207, 1983. 8. S. Ghosh. Computing visibility polygon from a convex set and related problems. J. Algorithms, 12:75{95, 1991. 9. M. T. Goodrich and R. Tamassia. Dynamic ray shooting and shortest paths via balanced geodesic triangulations. In Proc. 9th Annu. ACM Sympos. Comput. Geom., pages 318{327, 1993. 10. L. J. Guibas and J. Hershberger. Optimal shortest path queries in a simple polygon. J. Comput. Syst. Sci., 39:126{152, 1989. 11. M. H. Overmars and J. van Leeuwen. Maintenance of con gurations in the plane. J. Comput. Syst. Sci., 23:166{204, 1981. 12. F. P. Preparata and M. I. Shamos. Computational Geometry: an Introduction. Springer-Verlag, New York, NY, 1985. 13. J. H. Reif and J. A. Storer. Minimizing turns for discrete movement in the interior of a polygon. IEEE J. Robot. Autom., pages 182{193, 1987. 14. S. Suri. On some link distance problems in a simple polygon. IEEE Trans. Robot. Autom., 6:108{113, 1990. 15. R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Comput., 16(3):421{444, 1987. This article was processed using the LaTEX macro package with LLNCS style