On Romeo and Juliet Problems: Minimizing Distance-to-Sight

We introduce a variant of the watchman route problem, which we call the quickest pair-visibility problem. Given two persons standing at points $s$ and $t$ in a simple polygon $P$ with no holes, we want to minimize the distance they travel in order to see each other in $P$. We solve two variants of this problem, one minimizing the longer distance the two persons travel (min-max) and one minimizing the total travel distance (min-sum), optimally in linear time. We also consider a query version of this problem for the min-max variant. We can preprocess a simple $n$-gon in linear time so that the minimum of the longer distance the two persons travel can be computed in $O(\log^2 n)$ time for any two query positions $s,t$ where the two persons start.


Introduction
In the watchman route problem, a watchman takes a route to guard a given region-that is, any point in the region is visible from at least one point on the route. It is desirable to make the route as short as possible so that the entire area can be guarded as quickly as possible. The problem was first introduced in 1986 by Chin and Ntafos [1] and has been extensively studied in computational geometry [2,3]. Though the problem is NP-hard for polygons with holes [1,4,5], an optimal route can be computed in time O(n 3 log n) for simple n-gons [6] when the tour must pass through a specified point, and O(n 4 log n) time otherwise.
In this paper, we study a variant of the watchman route problem. Imagine two persons, Romeo and Juliet, travel in a region from their starting locations. They want to minimize the distance they travel in order to see each other. More precisely, given the region and the locations where Romeo and Juliet start, the objective is to compute their paths, one for Romeo and one for Juliet, such that they see each other after traveling along the paths and their travel distances are minimized. This problem can be formally defined as follows.
Problem (quickest pair-visibility problem). Given two points s and t in a simple polygon P , compute the minimum distance that s and t must travel in order to see each other in P .
In the min-max variant of the quickest pair-visibility problem, we want to minimize the longer distance that the two points travel to see each other. In the min-sum variant, we want to minimize the total travel distance that the two points travel to see each other.
This problem may sound similar to the shortest path problem between s and t, in which the objective is to compute the shortest path π(s, t) for s to reach t. However, they differ even for a simple case: for any two points lying in a convex polygon, the distance in the quickest pair-visibility problem is zero while in the shortest path problem, it is their geodesic distance |π(s, t)|. We would like to mention that our algorithm to be presented later uses the shortest path as a guide in computing the quickest pair-visibility paths.  Figure 1: (a) The quickest pair-visibility problem finds two paths π(s, s1) and π(t, t1) such that s1t1 ⊂ P and max{|π(s, s1)|, |π(t, t1)|} or |π(s, s1)| + |π(t, t1)| is minimized. The quickest visibility problem for query point t finds a shortest π(s, t2) with tt2 ⊂ P . (b) min-max: Every pair (s , t * ), where t * is some point within the geodesic disk centered in t with radius π(s, s ), is an optimal solution to the min-max problem. (c) min-sum: An instance where |π(s, s )| + |π(t, v4)| = |π(s, v4)| + |π(t, v5)|. Therefore, both (s , v4) and (v4, v5) are optimal solutions to the min-sum problem.
The quickest pair-visibility problem occurs in optimization tasks. For example, mobile robots that use a line-of-sight communication model are required to move to mutually-visible positions to establish communication [7]. An optimization task here is to find shortest paths for the robots to meet the visibility requirement for establishing communication among them.
Wynters and Mitchell [8] studied this problem for two agents acting in a polygonal domain in the presence of polygonal obstacles and gave an O(nm)-time algorithm for the min-sum variant (where n is the number of vertices of the polygonal domain, and m is the number of edges of the visibility graph of all corners) and an O(n 3 log n)-time algorithm for the min-max variant.
A query version of the quickest visibility problem has also been studied [9,10,11]. In the query problem, a polygon and a source point lying in the polygon are given, and the goal is to preprocess them and construct a data structure that supports, for a given query point, finding the shortest path taken from the source point to see the query point efficiently. Khosravi and Ghodsi [10] considered the case for a simple n-gon and presented an algorithm to construct a data structure of O(n 2 ) space so that, given a query, it finds the shortest visibility path in O(log n) time. Later, Arkin et al. [9] improved the result and presented an algorithm for the problem in a polygonal domain. Very recently, Wang [11] presented an improved algorithm for this problem for the case that the number of the holes in the polygon is relatively small. Figure 1(a) illustrates differences in these problems for a simple polygon and two points, s and t, in the polygon.

Our results
In this paper, we consider both min-max and min-sum variants of the quickest pair-visibility problem for a simple polygon. That is, either we want to minimize the maximum length of two traveled paths (min-max) or we want to minimize the sum of the lengths of two traveled paths (min-sum). We give a sweep-line-like approach that "rotates" the lines-of-sight along vertices on the shortest path between the start positions, allowing us to evaluate a linear number of candidate solutions on these lines. Throughout the sweep, we encounter solutions to both variants of the problem. We further show that our technique can be implemented in linear time.
We also consider a query version of this problem for the min-max variant. We can preprocess a simple n-gon in linear time so that the minimum of the longer distance the two query points travel can be computed in O(log 2 n) time for any two query points.

Preliminaries
Let P be a simple polygon and ∂P be its boundary where ∂P ⊂ P . The vertices of P are given in counterclockwise order along ∂P . We denote the shortest path within P between two points p, q ∈ P by π(p, q) and its length by |π(p, q)|. Likewise, we denote the shortest path within P between a point p ∈ P and a line segment ⊂ P by π(p, ). We say a point p ∈ P is visible from another point q ∈ P (and q is visible from p) if and only if the line segment pq is contained in P . For two starting points s and t, our task is to compute a pair (s , t ) of points such that s and t are visible to each other, where we wish to minimize the lengths of π(s, s ) and π(t, t ). In the min-max setting, we wish to minimize max{|π(s, s )|, |π(t, t )|}. For the min-sum setting, we wish to minimize |π(s, s )| + |π(t, t )|. Note that, for both variants, the optimum is not necessarily unique; see Figure 1(b) and (c).
We say a segment g is tangent to a path π at a vertex v if v ∈ g ∩ π and v's neighboring vertices on π are in a closed half-plane bounded by the line containing g. Let v 0 , v 1 , . . . , v k−1 , v k be the sequence of vertices on π(s, t) with s = v 0 and t = v k . Lemma 1. Unless s and t are visible to each other, there is an optimal solution (s * , t * ) such that s * t * is tangent to the shortest path π(s, t) at a vertex v of π(s, t).
Proof. We first show that there is a vertex of P lying on s * t * . Without loss of generality, assume that s * t * is horizontal with s * lying to the left of t * . Let = xx be the maximal segment contained in P that contains s * t * with x closer to s * than to t * . If s = s * (or t = t * ), then the lemma holds immediately because s (or t) is an endpoint of s * t * . Assume to the contrary that s * t * contains no vertex of P . Then there are points p ∈ P in a neighborhood of s * and q ∈ P in a neighborhood of t * such that p and q are visible to each other, and max{|π(s, p)|, |π(t, q)|} < max{|π(s, s * )|, |π(t, t * )|} and |π(s, p)| + |π(t, q)| < |π(s, s * )| + |π(t, t * )|. This contradicts the optimality of (s * , t * ).
We now show that s * t * contains a vertex of π(s, t). Let s be the vertex on π(s, s * ) preceding s * and let t be the vertex on π(t, t * ) preceding t * . Consider first the case that both s and t lie below the line through . See Figure 2(a). Then ∂P touches s * t * at a vertex v locally from below. Otherwise, (s * , t * ) is not optimal by the same argument as in the previous paragraph. Then s * ∈ xv and t * ∈ vx . The path π(s, t) must cross xv at a point y and vx at a point y . Since y and y are visible to each other, and π(s, t) is a shortest path, π(s, t) contains yy , which in turn contains v. Thus v lies on π(s, t) and s * t * is tangent to π(s, t) at v. Consider now the case that s and t lie on different sides of the line through . Without loss of generality, assume that s lies below the line and t lies above the line. Then s * t * intersects π(s, t). We first show that s * t * contains an edge of π(s, t). Assume to the contrary that s * t * intersects π(s, t) only at a point, say u. Then there is another line segment ⊂ P containing u and intersecting both s * s and t * t . See Figure 2(b). This contradicts that (s * , t * ) is an optimal solution because, for s = ∩ s * s and t = ∩ t * t , d(s, s ) < d(s, s * ) and/or d(t, t ) < d(t, t * ) and s and t are visible to each other. If u coincides with s * or t * , only one of the distance inequalities above holds, we hence consider lexicographic smallest (max,min) solutions in the min-max setting to establish the contradiction. Therefore, s * t * contains an edge of π(s, t), say vv . Moreover, one of v and v touches s * t * from above, and the other touches s * t * from below since s and t are on different sides of . See Figure 2(c). Thus, we can assume that ∂P touches s * v at a vertex v locally from below. Then π(s, t) must cross xv at a point y, and vx at a point y . Since y and y are visible to each other, and π(s, t) is a shortest path, π(s, t) contains yy , which in turn contains both v and v. Thus both v and v lie on π(s, t) and s * t * is tangent to π(s, t) at both v and v.

Computing All Events for a Sweep-Line-Like Approach
In the remaining part of the paper, we use (s * , t * ) to denote the optimal solution pair from s and t to a given line (and not necessarily a global optimal solution for the quickest pair-visibility problem). For each vertex v on π(s, t) we compute a finite collection of lines through v, each being a configuration at which the combinatorial structure of the shortest paths π(s, s * ) and/or π(t, t * ) changes. To be more precise, at these lines either the vertices of π(s, s * ) or π(t, t * ) (except for s * and t * ) change or an edge of ∂P changes that is intersected by the extension of s * t * . To explain how to compute these lines, we introduce the concept of a line-of-sight.
The algorithm we present is in many aspects similar to a sweep-line strategy, except that we do not sweep over the scene in a standard fashion but rotate a line-of-sight in P around the vertices of the shortest path π(s, t) in order from s while making use of Lemma 1. Recall that v 0 , v 1 , . . . , v k−1 , v k is the sequence of vertices on π(s, t) with s = v 0 and t = v k . The process will be initialized with a line-of-sight that contains s and v 1 and is then rotated around v 1 (while remaining tangent to v 1 ) until it hits v 2 , see Figure 3(a). In general, the line-of-sight is rotated around v i in a way so that it remains tangent to π(s, t) at v i (it is rotated in the interior of P ) until the line-of-sight contains v i and v i+1 , then the process is iterated with v i+1 as the new rotation center. The process terminates as soon as the line-of-sight contains v k−1 and v k = t.
While performing these rotations around the shortest path vertices, we encounter all lines-of-sight. As for a standard sweep-line approach, we will compute and consider events at which the structure of a solution changes: this is either because the interior vertices of π(s, s * ) or π(t, t * ) change or because the line-of-sight starts or ends at a different edge of ∂P . These events will be represented by points on ∂P (actually, we consider the events as vertices on ∂P unless they are already vertices). Between two consecutive events, we compute the local minima of the relevant distances for the variant at hand in constant time and hence encounter all local minima eventually.
There are three event-types to distinguish: 1. Path-Events are endpoints of lines-of-sight that contain two consecutive vertices of the shortest path π(s, t). See Figure 3(a). 2. Boundary-Events are endpoints of lines-of-sight that are tangent at a vertex of π(s, t) and contain at least one vertex of P \ π(s, t) (potentially as an endpoint). See Figure 3(b). 3. Bend-Events are endpoints of lines-of-sight where the shortest path from s (or t) to the line-of-sight gains or loses a vertex while rotating the line-of-sight around a vertex v. See Figure 3(c). Note that bend-events can coincide with path-or boundary-events.
We will need to explicitly know both endpoints of the line-of-sight on ∂P at each event and the corresponding vertex of π(s, t) on which we rotate. Lemma 2 (Computing path-and boundary-events). For a simple polygon P with n vertices and points s, t ∈ P , the queue Q of all path-and boundary-events of the rotational sweep process, ordered according to the sequence in which the sweeping line-of-sight encounters them, can be initialized in O(n) time.
Proof. Consider some line-of-sight that is tangent to a vertex v i ∈ π(s, t) for some 0 < i < k. Then subdivides P into a number of subpolygons. Consider as the union of two (sub)segments + and − of induced by v i such that + ∩ − = {v i } and − is incident to the subpolygon of P induced by containing s. We will discuss the computation of all boundary-and path-events swept by + . The other events swept by − can be computed in a second round by changing the roles of s and t. We do not maintain a queue for the events explicitly; instead we will introduce new vertices on ∂P or label existing vertices of ∂P as events.
Later the events will be considered by following two pointers to vertices on ∂P and hence by processing the vertices in the order of their occurrence on ∂P .
We start with computing all path-events swept by + . For this we compute the shortest path map M s of s in P . The shortest path map of s is a decomposition of P in O(n) triangular cells such that the shortest path from s to any point within a cell is combinatorially the same. It can be obtained by extending every edge of the shortest path tree of s towards its descendants until it reaches ∂P in linear time [12]. A path-event occurs when a line-of-sight contains two consecutive vertices of π(s, t). Note that for each path-event, + appears as an edge of M s and its endpoints appear as vertices of M s (see also Figure 4(a)). For each index i with 0 < i < k, we find the edge incident to v i and parallel to v i−1 v i by considering every edge of M s incident to v i . This takes O(n) time in total since there are O(n) edges of M s and we consider every edge at most once. Note that the path-event induced by v k−1 and t is an exception, but it can also be computed in O(1) time during the process by considering the triangle of M s that contains t.
For computing the boundary-events, we use the following properties. While rotating around v i from the position where contains v i−1 to the position in which contains , v i is the predecessor of p on π(s, p)), P4 for all 0 < i < k and all points p ∈ A − i the shortest path π(p, t) contains v i (i.e., v i is the successor of p on π(p, t)).
To compute all boundary-events that are vertices of P swept by + , we will make use of the shortest path tree T s for s in P . A boundary-event x is defined by a vertex v i ∈ π(s, t) such that the line-of-sight that contains x (potentially as one endpoint) is tangent to π(s, t) in v i . It follows from Property P3, that v i x is an edge of T s (and by that it cannot be obstructed by edges of P ) and x / ∈ π(s, t). So the vertices of P whose parent vertex in T s is a vertex of π(s, t) are possible boundary-events. In order to compute all boundaryevents we consider all consecutive path-events and compute all corresponding boundary-events by following Figure 5: Let E + i = xi,1, . . . , xi,j for an index 1 ≤ j ≤ n. We start atxi and follow the (triangular) cells of Mt incident to vi in counter-clockwise order around vi until we findxi,1. Then we continue to follow such cells until we findxi,2, and so on.
∂P and checking the vertices within the candidate set (see Figure 4(b)). We compute the boundary-events that are vertices of P swept by − in a similar way.
So far we have labeled all vertices x on ∂P that are boundary-events. We still need to compute the other endpointx of the line-of-sight xx that is tangent in v i . Let x ixi be the line-of-sight at the path-event Figure 5. While rotating around v i , + sweeps over A + i until the next path-event is met. Let E + i be the sequence of the path-and boundary-events in A + i we obtained so far sorted in counter-clockwise order along ∂P . The order of events in E + i is the same as the order in which + sweeps over them. Our goal is to computex for every event in E + i in order. To do this, we consider the (triangular) cells of the shortest path map M t of t incident to v i one by one in counter-clockwise order around v i starting from the cell incident tox i . Since every point in such cells is visible from v i , we can determine ifx is contained in a cell in constant time for any event x ∈ E + i . Therefore, we can computex for every event x in E + i in time linear in the number of the cells of M t incident to v i and the number of events of E + i , giving us all path-and boundary-events in O(n) total time.
Once we initialized the event queue Q, we can now compute and process bend-events as we proceed in our line-of-sight rotations. Proof. Bend-events occur between consecutive path-and boundary-events; they can also coincide with these events. We assume that all path-and boundary-events are already computed. Additionally, we assume that all vertices of the boundary-and path-events (the endpoints of the corresponding lines-of-sight) are inserted on ∂P . Recall that, for each event, we know both endpoints of the line-of-sight on ∂P and the corresponding vertex of π(s, t) on which we rotate. The path-and boundary-events define the area which is swept over by . Thus, we know which positions for we have to consider in order to compute all bend-events. As in the proof of Lemma 2, we consider the line-of-sight tangent to a vertex v ∈ π(s, t) as the union of two (sub)segments + and − of induced by v such that + ∩ − = {v} and − is incident to the subpolygon of P induced by containing s. We discuss the computation of all bend-events that are encountered by − . The bend-events that are swept over by + can be computed in a second round by changing the roles of s and t.
We start with the path-event defined by s and v 1 , and consider all events in the order they appear. Let be the line-of-sight rotating around a vertex v and denote by x the endpoint of − other than v. To find the bend-events efficiently, we compute and maintain the shortest path π(s, ) = π(s, − ) over the events.
While rotates around v, the combinatorial structure of π(s, ) may change. Specifically, let e = uw denote the edge of π(s, ) incident to with w on . Note that during the rotation of , all the edges of π(s, ) are stationary, except that e rotates around u. Therefore, a change in the combinatorial structure of π(s, ) occurs only when e hits a vertex u of P (if u at this event is an endpoint of e , then this bend-event coincides with a previously computed boundary-event) and splits into two edges sharing u (an event of type T1) or the two edges of π(s, ) incident to u become parallel (an event of type T2). (Then they merge into one and u disappears from π(s, ).) See Figure 6. From any event of the two event types above, e , u, and π(s, ) are updated accordingly. Additionally, x is updated and its new position is inserted as a vertex on ∂P as it represents a bend-event.
Lemma 4. An event of type T1 occurs only when (i) x reaches a vertex u , or (ii) e hits a vertex u of π(s, t) in its interior. Moreover, for case (ii), u and u are consecutive in π(s, t).
Proof. Imagine is rotated around v infinitesimally further from the current event. Then either e is orthogonal to or not. If e is not orthogonal to , the closest point in from s is x. Thus, the only way that e hits a vertex of P is that x reaches u . See Figure 6(a). Now consider the case that e is orthogonal to . Notice that the shortest path from a vertex v to a segment within a simple polygon lies inside a funnel, a region bounded by the shortest paths from v to both endpoints of the segment and the segment. For more details see [12]. Thus, u is contained in π(u, v). See Figure 6(b). Since π(u, v) is a subpath of π(s, t), u is a vertex of π(s, t), and thus u is the vertex of π(s, t) previous to u from s. Lemma 5. Once a vertex disappears from π(s, ), it never appears again on the shortest path during the rotation of the line-of-sight .
Proof. Assume to the contrary that there is a vertex u that disappears from π(s, 1 ), but then appears again on π(s, 2 ) for two distinct lines-of-sight 1 and 2 during the rotation. First note that if u is an endpoint of π(s, 1 ) (or π(s, 2 )), it is a boundary-and bend-event, and would only appear once when rotating the line-of-sight. Therefore, both π(s, 1 ) and π(s, 2 ) must contain u in their interiors, and both of them also contain π(s, u) in their interiors. Since u disappears from π(s, 1 ), the edge of π(s, 1 ) incident to u (on π(u, 1 )) is orthogonal to 1 . We claim that u appears on π(s, 2 ) due to case (ii) of type T1, that is, the edge of π(s, 2 ) incident to 2 hits u. Assume to the contrary that u appears on π(s, 2 ) due to case (i) of type T1. However, u (and its event vertex on ∂P ) is already swept by a line-of-sight before we consider 2 because it appears on π(s, 1 ). By Property P2, − sweeps a vertex only once. Thus, u appears on π(s, 2 ) due to case (ii) of type T1, and the edge of π(s, 2 ) incident to u is orthogonal to 2 . This means that 1 and 2 are parallel.
Since 1 and 2 are parallel, they are tangent to π(s, t) at two distinct vertices, say u 1 and u 2 , respectively. Without loss of generality, assume that u 1 is closer to s than u 2 . We show that π(p 1 , p 2 ) contains u 1 for any two points p 1 ∈ P 1 and p 2 ∈ 2 , where P 1 is the subpolygon bounded by − 1 containing s. Since both u 1 and u 2 are vertices of π(s, t), π(s, u 2 ) contains u 1 . Let p be the point on − 2 farthest from u 2 such that π(s, p) contains u 1 . Since the boundary of P intersect neither u 1 p nor u 2 p, π(u 1 , u 2 ) is contained in the triangle with corners u 1 , u 2 , p. No line segment parallel to 2 is tangent to π(s, t) at u 1 , which is a contradiction. Therefore, π(s, p 2 ) contains u 1 for any point p 2 ∈ 2 . Then since 1 is tangent to π(s, t), π(p 1 , p 2 ) contains u 1 for any two points p 1 ∈ P 1 and p 2 ∈ 2 . Thus, π(s, 2 ) contains π(s, u 1 ), and no vertex in P 1 other than the vertices of π(s, u 1 ) appears on π(s, 2 ). Since u is contained in P 1 , it cannot appear on π(s, 2 ), which is a contradiction.
Using the two lemmas, we can compute all bend-events as follows. For a line-of-sight rotating around a vertex v, we have three candidates for the next bend-event. Let e be the edge of P containing the endpoint of − other than v, and let u be the neighboring vertex of u in π(u, t). The next bend-event is (1) the endpoint of e not contained in π(s, ) if it exists, (2) the intersection point between e and the line through v and orthogonal to uu if it exists, or (3) the intersection point between e and the line through v and orthogonal to u if it exists, where u is the neighboring vertex of u in π(s, ) closer to s. Note that the first two cases are type T1 events and the last case is a type T2 event. We can compute all of the three events in constant time. Also, we can update u, e , x and π(s, ) accordingly in constant time. Therefore, the time for computing all bend-events is linear in the amount of the combinatorial change on π(s, ). By Lemma 5, the the amount of the combinatorial change is O(n), and therefore, we can compute all bend-events in O(n) time.

Algorithm Based on a Sweep-Line-Like Approach
In this section, we present a linear-time algorithm for computing the minimum distance that two points s and t in a simple polygon P travel in order to see each order. We compute all events defined in Section 3 in linear time. The remaining task is to handle the lines-of-sight lying between two consecutive events. Lemma 6. For any two consecutive events, the line-of-sight lying between them that minimizes the sum or the maximum of the distances from s and t to can be found in constant time.
Proof. Let L be the set of all lines-of-sight lying between the two consecutive events. We assume that L contains no vertical line-of-sight. Otherwise, we consider the subset containing all lines-of-sight with positive slopes, and then the subset containing all lines-of-sight with negative slopes.
These lines-of-sight share a common vertex v of π(s, t). We will give an algebraic function for |π(s, )| for ∈ L. An algebraic function for |π(t, )| can be obtained analogously. Observe that π(s, u) is the same for all ∈ L, where u is the second to the last vertex u of π(s, ) from s. Thus, we consider only the length of π(u, ), which is a line segment. The length is either the Euclidean distance between u and the line containing , or the Euclidean distance between u and the endpoint of closest to u. We show how to handle the first case only because the second case can be handled analogously.
Proof. Our algorithm first computes all path-and boundary-events as described in Lemma 2. The number of events introduced during this phase is bounded by the number of vertices of the shortest path maps, M s and M t , respectively, which are O(n). In the next step, it computes the bend-events on ∂P as described in Lemma 3, which can be done in O(n) time. Finally, our algorithm traverses the sequence of events. Between any two consecutive events, it computes the respective local optimum in constant time by Lemma 6. It maintains the smallest one among the local optima computed so far, and returns it once all events are processed. Therefore the running time of the algorithm is O(n).
For the correctness, consider the combinatorial structure of a solution and how it changes. The pathevents ensure that all vertices of π(s, t) are considered as being the vertex lying on the segment connecting the solution (s * , t * ) (Lemma 1). While the line-of-sight rotates around one fixed vertex of π(s, t), either the endpoints of line-of-sight sweep over or become tangent to a vertex of ∂P . These are exactly the boundaryevents. Or the combinatorial structure of π(s, s * ) or π(t, t * ) changes as interior vertices of π(s, s * ) or π(t, t * ) appear or disappear. These happen exactly at bend-events. Therefore, our algorithm returns an optimal point-pair.  Figure 7: Let be a be a line-of-sight which is tangent to π(s, t) at a vertex v. And let be be a line-of-sight that comes after during the rotational sweep process. Clearly, |π(s, )| ≥ |π(s, )|. Corollary 1. By the same algorithm, one can also compute optimal pairs (s * , t * ) that minimize The first modification introduced in Corollary 1 models that Romeo and Juliet travel with different speeds. It is easy to see, that this formulation is equivalent to minimizing the objective max(α|π(s, s * )|, β|π(t, t * )|) for some α, β ∈ R + . The second variant can be motivated as follows: Imagine Romeo (and Juliet) is driving a car that before departing from s (and t) already drove a distance of α (and β). The objective max(α + |π(s, s * )|, β + |π(t, t * )|) minimizes the largest distance any of the two cars had to drive in order to establish a line-of-sight.

Quickest Pair-Visibility Query Problem
In this section, we consider a query version of the min-max variant of the quickest pair-visibility problem: Preprocess a simple n-gon P so that the minimum traveling distance for two query points s and t to see each other can be computed efficiently. We can preprocess a simple n-gon in linear time and answer a query in O(log 2 n) time by combining the approach in Section 4 with the data structure given by Guibas and Hershberger [13,14]. For any two query points s and t in P , the query algorithm for their data structure returns π(s, t), represented as a binary tree of height O(log n), in O(log n) time [14]. Thus, we can apply a binary search on the vertices (or the edges) on π(s, t) efficiently.
Imagine that we rotate a line-of-sight along the vertices of π(s, t) for two query points s and t in P . Lemma 1 implies that there is a line-of-sight containing s * and t * , where (s * , t * ) is an optimal solution. We call it an optimal line-of-sight. We define the order of any two lines-of-sight as the order in which they appear during this rotational sweep process. By the following lemma, we can apply a binary search on the sequence of events along ∂P and find two consecutive events such that the respective local optimum achieved between them is a global optimal solution. Lemma 7. The geodesic distance between s (and t) and the rotating line-of-sight increases (and decreases) monotonically as the line-of-sight rotates along the vertices of π(s, t) from s.
Proof. Let be a line-of-sight that is tangent to π(s, t) at a vertex v. Consider the subdivision of P induced by and let P s be the subpolygon that contains s. Let be a line-of-sight that comes after during the rotational sweep process. We claim that does not intersect the interior of P s . If is tangent to π(s, t) at v, it never intersects the interior of P s as shown in the proof of Lemma 2. Assume that is tangent to π(s, t) at a vertex u that comes after v along π(s, t) from s, but intersects the interior of P s . Without loss of generality, assume that is horizontal and P s lies locally below . Then u must lie strictly above the line containing . However, since both v and u are vertices of π(s, t) and is tangent to π(s, t) at v, there must be another vertex u of π(s, t) that lies on or below the line containing and appears between v and u along π(s, t). See Figure 7.
Thus, u is not visible from any point on , and does not intersect the interior of P s . Since π(s, ) intersects , we have |π(s, )| ≥ |π(s, )|. The claim for t and the rotating line-of-sight can be shown analogously.

Binary Search for the Path-Events
We first consider the path-events, and find two consecutive path-events containing an optimal line-of-sight between them. Let v 0 , v 1 , . . . , v k−1 , v k be the sequence of vertices on π(s, t) with s = v 0 and t = v k . Due to the shortest-path data structure by Guibas and Hershberger, we can obtain π(s, t) represented as a binary tree of height O(log n) in O(log n) time. Consider an edge v i v i+1 of π(s, t). We can determine whether or not an optimal line-of-sight is tangent to π(s, t) at a vertex lying after v i along π(s, t) in O(log n) time.
To do this, we compute the line-of-sight containing v i v i+1 in O(log n) time. We use the data structure for ray shooting given by Hershberger and Suri [15] with linear preprocessing and logarithmic query time. Then, we compute the length of π(s, ) and π(t, ) in O(log n) time using the data structure given by Guibas and Hershberger for computing the distance between a query point and a query line segment in O(log n) time [13]. An optimal line-of-sight is tangent to π(s, t) at a vertex lying after v i if and only if π(s, ) is shorter than π(t, ). Therefore, we can compute the two consecutive path-events with an optimal solution lying between them in O(log 2 n) time.

Binary Search for the Boundary-Events
Now we have the vertex v i of π(s, t) contained in an optimal line-of-sight. We find two consecutive boundaryevents defined by lines-of-sight tangent to π(s, t) at v i such that an optimal line-of-sight lies between them. Letx i and x i be the first points of ∂P hit by the rays from any point in v i−1 v i towards v i−1 and v i , respectively. See Figure 5. Similarly, letx i+1 and x i+1 be the first points of ∂P hit by the rays from any point in v i v i+1 towards v i and v i+1 , respectively. These four points of ∂P can be found in O(log n) time by the ray-shooting data structure [15]. Without loss of generality, we assume that a line-of-sight rotates around v i in the counter-clockwise direction in the rotational sweep process. Letγ be the part of ∂P lying betweenx i andx i+1 in counter-clockwise order, and γ be the part of ∂P lying between x i and x i+1 in counter-clockwise order. An optimal line-of-sight * has one endpoint onγ and the other endpoint on γ.
We first find the edge ofγ (resp. γ) containing an endpoint of * by applying a binary search on the vertices ofγ (resp. γ). This gives two consecutive boundary-events such that * lies between them. We now show how to find the edge of γ containing an endpoint of * . The edge onγ can be found analogously.
We perform a binary search on the vertices in γ as follows. Let x * be the endpoint of * contained in γ. For any vertex u of γ, we can determine which part of γ with respect to u contains x * in O(log n) time. To do this, we consider the line-of-sight containing the edge of π(v i , u) incident to v i . Observe that intersects π(v i , u) only in the edge including its endpoints as π(v i , u) is a shortest path. See Figure 8(a). Since we can obtain the edge of π(v i , u) incident to v i in O(log n) time using the shortest-path data structure, we can obtain in the same time. Here, to obtain the endpoint of on γ, we use the ray-shooting data structure that supports O(log n) query time [15]. Then we compare |π(s, )| and |π(t, )| in O(log n) time. The point x * comes after u from x i if and only if |π(s, )| < |π(t, )|. Therefore, we can determine which part of γ with respect to u contains x * in O(log n) time, and thus the binary search is completed in O(log 2 n) time. In this way, we can compute two consecutive boundary-events such that an optimal line-of-sight lies between them in O(log 2 n) time.

Binary Search for the Bend-Events
Now we have two consecutive events in the sequence of all path-and boundary-events that contain an optimal line-of-sight * between them. Let 1 and 2 be two lines-of-sight corresponding to the two consecutive events such that 2 comes after 1 . The remaining task is to handle the bend-events lying between them. For the bend-events, we perform a binary search on the edges of π(s, 1 )∪π(s, 2 ) in O(log 2 n) time. Then we perform a binary search on the edges of π(t, 1 ) ∪ π(t, 2 ) in O(log 2 n) time. In the following, we describe the binary search on π(s, 1 ) ∪ π(s, 2 ). The other one can be done analogously.
We find the point s such that π(s, s ) is the maximal common subpath of π(s, 1 ) and π(s, 2 ) from s in O(log n) time using the shortest-path data structure [14]. See Figure 8(b). Then we obtain π = π(s , 1 ) ∪ π(s , 2 ) represented as a binary tree of height O(log n) in O(log n) time. Notice that π is a path from 1 to 2 , concatenating the two shortest paths from 1 to s and from s to 2 .
For an edge e of π , we use (e) to denote the line-of-sight containing v i and orthogonal to the line containing e. Observe that (e) comes after (e ) if and only if e comes after e along π from 1 (because  Figure 8: (a) The line-of-sight intersecting π(v i , u) contains the edge of π(v i , u) incident to v i . (b) The maximal common subpath of π(s, 1 ) and π(s, 2 ) from s is π(s, s ); π = π(s , 1 ) ∪ π(s , 2 ) (blue). the order of the edges of π , as they appear on the path, are radially sorted around v i ). Also, given an edge e of π , we can compute (e) in constant time. Using these properties, we can find two consecutive edges e and e of π such that * lies between (e) and (e ) in O(log 2 n) time by applying a binary search on π as we did for path-and boundary-events. Now we have two consecutive events in the sequence of all path-, boundary-and bend-events that contain * between them. Recall that the combinatorial structure of π(s, ) (and π(t, )) is the same for every line-ofsight lying between the two events. Let (u s , w s ) and (u t , w t ) be the edges of π(s, ) and π(t, ) incident to at w s and w t , respectively, for any line-of-sight lying between the two events. Using the shortest-path data structure, we can obtain u s , u t , |π(s, u s )| and |π(t, u t )| in O(log n) time. Then we apply the algorithm in Lemma 6 to find an optimal line-of-sight in constant time. In this way, we can obtain an optimal line-of-sight in O(log 2 n) time in total. Therefore, we can find two consecutive events with an optimal solution between them, and we can obtain an optimal solution in O(log 2 n) time in total.
Theorem 2. Given a simple n-gon P , we can preprocess it in O(n) time to find the minimum of the longer distance that s and t travel in order to see each other in P can be computed in O(log 2 n) time for any two query points s, t ∈ P .

Conclusions and Open Problems
We have presented a linear time algorithm that solves two variants of the quickest pair-visibility problem for a simple polygon: either we want to minimize the maximum length of a traveled path or we want to minimize the sum of the lengths of both traveled paths.
Additionally, we have considered a query version of the quickest-visibility problem for the min-max variant. We can preprocess a simple n-gon in linear time so that the minimum of the longer distance the two query points travel can be computed in O(log 2 n) time for any two query points.
We conclude this paper with some interesting open problems.
1. Is there a way to extend our algorithm to more than two query points? More precisely, given k points in a simple polygon, compute the minimum distance that these points must travel in order to see each other (at the same moment).
2. Find an efficient algorithm for the query version of the quickest-visibility problem for the min-sum problem.