Quickest Visibility Queries in Polygonal Domains
Haitao Wang

TL;DR
This paper introduces efficient data structures for quickest visibility and shortest-path-to-segment queries in polygonal domains with holes, improving query times and sizes especially when the number of holes is small.
Contribution
The authors develop new data structures that significantly improve query efficiency for visibility and shortest-path problems in polygonal domains with few holes, matching optimal results in simple cases.
Findings
New data structure of size O(n log h + h^2) for visibility queries
Query time of O(h log h log n) for visibility, better for small h
Optimal data structure for shortest-path-to-segment queries when h=O(1)
Abstract
Let be a point in a polygonal domain of holes and vertices. We consider a quickest visibility query problem. Given a query point in , the goal is to find a shortest path in to move from to see as quickly as possible. Previously, Arkin et al. (SoCG 2015) built a data structure of size that can answer each query in time, where is the inverse Ackermann function and is the size of the visibility polygon of in (and can be in the worst case). In this paper, we present a new data structure of size that can answer each query in time. Our result improves the previous work when is relatively small. In particular, if is a constant, then our result even matches the best result for the simple…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsComputational Geometry and Mesh Generation · Robotic Path Planning Algorithms · Robotics and Sensor-Based Localization
11institutetext: Department of Computer Science
Utah State University, Logan, UT 84322, USA
11email: [email protected]
Quickest Visibility Queries in Polygonal Domains
Haitao Wang
Abstract
Let be a point in a polygonal domain of holes and vertices. We consider a quickest visibility query problem. Given a query point in , the goal is to find a shortest path in to move from to see as quickly as possible. Previously, Arkin et al. (SoCG 2015) built a data structure of size that can answer each query in time, where is the inverse Ackermann function and is the size of the visibility polygon of in (and can be in the worst case). In this paper, we present a new data structure of size that can answer each query in time. Our result improves the previous work when is relatively small. In particular, if is a constant, then our result even matches the best result for the simple polygon case (i.e., ), which is optimal. As a by-product, we also have a new algorithm for a shortest-path-to-segment query problem. Given a query line segment in , the query seeks a shortest path from to all points of . Previously, Arkin et al. gave a data structure of size that can answer each query in time, and another data structure of size with query time. We present a data structure of size with query time , which also favors small values of and is optimal when .
1 Introduction
Let be a polygonal domain with holes and a total of vertices, i.e., there is an outer simple polygon containing pairwise disjoint holes and each hole itself is a simple polygon. If , then becomes a simple polygon. For any two points and in , a shortest path from to is a path in connecting and with the minimum Euclidean length. Two points and are visible to each other if the line segment is in . For any point in , its visibility polygon consists of all points of visible to , denoted by \mbox{V!i!s}(q).
We consider the following quickest visibility query problem. Let be a source point in . Given any point in , the query asks for a path to move from to see as quickly as possible. Such a “quickest path” is actually a shortest path from to any point of \mbox{V!i!s}(q). The problem has been recently studied by Arkin et al. [1], who built a data structure of size that can answer each query in time, where is the size of \mbox{V!i!s}(q). In this paper, we present a new data structure of size with query time. Our result improves the previous work when is relatively small. Interesting is that the query time is independent of , which can be in the worst case. Our result is also interesting in that when , the data structure has size and query time, which even matches the best result for the simple polygon case [1] and is optimal.
As in [1], in order to solve the quickest visibility queries, we also solve a shortest-path-to-segment query problem (or segment query for short), which may have independent interest. Given any line segment in , the segment query asks for a shortest path from to all points of . Arkin et al. [1] gave a data structure of size that can answer each query in time, and another data structure of size with query time. We present a new data structure of size with query time. Our result again favors small values of and attains optimality when , which also matches the best result for the simple polygon case [1, 13].
Given the shortest path map of , our quickest visibility query data structure can be built in time and our segment query data structure can be built in time. Arkin et al.’s quickest visibility query data structure and their first segment query data structure can both be built in time, and their second segment query data structure can be built in time [1].
Throughout the paper, whenever we talk about a query related to paths in , the query time always refers to the time for computing the path length, and to output the actual path, it needs additional time linear in the number of edges of the path by standard techniques (we will omit the details about this).
1.1 Related Work
The traditional shortest path query problem has been studied extensively, which is to compute a shortest path to move from to “reach” a query point. Each shortest path query can be answered in time by using the shortest path map of , denoted by \mbox{S!P!M}(s), which is of size. To build \mbox{S!P!M}(s), Mitchell [28] gave an algorithm of time for any and space, and later Hershberger and Suri [22] presented an algorithm of time and space. If is a simple polygon (i.e., ), \mbox{S!P!M}(s) can be built in time, e.g., see [17].
For the quickest visibility queries, Arkin et al. [1] also built a “quickest visibility map” of size in time, which can answer each query in time. In addition, Arkin et al. [1] gave a conditional lower bound on the problem by showing that the 3SUM problem on numbers can be solved in time, where is the preprocessing time and is the query time. Therefore, a data structure of preprocessing time and query time would lead to an time algorithm for 3SUM.
In the simple polygon case (i.e., ), better results are possible for both the quickest visibility queries and the segment queries. For the quickest visibility queries, Khosravi and Ghodsi [24] first proposed a data structure of size that can answer each query in time. Arkin et al. [1] gave an improved result and they built a data structure of size in time, with query time. For the segment queries, Arkin et al. [1] built a data structure of size in time, with query time. Chiang and Tamassia [13] achieved the same result for the segment queries and they also gave some more general results (e.g., when the query is a convex polygon).
Similar in spirit to the “point-to-segment” shortest path problem, Cheung and Daescu [12] considered a “point-to-face” shortest path problem in 3D and approximation algorithms were given for the problem.
1.2 Our Techniques
We first propose a decomposition of by shortest paths from to certain vertices of \mbox{S!P!M}(s). The decomposition , whose size is , has cells with the following three key properties. First, any segment in can intersect at most cells of . Second, for each cell of , consists of at most two sub-segments of . Third, after time preprocessing, for each sub-segment of in any cell of , the shortest path from to can be computed in time. With , we can easily answer each segment query in time by a “pedestrian” algorithm.
To solve the quickest visibility queries, an observation is that the shortest path from to see is a shortest path from to a window of \mbox{V!i!s}(q), i.e., an extension of the segment for some reflex vertex of . Hence, the query can be answered by calling segment queries on all windows of \mbox{V!i!s}(s) and returning the shortest path. This leads to the time query algorithm in [1].
If we follow the same algorithmic scheme and using our new segment query algorithm, then we would obtain an algorithm of time for the quickest visibility queries. We instead present a “smarter” algorithm. We propose a “pruning algorithm” that prunes some “unnecessary” portions of the windows such that it suffices to consider the remaining parts of the windows. Further, with the help of the decomposition , we show that a shortest path from to the remaining windows can be found in time. We refer to it as the preliminary result. To achieve this result, we solve many other problems, which may be of independent interest. For example, we build a data structure of size such that given any query point and line segment in , we can compute in time the intersection between and the shortest path from to in (or report none if they do not intersect). Our above pruning algorithm is based on a new and interesting technique of using “bundles”.
To further reduce the query time to , the key idea is that by using the extended corridor structure of [8, 11], we show that there exists a set of candidate windows such that a shortest path from to see the query point must be a shortest path from to a window in . This is actually quite consistent with the result in the simple polygon case, where only one window is needed for answering each quickest visibility query [1]. Once the set is computed, we can apply our pruning algorithm discussed above on to answer the quickest visibility query in additional time. To compute , we give an algorithm of time, without having to explicitly compute \mbox{V!i!s}(s). The algorithm is based on a modification of the algorithm given in [9] that can compute \mbox{V!i!s}(q) in time for any point , after space and time preprocessing.
The rest of the paper is organized as follows. In Section 2, we introduce notation and review some concepts. In Section 3, we introduce the decomposition of , and present our algorithm for the segment queries. We present our preliminary result for the quickest visibility queries in Section 4 and give the improved result in Section 5. Section 6 concludes the paper.
2 Preliminaries
For any subset of , we say that a point is (weakly) visible to if is visible to at least one point of . For any point , we use to denote a shortest path from to in , and in the case where the shortest path is not unique, may refer to an arbitrary such path. With a little abuse of notation, for any subset of , we use to denote a shortest path from to all points of ; we use to denote the length of , i.e., .
Let denote the set of all vertices of .
The shortest path map \mbox{S!P!M}(s).
\mbox{S!P!M}(s) is a decomposition of into regions (or cells) such that in each cell , the sequence of obstacle vertices along is fixed for all in [22, 28]. Further, the root of , denoted by , is the last vertex of in for any point (hence ; note that is if is visible to ). We classify each edge of a cell into three types: a portion of an edge of , an extension segment, which is a line segment extended from along the opposite direction from to the vertex of preceding , and a bisector curve/edge that is a hyperbolic arc. For each point on a bisector edge of \mbox{S!P!M}(s), is on the common boundary of two cells and there are two different shortest paths from to through the roots of the two cells, respectively. The vertices of \mbox{S!P!M}(s) include and all intersections of edges of \mbox{S!P!M}(s). The intersection of two bisector edges is called a triple point, which has more than two shortest paths from . The map \mbox{S!P!M}(s) has vertices, edges, and cells [22, 28].
For differentiation, we call the vertices and edges of the polygonal domain the obstacle vertices and the obstacle edges, respectively. The holes and the outer polygon of are also called obstacles.
The shortest path tree \mbox{S!P!T}(s) is the union of shortest paths from to all obstacle vertices of . \mbox{S!P!T}(s) has edges [22, 28]. Given \mbox{S!P!M}(s), \mbox{S!P!T}(s) can be obtained in linear time. We somethings consider a further decomposition of \mbox{S!P!M}(s) by having all edges of \mbox{S!P!T}(s) in it.
For ease of exposition, we make a general position assumption that no obstacle vertex has more than one shortest path from and no point of has more than three shortest paths from . Hence, no bisector edge of \mbox{S!P!M}(s) intersects an obstacle vertex and no three bisector edges intersect at the same point.
For any polygon , we use to denote the number of vertices of and use to denote the boundary of .
Ray-shooting queries in simple polygons.
Let be a simple polygon. With time and space preprocessing, each ray-shooting query in (i.e., given a ray in , find the first point on hit by the ray) can be answered in time [6, 21]. The result can be extended to curved simple polygons or splinegons [26].
The canonical lists and cycles of planar trees.
We will often talk about certain planar trees in (e.g., \mbox{S!P!T}(s)). Consider a tree with root . A leaf is called a base leaf if it is the leftmost leaf of a subtree rooted at a child of (e.g., see Fig. 1). Denote by the post-order traversal list of starting from such a base leaf , and we call it a canonical list of . The root must be the last node in . We remove from and make the remaining list a cycle by connecting its rear to its front, and let denote the circular list. Although may have multiple base leaves, is unique and we call the canonical cycle of .
We further use (e.g., see Fig. 1) to denote the list of the leaves of following their relative order in and use to denote the circular list of . One reason we introduce these notation is the following. Let be any edge of . All nodes of whose paths to in contain must be consecutive in and . Similarly, all leaves of whose paths to in contain must be consecutive in and .
The following observation on shortest paths will be frequently referred to in the paper.
Observation 1
Suppose and are two shortest paths from to two points in , respectively; then and do not cross each other. 2. 2.
Suppose is a shortest path from to a point in and is a line segment in ; then the intersection of and is a sub-segment of (which may be a single point or empty).
3 The Decomposition and the Segment Queries
In this section, we introduce a decomposition of and use it to solve the segment query problem. The decomposition will also be useful for solving the quickest visibility queries.
We first define a set of points. Let be an intersection between a bisector edge of \mbox{S!P!M}(s) and an obstacle edge. Since is on a bisector edge, it is in two cells of \mbox{S!P!M}(s) and has two shortest paths from . We make two copies of in the way that each copy belongs to only one cell (and thus corresponds to only one shortest path from ). We add the two copies of to . We do this for all intersections between bisector edges and obstacle edges. Consider a triple point , which is in three cells of \mbox{S!P!M}(s) and has three shortest paths from . Similarly, we make three copies of that belong to the three cells, respectively. We add the three copies of to . We do this for all triple points. This finishes the definition of .
By definition, each point of has exactly one shortest path from . Let denote the set of shortest paths from to all points of . Let be the union of all shortest paths of . We consider points of distinct although some of them are copies of the same physical point. In this way, we can consider as a “physical” tree rooted at .
Definition 1
Define to be the decomposition of by the edges of .
In the following, we assume the shortest path map \mbox{S!P!M}(s) has already been computed. We have the following lemma about the decomposition .
Lemma 1
The size of the set is . 2. 2.
The combinatorial size of is . 3. 3.
Each cell of is simply connected. 4. 4.
For any segment in , can intersect at most cells of . Further, for each cell of , the intersection and consists of at most two (maximal) sub-segments of . 5. 5.
After time preprocessing, for any segment in a cell of , the shortest path from to can be computed in time, where is the combinatorial size of . 6. 6.
For each cell of , has at most two vertices and (both in ), called “super-roots”, such that for any point , is the concatenation of and the shortest path from to in , for a super-root in . 7. 7.
Given the shortest path map \mbox{S!P!M}(s), can be computed in time.
We will prove Lemma 1 later in Section 3.2. Below we first give our data structure for answering segment queries by using Lemma 1.
3.1 The Segment Queries
As preprocessing, we first compute the decomposition . Then, we build a point location data structure on [14, 25], which can be done in time and space since the size of is by Lemma 1(2); the data structure can answer each point location query in time.
In addition, for each cell of , by Lemma 1(3), is a simple polygon; we build a ray-shooting data structure on [6, 21]. Since the total size of all cells of is by Lemma 1(2), the total preprocessing time and space for the ray-shooting queries on all cells of is .
Finally, we do the preprocessing in Lemma 1(5). Hence, given \mbox{S!P!M}(s), the total preprocessing time and space is . The following lemma gives our query algorithm.
Lemma 2
Given any segment in , we can compute a shortest path from to in time.
Proof
Let and be the two endpoints of , respectively. Our algorithm works in a “pedestrian” way, as follows.
By using a point location query, we find the cell of that contains . Then, we check whether is contained in . This can be done by using a ray-shooting query as follows. We shoot a ray from towards and compute the first point of hit by the ray. The segment is in if and only if is before on the ray.
If is in , then we can immediately compute the shortest path from to in time by Lemma 1(5).
Otherwise, we compute the shortest path from to the sub-segment of in time by Lemma 1(5). Next, based on the edge of containing , we can determine in constant time the next cell of that the ray enters. We process the cell in the similar way as the above for . The algorithm finishes once we process a cell that contains .
The above computes for multiple sub-segments of such that these sub-segments constitute exactly and each sub-segment is in a single cell of . Clearly, among all shortest paths from to these sub-segments, the one with the minimum length is the shortest path from to .
To analyze the running time of the above algorithm, let be the number of the above sub-segments of . Suppose are these sub-segments ordered from to . For each , let be the cell of that contains . First of all, the point location query for takes time. For each , determining each sub-segment needs a ray-shooting query in , which takes time; computing the length of also takes time by Lemma 1(5). Hence, the total time of the algorithm is .
By Lemma 1(4), . Also, by Lemma 1(4), each cell may contain two of the above sub-segments of , and thus it is possible that and refer to the same cell for . Let be the set of the distinct cells of for . Since each cell contains at most two of the above sub-segments of , . Further, since the cells of are distinct, we have . Due to , we have .
Therefore, the total time of the algorithm is bounded by . ∎
We summarize our result for segment queries in the following theorem.
Theorem 3.1
Given the shortest path map \mbox{S!P!M}(s), we can build a data structure of size in time, such that each segment query can be answered in time.
3.2 The Decomposition and Proving
Lemma 1
In this section we provide the details for and prove Lemma 1.
Let denote the obstacle space, which is the complement of the free space of . More specifically, consists of the simple polygonal holes of and the (unbounded) region outside the outer boundary of . Let denote the union of all bisector edges of \mbox{S!P!M}(s). Mitchell [27] proved that is simply connected and is also simply connected (e.g., see Fig. 2). We consider as a planar graph , defined as follows.
The vertex set of consists of all obstacles of and all triple points of \mbox{S!P!M}(s). For any two vertices of , if they are connected by a chain of bisector edges in \mbox{S!P!M}(s) such that the chain does not contain any other vertex of , then has an edge connecting the two vertices, and further, we call the above chain of bisector edges a bisector super-curve (e.g., in Fig. 2, each red curve is a bisector super-curve). We have the following observation about .
Observation 2
* is a simple graph, i.e., does not have a self-loop and no two vertices have more than one edge. has vertices, edges, and faces.*
Proof
The first part of the observation can be proved easily from Mitchell’s observation in [27] that is simply connected, as follows.
Indeed, assume to the contrary that has a self-loop at a vertex . According to our definition, the self-loop corresponds to a bisector super-curve that connects the vertex (either a triple point or an obstacle) to itself. Let be region bounded by bisector-super curve and . Hence, is closed, which contradicts with that is simply connected.
Similarly, assume to the contrary that two vertices and have two edges. Then, the two edges correspond to two bisector super-curves. Thus, the region bounded by the two bisector super-curves and the two vertices is closed, incurring contradiction again.
To prove the second part of the observation, note that is a planar graph.
First, it is known that the number of triple points is [15]. Since there are obstacles in , the number of vertices of is .
Second, the faces of correspond exactly to the faces of the (\leq 1)-\mbox{S!P!M} of defined in [15], whose total number is proved to be [15] (see Lemma 4.3 with ). Therefore, the number of faces of is .
Finally, since both the number of vertices and the number of faces of are , the number of edges of is also . ∎
Let be the set of all triple points. It is known that [15]. Let be the set of intersections between obstacle edges and bisector edges of \mbox{S!P!M}(s). It is not difficult to see that each point of corresponds to an intersection between an obstacle and a bisector super-curve. Since has edges, there are bisector super-curves. Thus, . Recall that consists of three copies of each point of and two copies of each vertex of . Since both and are , we have . This proves Lemma 1(1).
Since , is the set of shortest paths. Note that each edge of any path of except the last edge (i.e., the one connecting a point of ) is an edge of the shortest path tree \mbox{S!P!T}(s). Hence, the total number of edges of the tree is . Since is the decomposition of by the edges of , the combinatorial size of is . This proves Lemma 1(2).
Throughout the paper, let . Hence, .
To prove the rest of Lemma 1, we introduce another decomposition as follows.
Definition 2
Define to be the decomposition of by the edges of .
By definition, can be obtained from by removing all bisector edges of .
Lemma 3
Each cell of is simply connected.
Proof
Let be the decomposition of by the edges of . Note that is exactly , which is simply connected [27].
Let the points of be , ordered arbitrarily. Consider the decomposition of by the shortest path . Note that may have more than one connected cell. Recall that is on a bisector edge of . Since is simply connected, does not cross any bisector edges of \mbox{S!P!M}(s), and itself does not form any cycle, each cell of is simply connected.
Similarly, consider the decomposition of by the shortest path . Again, does not cross any bisector edge of . Further, by Observation 1(1), and do not cross each other. Hence, does not cross any edge of . Since each cell of is simply connected, each cell of is also simply connected.
We keep considering the rest of the paths for one by one in the same way as above. By the similar argument we can obtain that each cell of , which is , is simply connected. ∎
It is known that is simply connected and is in for any point [27]. To simplify the discussion, together with the copies of the points of , we consider as a simple polygon (with some curved edges) by making two copies for each interior point of every bisector super-curve such that they respectively belong to the two sides of the curve. In this way, for any point , it has a unique shortest path from in , which is also a shortest path in . In this way, becomes a decomposition of by the tree .
Consider any cell of . Recall that is the set of all vertices of . We consider the points of on the boundary of as vertices of . Then, the boundary portion between any two adjacent vertices of is an obstacle edge, an edge of , or a bisector super-curve. Let be any point of . Let be the point of closest to . We call the super-root of , which is unique (i.e., independent of ) due to the following lemma.
Lemma 4
The point is in , i.e., it is either or an obstacle vertex. 2. 2.
* is a sub-path of a shortest path in .* 3. 3.
For any point , the concatenation of and the shortest path from to in is the shortest path from to in .
Proof
We prove the lemma by induction in a similar way as in Lemma 3. We use the same terminology as in the proof of Lemma 3. Let the points of be , ordered arbitrarily. Let . For each , let denote the decomposition of by . We let . For each , let . Hence, .
Initially, consider the decomposition . Note that there is only one cell in . Clearly, and all three statements hold for and . We assume the lemma statements hold for and . Our goal is to prove that the lemma statements hold for and .
Let be the cell of containing . By induction, is the concatenation of and the shortest path from to in . Also by induction, is a sub-path of . Hence, does not partition any cell of other than . In other words, for any cell of , if , then is still in , and thus the lemma statements still hold on and .
For the cell , partitions into multiple sub-cells. Consider any sub-cell of . Our goal is to show that the lemma statements hold on and . Depending on whether contains , there are two cases.
The case .
We first consider the case where contains . Consider any point in . Since , , and the point of closest to is , the point of closest to is also . Hence, . By induction, the first and second statements of the lemma hold for and .
For the third statement, consider any point . Since , is a concatenation of and , and the latter path is in . To prove the third statement, it sufficient to show that is in . Indeed, assume to the contrary that is not in . Then, since is a cell of the decomposition of by , must cross . However, this is not possible due to Observation 1(1). Hence, must be in .
The case .
Suppose does not contain . Let be the point of closest to . We first show that for any point , is the point of closest to .
Indeed, since , contains and is in . Since is not in , let be the first point in we encounter if we traverse on from to . Clearly, is not since otherwise would be in . Since is a cell of the decomposition of by , must be on . In other words, .
Since is on both and , is also the first point in we encounter if we traverse on from to . Thus, is the point of closest to . Hence, we obtain .
On the other hand, the definition of implies that is the point of closest to .
Therefore, is the point of closest to . This implies that .
Note that is a vertex of and cannot be . Thus, must be either or an obstacle vertex (in fact, cannot be either due to ), which proves the first statement of the lemma.
Since is on and thus is on , is a sub-path of . This proves the second statement of the lemma.
For the third statement, consider any point . Since , by induction, is the concatenation of and , and is in . Using the same analysis as above, we can show that must contain . Further, the portion of between and must be in , since otherwise would cross , incurring contradiction. Hence, the portion of between and is the shortest path from to in . Thus, is the concatenation of and the shortest path from to in . This proves the third statement.
This proves that all lemma statements hold for and , and thus hold for and .
The lemma thus follows. ∎
Observation 3
Each cell of has at most one bisector super-curve on its boundary.
Proof
Assume to the contrary there are two bisector super-curves on the boundary of . Then, there must exist an endpoint of one of these two bisector super-curves such that the shortest path partitions into two cells that contain the two bisector super-curves, respectively. This implies that is not in . Since the two endpoints of every bisector super-curve are in , we obtain and is not in , a contradiction. ∎
Since is a planar tree, we can define its canonical lists as discussed in Section 2. Let be an arbitrary base leaf of , which can be found in time. Let the leaf list be , which follow the counterclockwise order along .
For each , let denote the portion of counterclockwise from to (let refer to ). Note that is either a bisector super-curve or a chain of obstacle edges. Suppose we move a point on from to . The shortest path will continuously change with the same topology since is always in (which is simply connected). Let be the region of that is “swept” by during the above movement of . More specifically, let be the common point on that is farthest to . Then, is bounded by , , and . For convenience of discussion, we let also contain the common sub-path and we call the tail of . We call the region bounded by , , and the cell of . We consider , , and as the three portions of the boundary of . The definition implies that for any point in , is in . In fact, if is in the cell of , then is the concatenation of and the shortest path from to in the cell. Clearly, is the union of . Let . The next lemma is proved with the help of the regions of . The set will also be quite useful in Section 4. Recall that each edge of is either an obstacle edge, a bisector super-curve, or an edge of (also called a shortest path edge).
Lemma 5
For each cell of , there are two shortest paths of that contain all shortest path edges of .
Proof
By the definitions of the regions of , is contained in the cell of a region of . Therefore, each shortest path edge of belongs to either or . ∎
Observe that the decomposition can be obtain from by removing all bisector super-curves. For any bisector super-curve , the two cells of incident to are merged into one cell of . Due to Observation 3, a cell of can be merged into at most one cell of . Therefore, for each cell of , either is also in or is a merged cell merged by exactly two cells of . Since every cell of is simply connected, each cell of is also simply connected. This proves Lemma 1(3).
Consider any line segment . By Observation 1(2), can cross any shortest path of at most once. Hence, can cross the shortest paths of at most times in total. Whenever crosses the boundary of a cell of , it must cross a shortest path of . Thus, can intersect cells of . This proves the first part of Lemma 1(4). For the second part, consider any cell . By Lemma 5, if is not a merged cell, then can cross the boundary of at most twice; otherwise, can cross the boundary of at most four times. Therefore, the intersection consists of at most two (maximal) sub-segments of . This proves the second part of Lemma 1(4).
In the sequel, we prove Lemma 1(5). Consider any cell of . According to our discussion above, is either in or a merged cell of two cells and of . If it is the former case, then we also call the super-root of ; otherwise, we call and the two super-roots of . Lemma 4 leads to the following lemma, which proves Lemma 1(6).
Lemma 6
For any cell of , the following hold.
Its two super-roots are in . 2. 2.
For each super-root of , is a sub-path of a shortest path in . 3. 3.
For any point , is the concatenation of and the shortest path from to in , for a super-root of .
Proof
By Lemma 4, the proof is straightforward because either is a cell of or a merge of two cells of . ∎
Recall that for any simple polygon and a fixed source point, each segment query can be answered in time after time preprocessing [1]. As preprocessing, for each cell of , since it is a simple polygon, we compute the above segment query data structure with respect to each super-root of . This takes time and space in total by Lemma 1(2).
Consider any segment in a cell of . By Lemma 6, is the concatenation of from to a super-root of and the shortest path from to in . As is in by Lemma 6(1), is available from \mbox{S!P!M}(s), and can be found in time. Hence, our query algorithm works as follows. For each super-root of , we compute and to obtain a “candidate” shortest path from to . Then, we return the shorter one of the at most two candidates paths as the solution. The total time is . This proves Lemma 1(5).
Remark.
One may wonder why we do not use instead of to answer the segment queries. The reason is that the boundaries of cells of contain bisector super-curves and the query segment may intersect a bisector super-curve multiple times, and thus a similar observation as Lemma 1(4) cannot be guaranteed on .
Finally, we prove Lemma 1(7) in the following lemma.
Lemma 7
Given \mbox{S!P!M}(s), the decomposition can be computed in time.
Proof
Let be the decomposition of \mbox{S!P!M}(s) by the edges of \mbox{S!P!T}(s). As discussed before, we can easily obtain \mbox{S!P!T}(s) from \mbox{S!P!M}(s) and thus obtain in time. Further, for each point , we add to the last edge of the shortest path , which is also the edge connecting to the root of the cell of \mbox{S!P!M}(s) containing . Let be the resulting decomposition, which can be obtained in time. Note that each edge of is also an edge of .
Since is a decomposition of by the edges of , can be obtained from by removing those edges that are not in . To this end, we first remove all bisector edges from . Then, we remove the edges of \mbox{S!P!T}(s) that are not in . This can be done by first marking all edges of in and then removing all unmarked edges of \mbox{S!P!T}(s) from . Below we only discuss how to mark all edges of in time since the latter step is trivial.
For each vertex of , we mark the edges of in as follows. We start from and traverse along from to , marking every edge that has not been marked yet; we stop the traversal either when we encounter or we encounter an edge that has been marked. In this way, every edge of is marked exactly once. Since has edges, the above marking algorithm runs in time.
Thus, the decomposition can be computed in time. ∎
4 The Quickest Visibility Queries: The Preliminary Result
In this section, we give our preliminary result on quickest visibility queries, which sets the stage for our improved result in Section 5.
For any subset of , a point is called a closest point of (with respect to ) if .
Given any query point in , our goal is to find a shortest path from to \mbox{V!i!s}(q). Let be a closest point of \mbox{V!i!s}(q). To answer the query, it is sufficient to determine . Thus we will focus on finding . Note that if is visible to , then . We can determine whether is visible to in time by checking whether is in the cell of \mbox{S!P!M}(s) whose root is . In the following, we assume is not visible to .
We define the windows of and \mbox{V!i!s}(q), which were used for studying the visibility polygons, e.g., [5, 10]. Consider an obstacle vertex that is visible to such that the two incident obstacle edges of are on the same side of the line through and (e.g., see Fig. 3). Let denote the first point on hit by the ray from along the direction from to . Then is called a window of ; we say that the window is defined by . Further, we call the extended window of .
Each window of is an edge of \mbox{V!i!s}(q), and thus the number of windows of is , where K=|\mbox{V!i!s}(q)|. Further, there must be a closest point that is on a window of [1]. Hence, as in [1], a straightforward algorithm to compute is to compute shortest paths from to all windows of and the path of minimum length determines . To compute shortest paths from to all windows, if we apply our segment queries on all windows using Theorem 3.1, then the total time would be . In the rest of this section, we present an algorithm that can compute in time, without having to compute shortest paths to all windows. The key idea is to prune some (portions of) windows such that is still in the remaining windows and the shortest paths from to all remaining windows can be computed efficiently.
4.1 The Algorithm Overview
As the first step, we compute \mbox{V!i!s}(q), which can be done in time after time and space preprocessing [9]. Then, we can find all windows and extended-windows in time. For ease of exposition, we make a general position assumption for that is not collinear with any two obstacle vertices. The assumption implies that is in the interior of and no two windows are collinear.
Let be the root of the cell of \mbox{S!P!M}(s) containing (if is on the boundary of multiple cells, then we take an arbitrary such cell). Hence, is a shortest path from to . Note that must define a window of [27]. Let be all windows of ordered clockwise around . Clearly, . For each , let .
Note that the window is special in the sense that is in . So we first apply our algorithm in Theorem 3.1 on to compute the closest point of . Clearly, if , then . In the following, we assume . Let . Note that does not contain but . If , then we can find by computing for all , which can be done in time using \mbox{S!P!M}(s). In the following, we assume . Note that the above assumption that is only for arguing the correctness of our following algorithm, which actually proceeds without knowing whether the assumption is true or not.
For each , let , i.e., the extended window of . Let . For convenience of discussion, we assume that each of does not contain its two endpoints and (but the endpoints of still refer to and ). Since , must be on an extended window of . Clearly, is also a closest point of . Since no two windows of are collinear, no extended-window of contains another. We assign each window a direction from to , so that we can talk about its left or right side.
Suppose is on . Since is an open segment, by the definition of , the shortest path must reach from either the left side or the right side of . Formally, we say that reaches from the left side (resp., right side) of if there is a small neighborhood of such that all points of in the neighborhood are on the left side (resp., right side) of . Let (resp., ) denote the set of points on whose shortest path from to is from the left (resp., right) side of . Hence, is either on or on .
Our algorithm will find two points and such that if is on for some , then , and otherwise (i.e., is in for some ), .
In the following, we will only present our algorithm for finding since the case for is symmetric. In the following discussion, we assume is on for some . Note that this assumption is only for arguing the correctness of our algorithm, which actually proceeds without knowing whether the assumption is true.
The rest of this section is organized as follows. In Section 4.2, we discuss some observations, based on which we describe our pruning algorithm in Section 4.3 to prune some (portions of) segments of such that () is still in the remaining segments of . In Section 4.5, we will finally compute (which will be ) on the remaining segments of . Some implementation details of the algorithm are given in Sections 4.4 and 4.6. Section 4.7 summarizes the overall algorithm.
As will be clear later, our algorithm uses extended windows instead of windows because extended windows can help us with the pruning.
4.2 Observations
For any point with , and its shortest path , we use to denote a point on infinitely close to (but ). If is on for some , then must be on the left side of .
For any segment of , we say that or a sub-segment of can be pruned if it does not contain . Our pruning algorithm, albeit somewhat involved, is based on the following simple observation.
Observation 4
For any point for some , if intersects any segment or an endpoint of it, then can be pruned (i.e., cannot be ).
Proof
Let be a point on that is a point on any segment or an endpoint of it. Clearly, t^{\prime}\in\mbox{V!i!s}(s) and . Thus, cannot be . ∎
Consider the shortest paths for . To simplify the notation, let for each . In particular, let (not ). Recall that . The union of all paths for forms a planar tree, denoted by , with root at . Consider the canonical cycle as defined in Section 2. Let be the circular list of the points of following their relative order in . We further break into a list at , such that starts from and all other points of follow the counterclockwise order in . Assume is , i.e., the -th point of the list is ; e.g., see Fig. 4. So essentially maps each point of from its position in to its position in the list . Hence, is a permutation of , and if . The reason we introduce the list is that intuitively, for any , the path is counterclockwise from with respect to around . For convenience, we let .
Later in Section 4.6 we will give the implementation details for the following lemma.
Lemma 8
Given \mbox{S!P!M}(s), after time preprocessing, we can compute the list and thus determine the map in time.
Observation 5
For any , does not contain and does not contain .
Proof
Assume to the contrary that contains for some . Since is in , by Observation 1(2), . Recall that . This implies that either contains or contains , which further implies the two windows and are collinear. This incurs contradiction since no two windows are collinear. Hence, does not contain .
Assume to the contrary that contains . Then, since both and are in , by Observation 1(2), is in . Hence, . Recall that is the root of the cell of \mbox{S!P!M}(s) containing , and . Since is in the interior of , and must be collinear since otherwise there would be a shorter path from to without containing . Recall that . Since and are collinear, the three points , , and are collinear. But this contradicts with our general position assumption that is not collinear with any two obstacle vertices. ∎
Lemma 9
Suppose contains with and . If , then can be pruned; otherwise, can be pruned.
Proof
We first discuss the case . Consider the region bounded by the closed curve that is the union of , , and the subpath of between and (e.g., see Fig. 5(a)). By Observation 1(1), does not cross . Since , is clockwise from with respect to (which is the last edge of ). Hence, must be locally on the left side of .
Consider any point . We show that cannot be . Recall that is an open segment, so is not or . Since , the point must be in . By the definition of , is not in the interior of . Hence, must intersect the boundary of . Since cannot cross the subpath of between and , must intersect , , or a point of . By Observation 4, cannot be .
The above shows that cannot be . Thus, can be pruned.
For the case , the argument is similar (e.g., see Fig. 5(b)). Since , must be locally on the left side of . For any point , using the similar argument as above, we can show that cannot be . Thus, can be pruned. ∎
Lemma 10 provides an algorithm to remove all extended-windows of that can be pruned by Lemma 9.
Lemma 10
Given \mbox{S!P!M}(s) and with time preprocessing, we can find in time all segments of that can be pruned by Lemma 9.
Proof
The task is to determine those indices and such that is contained in for in , after which we can determine whether or should be pruned by Lemma 9. Recall that is a permutation of the indices of . Therefore, equivalently we can determine those indices and such that is contained in for in . We actually do not need to explicitly find all such pairs, as shown below.
A key observation is that if is contained in a path with , then it must be that and is contained in for any . Indeed, if is contained in a path with , then the subpath of from to is . According to the definition of the map , i.e., the list , must be after in the list, i.e., . Further, for any , is in the path of the tree from to the root , which is the shortest path .
Based on the above observation, our algorithm works as follows. We consider the points in the order of . Suppose we are about to process . The algorithm maintains a stack of indices in in increasing order (from bottom to top of ) such that for each , if , then has been pruned. Initially we set before we process . In general, our algorithm processes for any as follows.
If , then we push on top of and proceed to process . Otherwise, we first check whether is contained in , where is the top index on .
If , then is not in any path with by the above observation. We push on top of and then proceed on processing . 2. 2.
If , then depending on whether , there are two cases.
- (a)
If , then by Lemma 9, we prune and pop from . Then, we repeat the same algorithm as above (i.e., first check whether , and if not, check whether is contained in , where is the new top index of ). 2. (b)
If , then by Lemma 9, we prune and proceed on processing .
The algorithm finishes once has been processed. It is not difficult to see that if we can check whether is in in time, then the algorithm runs in time since each index of can be pushed or popped from at most once. In the following, we show that after time preprocessing, and this will prove the lemma.
First of all, if both and are in the same cell of \mbox{S!P!M}(s), then if and only if , where is the root of . Otherwise, if is not in any edge of the shortest path tree \mbox{S!P!T}(s), then cannot be in . Otherwise, suppose is on an edge of \mbox{S!P!T}(s). We can find the edge in time by a point location query on the decomposition of \mbox{S!P!M}(s) by the edges of \mbox{S!P!T}(s). Let be an endpoint of , and thus is a node of \mbox{S!P!T}(s). Let be the root of the cell of \mbox{S!P!M}(s) containing . Then, is in if and only if is an ancestor of in \mbox{S!P!T}(s). Note that is an ancestor of if and only if the lowest common ancestor of and is . We can build a data structure on \mbox{S!P!T}(s) in time such that given any two nodes of the tree, the lowest common ancestor can be found in constant time [3, 18].
Hence, we can determine whether in time after time preprocessing.
The lemma thus follows. ∎
We apply the algorithm in Lemma 10 to prune the segments of . But to simplify the notation, we assume that none of the segments of is pruned since otherwise we could re-index all segments of . So now has the following property.
Observation 6
For any , is not contained in any with and .
Proof
Suppose to the contrary that is contained in for some and . On the one hand, due to Observation 5, . On the other hand, if , then by Lemma 9 either or would have already been removed from . ∎
For each , since does not cross , forms a closed curve that separates the plane into two regions, one locally on the left of and the other locally on the right . We let denote the region locally on the left side of including as its boundary (it is possible that is unbounded). If is a sub-path including at least one edge, then it is also considered to be in . We have the following observation for .
Observation 7
If , then must be in .
Proof
Let that is on . Then, is in the interior of . By Observation 4, cannot intersect . Also, cannot cross either or , and is on the boundary of . Hence, must be inside . Thus, is in . ∎
Our pruning algorithm mainly relies on the following lemma, whose proof in turn boils down to Observation 4.
Lemma 11
Suppose and are two indices with .
If , then does not cross and does not cross , and further, is contained in (e.g., see Fig. 6(a)). 2. 2.
If , then either crosses or crosses . Further, in the former case (e.g., see Fig. 6(b)), can be pruned, and in the latter case (e.g., see Fig. 6(c)), the sub-segment of can be pruned, where is the point at which crosses .
Proof
Suppose . We first show that cannot be in the interior of the region .
Assume to the contrary that is in the interior of . Let be a point on arbitrarily close to (but ). Since , is clockwise from with respect to . Since is not in by Observation 5, is not in . Since is in the interior of , must cross at a point with (e.g., see Fig. 7).
Depending on whether , there are two cases.
If , then since , we obtain by Observation 1(2). Since is in the interior of , we further obtain that is counterclockwise from with respect to . Thus, we have , a contradiction. 2. 2.
If , then since and is counterclockwise from with respect to , must cross an interior point of before reaching . This implies that by Observation 1(2), and thus, contains since . Hence, we again obtain contradiction.
This proves that cannot be in the interior of the region .
By Observations 5 and 6, cannot be in or . Since no segment of contains another, cannot be in . Hence, cannot be on the boundary of . Therefore, is outside . Next we show that does not cross .
Indeed, since both and are outside , in order for to cross , must cross at least twice, which is not possible by Observation 1(2). Similarly, in order for to cross , it would have to cross at least twice, which is not possible.
This proves that does not cross and does not cross . Since is clockwise from and does not cross , is contained in . Further, since is counterclockwise from and does not cross , must be contained in .
This proves the first part of the lemma.
For the second part of the lemma, we assume . By the same analysis as above, cannot be on the boundary of . Depending on whether is in the interior of or outside it, there are two cases.
If is outside , then since , is counterclockwise from with respect to . Further, since and do not cross each other and does not contain (by Observation 5), must cross . Let be the point of where crosses. Let be the open region bounded by , , and the subpath of between and .
Consider any point on (if any). The point must be in the interior of . Clearly, is not in . Hence, must cross the boundary of . Since cannot cross , it must cross either or . By Observation 4, can be pruned. Thus, can be pruned. 2. 2.
If is in the interior of , let be a point on infinitely close to . Since , by the same analysis as before, is not in . Since is in the interior of , must intersect the boundary of at a point . Since does not intersect or , is on . This proves that crosses .
Consider the region bounded by , , and the subpath of between and .
Consider any point on . By the similar argument as above, we can show that can be pruned. Thus, can be pruned.
The lemma thus follows. ∎
For any , we say and are consistent if . By Lemma 11, if and are not consistent, then we can do some pruning, based on which we present our pruning algorithm in Section 4.3. Figure 8 gives an example showing the remaining parts of the segments of after the pruning algorithm.
4.3 A Pruning Algorithm for Pruning the Segments of
We process the paths in this order. Assume that has just been processed and we are about to process . Our algorithm maintains a sequence of bundles, denoted by . Each bundle is defined recursively as follows. Essentially is a list of sorted indices of a subset of , but the indices are grouped in a special and systematic way.
There are two types of bundles: atomic and composite. If has only one index, then it is an atomic bundle. Otherwise, is a composite bundle consisting of a sequence of at least two bundles (with ) such that the last bundle must be atomic (others can be either atomic or composite), and we call the index contained in the wrap index of . We consider the bundles as the children bundles of .
Let and denote the smallest and largest of all indices of , respectively. If is composite, then further has the following three bundle-properties. (1) The indices of are distinct and sorted increasingly by their order in . (2) For any , . (3) If is the wrap index of , then and crosses for every (intuitively, “wraps” the point , and this is why we call a “wrap” index). Refer to Fig. 9 for an example.
For convenience, if the context is clear, we also consider a bundle as a set of sorted indices. So if an index is in , we can write “”.
Remark.
We use the word “bundle” because each index of refers to the shortest path . Therefore, is a “bundle” of shortest paths.
In addition, the bundle sequence maintained by our algorithm has the following two -properties. (1) The indices in all bundles are distinct in and are sorted increasingly by their order in the sequence. (2) For any , .
Observation 8
For any and any indices and (both and are from ), the two shortest paths and are consistent (e.g., see Fig. 9). 2. 2.
For any composite bundle , for any and any indices and , the two shortest paths and are consistent (e.g., see Fig. 9).
Proof
We only prove the first part since the second part is similar.
Since , it holds that . Clearly, and . Since , we have . Therefore, we obtain . Thus, and are consistent. ∎
In the following, we discuss our algorithm for processing the shortest path , during which will be updated. Initially when , we simply set to contain the only atomic bundle and this finishes our processing for . In general when , we do the following.
We first find the index such that . Later in Section 4.4 we will give a data structure to maintain the bundle sequence such that can be found in time.
If (so does not exist in this case), then we add a new atomic bundle to the rear of and we are done with processing . Note that the two -properties are maintained.
Otherwise, we check whether . We have the following lemma.
Lemma 12
If , then the extended-window can be pruned.
Proof
Assume that . Since , we have , which also implies that is a composite bundle. Let be the wrap index of . Due to , it follows that . Since every index of is smaller than , . By Lemma 11, does not cross .
Consider the index with . Hence, . By the third bundle-property, crosses , say, at a point (e.g., see Fig. 10). Consider the region bounded by , , and the subpath of between and . Since and , must be in since otherwise would cross , contradicting with Lemma 11(1). Also, by Observation 6, is not on . Therefore, is in the interior of . This implies that the shortest path from to any point of must intersect , , or their endpoints. Therefore, no point of can be . Thus, can be pruned. ∎
By Lemma 12, if , we simply ignore and finish the processing of .
In the following, we assume (note that is not possible since ). Next, we are going to find all such indices of that crosses . To this end, the following two lemmas are crucial.
Lemma 13
For any index in for any , does not cross . 2. 2.
For any index in for any , if crosses , then can be pruned; otherwise, must cross . 3. 3.
If is in for some and crosses , then crosses for any and any . 4. 4.
If is in for some and does not cross , then does not cross for any and any .
Proof
We prove the four parts of the lemma separately.
If is in a bundle of . Note that . Since and , we obtain . Consequently, by Lemma 11(1), does not cross . 2. 2.
If is in a bundle of , then . Since , according to Lemma 11(2), either crosses or crosses . If crosses , by Lemma 11(2), can be pruned. Otherwise, must cross . 3. 3.
Let and be the indices as in the lemma statement. Our goal is to show that crosses .
Clearly, and . By Lemma 11(1), is contained in (e.g., see Fig. 11). Since and , if we move from to along , we will enter the interior of both and . If we keep moving, note that we cannot encounter any point in either or . Since crosses , if we move as above on , we will encounter a point on , which is part of the boundary of . Since is contained in , the above moving will also encounter a point on (e.g., see Fig. 11). Due to Observation 6, cannot be . Hence, must cross at . 4. 4.
This part is equivalent to the above third part.
∎
For any bundle in , if has two indices and such that crosses but does not cross , then we say that is a mixed bundle, which is necessarily a composite bundle.
Lemma 14
For any mixed bundle , the following holds.
The path must cross , where is the wrap index of , i.e., . 2. 2.
If an index is in for some and crosses , then crosses for any and any . 3. 3.
If an index is in for some and does not cross , then does not cross for any and any . 4. 4.
If a bundle of has two indices and such that crosses but does not cross , then we also say that is a mixed bundle. This lemma applies to recursively.
Proof
Suppose is an index of such that crosses . If , then we are done with the proof. In the following, we assume . Hence, .
Assume to the contrary that does not cross . Since is the wrap index, crosses , say, at a point (e.g., see Fig. 12(a)). Consider the region bounded by , , and the subpath of between and , such that is on the right side of the directed segment from to . Since and crosses but does not cross , must be in the region . Since and , if we go from to along , we will get out of by crossing , after which we get into the interior of the region since cannot cross (e.g., see Fig. 12(b)). If we keep moving towards along , before reaching we will need to get out of the interior of through again. However, due to Observation 1(2), since already crosses somewhere on , it cannot intersect again. Thus, we obtain contradiction. 2. 2.
This part follows the similar proof as the third part of Lemma 10 and we omit the details. 3. 3.
This part is equivalent to the second part of the lemma. 4. 4.
Using the same analysis, we can prove that the same lemma applies to recursively.
∎
In light of the preceding two lemmas, in the following we will find the indices of such that crosses and then prune by Lemma 13(2) (i.e., remove from ); we say that such an index is prunable.
Before describing our algorithm, we first discuss an operation that will be used in the algorithm. Consider a composite bundle of . Let be a wrap index of , i.e., . Suppose crosses . Our algorithm will remove from and thus from . This is done by a wrap-index-removal operation. Further, suppose is the -th bundle of , i.e., . After is removed, the operation will implicitly insert the bundles into the position of in the bundle list , i.e., after the operation, becomes . Note that this new bundle list still has the two -properties. Indeed, and . Later in Section 4.4 we will give a data structure to maintain the bundles of so that each wrap-index-removal operation can be implemented in time.
Another operation that is often used in the algorithm is the following. Given any , we want to determine whether crosses . We call it the shortest path segment intersection (or SP-segment-intersection) query. Later in Section 4.6 we will present an algorithm that can answer each such query in time, after time and space preprocessing.
We are ready to describe our algorithm for removing all prunable indices from . By Lemma 13(1), each bundle of for does not contain any prunable index. For each bundle of in order, we call a procedure prune() until the procedure returns “false”.
If all indices of are prunable, then prune() will return “true” and the entire bundle will be removed from . Otherwise, the procedure will return false. Further, if is a mixed bundle, then all prunable indices of will be removed (and the procedure returns false).
The procedure works as follows (see Algorithm 1 for the pseudocode). It is a recursive procedure, which is not surprising since the bundles are defined recursively. As a base case, if is an atomic bundle , then we call an SP-segment-intersection query to check whether crosses . If yes, we remove the bundle and return true; otherwise, we return false. If is a composite bundle with as the wrap index (i.e., ), then we first call an SP-segment-intersection to check whether crosses . If not, by Lemma 14(1), does not have any prunable index and thus we simply return false. If yes, then we call a wrap-index-removal operation to remove . Afterwards, for each in order, we call recursively. If returns false, then we return false (without calling ). If it returns true, we remove (in fact all children bundles of have been removed by ). If , then we return true (since all children bundles of have been removed); otherwise, we proceed on calling .
If prune() returns true for every with , then we add a new atomic bundle at the end of , which now becomes . This also finishes our preprocessing for . Otherwise, prune() returns false for some with . In this case, as a final step, we create a new composite bundle , consisting of all bundles of after (not including ) and the atomic bundle as the last child bundle of . This is done by a bundle-creation operation. We will show in Section 4.4 that this operation can be implemented in time. Afterwards, the new bundle sequence becomes . The following lemma shows that the new bundle is a “valid” composite bundle and the updated maintains the two -properties.
Lemma 15
The new bundle has the three bundle properties and the updated has the two -properties.
Proof
Let , where . We show that has the three properties of composite bundles as follows.
Indeed, recall that every index of the original is smaller than . Note that although some indices have been removed from , we never change any relative order of two indices of . Further, is the last index of . Therefore, the indices of are sorted increasingly by their order in . Hence, has the first property. 2. 2.
To show the second property, again the bundles , which are from the original , never change their relative orders. By the recursive definition of bundles, it holds that for any . Thus, the second property also holds on . 3. 3.
For the third property, recall that . Since each with is a “descendent” bundle of (we consider a descendent bundle of itself) for some , it holds that . Since , . Therefore, . Further, for each , since is not prunable (otherwise would have already been pruned), does not cross (by Lemma 13(2)). By Lemma 13(2), must cross . Hence, the third property holds on .
To see that the updated bundle sequence maintains the two -properties, by using the similar analysis as above, the first property holds. For the second property, we have proved above that . Further, recall that . Therefore, we obtain . Consequently, the second property also holds on . ∎
To analyze the running time of the above algorithm, let be the number of indices that have been removed from . Then, the algorithm makes at most SP-segment-intersection queries. To see this, once the query discovers an index that is not prunable, the algorithm will stop without making any more such queries. On the other hand, each wrap-index-removal operation removes an index, and thus the number of such operations is at most . Further, observe that for each bundle , whenever we make a recursive call on a child bundle of , the wrap index of is guaranteed to be removed. Therefore, the number of total recursive calls is at most as well. Hence, the running time of the algorithm is .
This finishes our algorithm for processing the path . The total time for processing is . Since once an index is removed from , it will never be inserted into again, the sum of all such in the entire algorithm for processing all paths for is at most . Hence, the total time of the entire algorithm is .
Again, Fig. 8 gives an example showing the remaining parts of the segments of after the pruning algorithm.
4.4 The Data Structure for Maintaining the Bundles
In this section, we give a data structure for maintaining the bundle sequence such that our algorithm runs in the time as claimed above. In particular, we show that during our algorithm for processing each of the following operations can be performed in () time: inserting a new bundle at the end of , the bundle-creation operation, the wrap-index-removal operation, and finding the index .
We first present our data structure and then discuss the operations.
4.4.1 The Data Structure
Let . It is not difficult to see that the bundles of naturally form a tree structure. So we use a bundle tree to represent it, as follows. The tree has a root , whose children from left to right are exactly the bundles in this order. For each such bundle , if is atomic, then is a leaf of and the index of is stored at the leaf. Otherwise, suppose . Then, we store the wrap index of at the node and has children from left to right corresponding to in this order. If one of these bundles is composite, then its subtree is defined recursively. Refer to Fig. 13 for an example.
For each node of , let denote the subtree rooted at . It is easy to see that if is a leaf, then represents an atomic bundle; otherwise, represents a composite bundle. Each node of the tree except the root stores an index. Further, the post-order traversal of each subtree gives exactly the sequence of indices in the bundle represented by .
We implement the bundle tree as follows. In general, consider any internal node . We let have two pointers and pointing to the leftmost and rightmost children of , respectively. In this way, from , we can access its leftmost and rightmost children in time. All children of are organized by a doubly linked list: Each child of maintains a left (resp., right) pointer pointing to its left (resp. right) sibling, so that we can remove a node in constant time; the left (resp., right) pointer of the leftmost (resp., rightmost) child is empty. In this way, from the leftmost child of , we can visit all children of in order from left to right in linear time.
In order to compute the index in time, we use another balanced binary search tree to maintain the ranges of the bundles of . The tree has leaves corresponding to the bundles of from left to right. For each leave , let denote the bundle of corresponding to ; we associate with the range . By the second property of , the ranges of the leaves from left to right are sorted by either the minimum values or the maximum values of the ranges. Clearly, the height of is . In addition, each leave is associated with a cross pointer pointing to the node of corresponding to the bundle , so that once we have the access to in we can locate in in constant time. Finally, each internal node of maintains the minimum range value of the leftmost leave in the subtree of rooted at , which is used for searching.
This completes our data structure for maintaining the bundles of , which consists of two trees and . In the following, we show how to use our data structure to implement the operations on needed in our algorithm for processing .
4.4.2 Performing Operations
First of all, finding the index can be easily done in time by searching the tree . Further, by using the cross pointer, we can immediately access the node of whose subtree represents .
If , then our algorithm adds at the end of . To implement it, we first insert to as the rightmost leaf with the range , which can be done in time. Then, we add the atomic bundle to the rear of by adding a leaf to as the rightmost child of the root . The tree can be updated in constant time with the help of the rear pointer of .
If , then we check whether (note that we can find the leaf for in in time). If , then we are done for processing . In the following, we assume .
Our algorithm first calls the procedure . To implement it, note that is represented by the subtree , where is the right sibling of . Since we already have the access to , by using the right pointer of , we can access in constant time. The procedure begins with checking whether is atomic, which can be done in constant time by checking whether is a leaf.
If yes, then the procedure stops after an SP-segment-intersection query. Further, if needs to be removed, then we simply remove the leaf , which can be done in constant time (recall that the children of any node of are organized by a doubly linked list). Further, we also remove the corresponding leaf from in time.
If is not atomic, let . We can obtain the wrap index of in constant time since it stored at the node . To implement wrap-index-removal operation, essentially, we need to replace the node by its children. This can be done in constant time by using the left, right, front, and rear pointers of . Depending on whether is the leftmost or rightmost child of , we may also need to update the front or rear pointer of , which can also be easily done in constant time. We omit these details.
Next, our algorithm calls the procedure . We can access the node of whose subtree represents in constant time after the above wrap-index-removal operation (i.e., by following the front pointer of ). The algorithm then works recursively. Note that now becomes a bundle of . Hence, the above algorithm description on applies to recursively.
The algorithm stops when either we are at the end of or the procedure returns false for a bundle in the current . In the former case, we add to the rear of the current list in the same way as before. In the latter case, we preform a bundle creation operation by creating a composite bundle including all bundles of the current after as well as in the rear of . We implement this bundle creation operation as follows.
Note that we have the access of the node whose subtree represents after returns false. Let be the rightmost child of , which can be accessed in constant time from the root . Next, in constant time, we construct a subtree representing the bundle and use to replace the subtrees of from to (e.g., see Fig. 14), as follows. First, we create a new node storing the single index . Second, we set the front pointer of to and set the rear pointer of to . Third, if has a left sibling, denoted by , then we set the left pointer of to and set the right pointer of to ; otherwise, we set the front pointer of to . Fourth, we set the rear pointer of to . Fifth, we set the left pointer of to empty.
Finally we update the tree as follows. Recall that the algorithm stops when either we are at the end of or returns false for a bundle in the current . In the former case, we let , and in the latter case, we let denote the new bundle created by the bundle creation procedure. In either case, we update as as follows. Note that the original is and the updated is . Essentially, the bundles have been replaced by . So we first remove the leaves corresponding to the bundles from . Since they are consecutive in , the remove can be done in time. Next, we insert into as the rightmost leave. In the former case (i.e., ), . In the latter case, and , which can be obtained in time from the original . Hence, in either case the total time for updating is . In addition, we set the cross pointer of the new leaf to the node of whose subtree represents , which is done in constant time since we have the access of after is updated (e.g., is in the case of Fig. 14).
4.5 Computing the Closest Point
Recall that we have assumed that is on for some , i.e., . According to our pruning algorithm for computing the bundle sequence , the point must be on for some index . In this section, we will compute by using the bundle sequence . For example, in Fig 8, our goal is to compute on the left sides of those (red) thick segments.
Recall that we have defined in Section 3.2 that is the region of bounded by , , and , where is either a bisector super-curve whose endpoints are and or a chain of obstacle edges. Also recall that consists of a tail and a cell.
Let be any segment in such that contains . With the help of the decomposition proposed in Section 3, we propose a region-processing algorithm to compute in the following lemma.
Lemma 16
Suppose is a segment of such that contains and is known. Then can be computed in time, after time and space preprocessing.
Proof
We first present our region-processing algorithm for computing , and then argue its correctness. Finally, we will analyze the running time of the algorithm.
The algorithm.
For each of , , and , we check whether it crosses . Note that this step is not necessary for if is a chain of obstacle edges since cannot cross any obstacle edge. By Observation 1(2), intersect (resp., ) at most once.
To avoid the tedious case analysis, by Observation 1(2), we assume that if intersects or , then the intersection is a single point (i.e., not a general sub-segment of ). Let (resp., ) be the intersection between and (resp., ); if there is no intersection, we simply let (resp., ) refer to . In general, if is a bisector super-curve, may intersect multiple times, and we let be an arbitrary such intersection; similarly, if there is no intersection let refer to .
If and , then is a point on the tail of . By Observation 1(2), can only intersect the tail once. By the definition of , for any point in the cell of , . This implies that is . So we can finish the algorithm in this case.
Otherwise (i.e., or ), if at least one element of is not , then for each point of and , we do the following. Observe that is not on the tail of . By the definition of the decomposition , regardless of whether is on , , or , there is a cell of such that contains and is in . By Lemma 1(4), consists of at most two maximal sub-segments and . Since is a simple polygon, we can build a ray-shooting data structure on each of the inside and the outside of . Then, we can compute and in time by using ray-shooting queries. Next, we compute and in time by Lemma 1(5). In this way, we obtain at most six candidate paths (for the at most three non-empty points of ) and return the shortest one as .
The remaining case is when every element of is , i.e., does not cross any of the three parts of . In this case, is contained in a single cell of . We can determine by locating the cell of that contains an arbitrary endpoint of . Then, we compute by Lemma 1(5).
The correctness.
Recall that contains . Let a closest point of (i.e., ). Thus, contains . If is on the tail of , then our algorithm correctly computes as discussed above. Otherwise, if is in , then must be in a single cell of . Clearly, our algorithm correctly computes in this case. If is not in , then since contains , must cross the boundary of . Suppose we move from along until we cross the boundary of at a point . Let be the cell of that is in and contains . Be definition, also contains . If is on (resp., ), then since intersects (resp., ) at a single point, our algorithm correctly computes . If is on , then all intersections between and are in since is contained in . Hence, our algorithm also correctly computes .
The time analysis.
The algorithm needs at most six calls of Lemma 1(5), which take time. It also has at most two SP-segment-intersection queries for computing the intersections of with and . Again, we will show that each such query can be answered in time with time and space preprocessing.
In addition, if is a bisector super-curve, our algorithm also needs to compute an intersection between and . This can be done in time after linear time preprocessing on using the ray-shooting data structure on curved simple polygons or splinegons [26] (indeed, each bisector edge of is convex, and thus it is straightforward to make a splinegon [26], e.g., by the standard technique as detailed in the proof of Lemma 20). Thus, the total preprocessing time on all such curves for is .
Also, we have mentioned before that we need a constant number of ray-shooting queries on the cells to determine the at most two sub-segments of . The query time is and the total preprocessing time on all cells of is .
Hence, our region-processing algorithm runs in time, and the total preprocessing time and space is . ∎
Recall that . Due to our general position assumption that is not collinear with any two obstacle vertices, none of is an obstacle vertex. Then, for each , there is a unique region of whose cell contains , such that the shortest path is contained in , and we let refer to the index of . Computing can be done in time by point location queries on the cells of the regions of .
For any two indices and in , if , then let denote the set of all integers ; otherwise, let denote the set of all integers . Recall that the regions are counterclockwise around . We actually use to refer to the set of indices of the regions of from to counterclockwise around .
Next we compute on for , by using our region-processing algorithm in Lemma 16. Consider the bundles of . For each with , we call a procedure , where is the last index of if and otherwise. Note that given the access of , we can obtain in constant time by using our data structure in Section 4.4. Also note that for any index . The procedure works as follows.
Depending on whether is atomic or composite, there are two cases.
The atomic case.
If is atomic, let be the only index of . According to the bundle-properties, and . So and are consistent. By Lemma 11(1), is contained in . Let be minus the interior of . We have the following observation.
Observation 9
If is on , then must be in (e.g., see Fig. 15).
Proof
Suppose is on . Let . By definition, the point is in the interior of . Since , does not intersect any point of or and it does not contain either. Also, cannot cross either or . Hence, must be in . ∎
Observation 9 leads to the following lemma.
Lemma 17
If is on , then is in for some index , and further, any shortest path from to is .
Proof
Suppose is on . Since is also a closest point of , must be .
Note that must be contained in a region of . By Observation 9, is in . Hence, is counterclockwise from with respect to around . Since is in , and is in , there is a region that contains such that is counterclockwise from with respect to around , which implies that . ∎
For each , we apply our region-processing algorithm on and to obtain a path, and we keep the shortest path among all such paths; let be the endpoint of on . According to Lemma 17, if is on , then must be .
For the purpose of analyzing the total running time of our algorithm, as will be seen later, for each with and , the region-processing algorithm will not be called on again in the entire algorithm for computing . On the other hand, we charge the two algorithm calls on for and to the index of . In this way, the total number of calls to the region-processing procedure in the entire algorithm is since the total number of indices of is at most and the total number of regions is .
The composite case.
If is composite, the algorithm is more complicated. Let be the wrap index of . Observation 9 and Lemma 17 still hold on . However, since now the region also contains a portion of for each and (e.g., see Fig. 16), may also contain the shortest path from to . In order to avoid calling the region-processing procedure on the same region of too many times, we use the following approach to process .
For any two different indices of and in a range of indices of the regions of , we say that is ccw-larger than if is a subset of (e.g., if , then ).
Define to be the ccw-largest index in such that crosses (if no such index exists, then let ). We first compute (to be discussed later). Then, we call the region-processing procedure on for all and return the shortest path that is found; let be the endpoint of on . By the following lemma, if is on , then is .
Lemma 18
If is on , then is in for some index , and further, any shortest path from to is .
Proof
By Lemma 17, the lemma statement holds for some . In the following we show that is in .
Assume to the contrary that is not in . Then, is ccw-larger than and does not cross . This implies that and are in . Since , is counterclockwise from with respect to . This implies that . But implies that . Thus, we have . Since , we obtain . But this contradicts with that is not in .
The lemma thus follows. ∎
The following lemma makes sure that when we process for any other index of with , we do not need to consider the regions for if .
Lemma 19
Suppose . If is on for some and , then is in for some .
Proof
Consider any such as in the lemma statement. Since is the wrap index of , crosses at a point (e.g., see Fig. 17). By Lemma 11(2), the portion of can be pruned, i.e., cannot be on . Let be the region bounded by , , and the subpath of between and . Note that .
Since , must be in . We claim that is in (e.g., see Fig. 17). To see this, is one of the two sub-regions of partitioned by . Since is not on , must be in the interior of , which is in . Hence, to prove that is in , it is sufficient to show that does not cross either or . Indeed, does not cross . On the other hand, does not intersect since otherwise would not be a closest point of \mbox{V!i!s}(q). This shows that is in .
Since , is ccw-larger than . By the definition of , crosses , say, at a point (e.g., see Fig. 17). Hence, the region contains a shortest path from to . Further, since , is also in . Since both and are on the boundary of , partitions into two sub-regions and one of them, denoted by , contains . Since does not cross , is in , which implies that must be in some region with .
This proves the lemma. ∎
In order to compute the index , we will use a -region range query. Namely, given the index range as well as , the query can be used to compute . In Section 4.6 we will give a data structure that can answer each such query in time (after time and space preprocessing).
After is processed as above, is computed. By Lemma 19, to process for other indices of , we only need to consider the indices of the regions of after . Let be the bundles in other than the last one. For each , if , we call recursively; otherwise, we call recursively, where is the last index of .
Remark.
For the procedure , the above algorithm still works by replacing by . To argue the correctness, the region in Observation 9 and Lemma 17 should be defined to be the region in the proof of Lemma 19 (with respect to ); then all observations above (after replacing by ) still hold for .
After is processed for each , is computed for every ; among these at most points, we return the point whose value is the smallest as , which is based on our above analysis (and also due to our assumption that is on for some ). The total number of calls on the region-processing procedures is . The total number of -region range queries is since each such query is for a composite bundle and there are at most bundles in total. Hence, the total time of the algorithm is . Recall that .
4.6 The Algorithm Implementation
In this section, we discuss some implementation details left out above. Specifically, we will give our algorithm for computing the map , and give our data structures for answering the SP-segment-intersections queries and the -region range queries.
4.6.1 Computing the Map
Recall the definitions of , , and in Section 4.2. Computing the map is to compute the list . Intuitively, we want to order the paths counterclockwise around with respect to . Our goal is to prove Lemma 8.
We begin with our preprocessing algorithm. Let denote the decomposition of \mbox{S!P!M}(s) by the edges of \mbox{S!P!T}(s), which can be constructed in time after \mbox{S!P!M}(s) is given. For each cell of , we pick an arbitrary point in the interior of as the representative point of . Let denote the set of all such representative points. Let be the tree that is the union of the shortest paths from to all points of , and let be the root of . Clearly, has nodes and can be computed in time once we have . The points of are exactly the leaves of . We find a base leave of in time. Then, we compute in time the list of all leaves and the cycle . To simplify the notation, let and let . This finishes our preprocessing, which takes time.
In the sequel, we discuss our algorithm for computing the list in time. It is sufficient to compute the circular list since we can obtain from in time by breaking the cycle at .
Let (temporarily only for the discussion in this subsection). Recall that for each point with , is the root of the cell of \mbox{S!P!M}(s) that contains and determines the shortest path , and note that is in a cell of , denoted by (which can be determined in time by a point location in ). If all cells are distinct, then the order of the points of following the relative order of the representative points of the cells in is exactly , which can be computed in time with help of the circular list .
If are not distinct, then we first compute the circular list of the cells by the above algorithm. To simplify the notation, let be the circular list. Then, two cells are the same only if they are adjacent in the list. Hence, we can determine in time the cycle of unique cells for , and further, for each cell , the set of points of in can also be determined. Consider a cell and let be the root. Let be the union of the segments for all , and we consider as a tree rooted at . Since is an obstacle vertex, is a node in . If is not , then let be the parent of in ; otherwise let be the child of in that is an ancestor of the base leave (we compute that particular child of in the preprocessing). Starting from the counterclockwise first child of in with respect to , and let be the list of the children of in ordered counterclockwise. It can be verified that the concatenation of is exactly the circular list . Following the above description, the circular list can be computed in time.
This proves Lemma 8.
4.6.2 The SP-segment-intersection Queries
In this section, we present our data structure for answering the SP-segment-intersection queries. Specifically, given any , we want to determine whether crosses , and if yes, compute an intersection. Here we consider a more general problem. Given a point and a segment in , we want to compute an intersection between and the shortest path (or report none if they do not intersect). In the case where has multiple shortest paths (and thus is not unique), the root of a cell of \mbox{S!P!M}(s) should also be provided so that refers to the one that contains . But to simplify the discussion, we assume always has a unique shortest path (the other case can be solved by our algorithm too).
We will show that with time and space preprocessing (with a given \mbox{S!P!M}(s)), each such query can be answered in time. When , the result is optimal.
Recall the definitions of , , , and the list in Section 3. In the following, we build up our data structure incrementally: We will first show how to answer queries when is in , then show how to answer queries when a vertex of , and finally discuss the general case where can be any point in .
We build a complete binary search tree as follows. The leaves of from left to right correspond to the points of in this order. In the following we will consider the points of and the leaves of interchangeably. Note that each point of is also a leaf in the tree . Consider any node of . We maintain a path of edges of , defined as follows. Let be the subtree of rooted at and let be the set of the leaves of . If is the root, then is the common sub-path (i.e., the intersection) of the shortest paths for all (note that is also the path of from to the root ). Otherwise, is the portion of the common sub-path of for all that is not stored in for any ancestor of . In this way, for each leave , the edges of of all nodes in the path of from to the root are pairwise disjoint and comprise exactly . Further, for each node of , since is a path of edges, we build a ray-shooting data structure on by standard techniques as detailed in the following lemma.
Lemma 20
For the path of each node of with , we can build a data structure of size in time such that given any ray in the plane, we can compute in time the first intersection (if any) between and .
Proof
This can be easily done by using the ray-shooting data structure for simple polygons [6, 21]. We provide the details below.
Let be a big rectangle in the plane that contains all edges of . Let be the topmost point of . We shoot a ray from upwards until it hits at a point . Then, we can consider , , and bounds a simple polygon . We build a ray-shooting data structure in in size and space [6, 21].
Consider any ray-shooting query for . Given a ray , we compute the first point of hit by in time by using the ray-shooting data structure on . If is on , then we are done and return as the answer. If is on , then we are also done and report that there is no intersection between and . If is on , then we keep shooting the ray after and using the ray-shooting data structure again to compute the next point hit by the ray. Similarly as above, if is on , then we are done and return . If is on , then we report that there is no intersection. Note that cannot be on . Hence, we can answer the ray-shooting query on in time by making at most two ray-shooting queries on . ∎
We call the information associated with each node of the auxiliary data structure at .
Lemma 21
The size of is and can be built in time.
Proof
Recall that the number of edges of is . In the following, we first show that each edge of is stored in of at most two nodes in each level of .
Assume to the contrary that there are three such nodes in the same level of that all store the same edge of in . Let the three nodes be from left to right. If are consecutive, then two of them, say, and , must share the same parent . Since is in both and , by definition, should be in for an ancestor of (including itself). Thus, should not be in either or , incurring contradiction.
In the following we assume are not consecutive. If two of them share the same parent, then we can apply the same argument as above. Otherwise, we show below that the sibling of (i.e., and share the same parent) has including . Consequently, the above proof applies.
Let be the set of points of whose paths from in contain the edge . Note that consists of exactly the leaves in the subtree of separated by . By the definition of , the points of are consecutive in . According to the definition of , the leaves of corresponding to the points of are consecutive in . Since is in both and , all leaves of the subtrees of and are in . Since is between and , is also between and . Thus, all leaves of must also be in , implying that is in the common sub-path of for all . Since is in , is not in for any proper ancestor of . Because and share the same parent, we obtain that is also in .
This proves that each edge of is stored in at most two nodes in each level of . Since has levels and , each edge is stored in nodes. Hence, the size of is .
In the following, we construct the tree in time. The key is to compute for each node of , after which constructing the ray-shooting data structure on can be done in linear time by Lemma 20.
For each edge of , we compute the range that consists of all indices such that is contained in the path from to in . This can be done in time as follows. For each vertex of , we define the range as the set of all indices such that is contained in the path from to in . We first compute the ranges for all vertices of . This can be easily done a post-order traversal of starting from the leaf . Specifically, during the traversal for each vertex , if is a leaf containing , we set and ; otherwise, all children of have been visited and we set (resp., ) to be the smallest (resp., largest) of all children of . After the traversal, the ranges for all vertices of are computed. Then, for each edge of , it is not difficult to see that the range of is the same as that of , where is the endpoint of such that the path from to in contains .
Next we compute for all nodes of as follows. We consider the edges of following the post-order traversal from . For each edge , by using the range , we find those nodes of whose contains . This can be done in the similar way as the standard insertion operation in segment trees [4]. Specifically, for each node of , let be the range consists of all indices such that is . Starting from the root of , for each node , if , then we insert to ; otherwise, for each child of , if , then we proceed on recursively. As the standard insertion operations on segment trees, each edge is processed in time since the height of is . Hence, the total time of the algorithm is . Note that since we consider the edges of by following the post-order traversal from , whenever we insert an edge to , is always the edge adjacent to the first edge of the current and is then appended to as the new first edge. After the algorithm finishes, the sub-path is readily available by following the edges in the order they have been inserted and the first edge is the one closest to .
This proves the lemma. ∎
We show how to answer SP-segment-intersection queries by using the tree . We begin with a special case where the query point is in , say for some . Our goal is to compute an intersection between and . To answer the query, we follow the path of from the root to the leaf . For each node in the path, we use a ray-shooting query to compute an intersection between and . If we find an intersection, then we report the intersection and stop the algorithm; otherwise, we proceed on the next node. The correctness of the algorithm is based on the fact that the union of of all nodes in the above path is exactly . The query time is since each ray-shooting query takes time and the height of is .
We then consider a more general case where the query point is a vertex of ( is not necessarily in ). To answer the query, we first pick an arbitrary leave in the subtree of rooted at (for this, in the preprocessing step we need to associate with an arbitrary leaf in its subtree for each node of ). Clearly, must be in the path . We follow the path of from the root to the leaf . For each node in the path, we compute an intersection between and by using a ray-shooting query. If there is an intersection , we check whether is in the sub-path of between and (see below for more details about this). If yes, then we report and stop the algorithm. Otherwise, since can only cross once, there cannot be any intersection between and ; thus, in this case we simply return none. If there is no intersection between and , then we proceed on the next node in the path. If we do not find any intersection after we reach , then we report none.
It remains to discuss how to determine whether is between and . The point is on an edge of , which is also in . Let be the endpoint of that is farther to in . Observe that is between and if and only if is between and . To determine the latter, observe that is between and if and only if is after in the canonical list , which can be determined in time (e.g., by binary search) after is computed in the preprocessing.
Hence, the total time for answering the query is .
In the following, by making use of the above result, we consider the most general case where can be any point in . We first present the result for the simple polygon case.
Lemma 22
For any simple polygon of vertices and a source point in , after time preprocessing, we can answer each SP-segment-intersection query in time.
Proof
Given any query segment and a point in , the query asks for the intersection between and the shortest path from to in (or report none if there is no intersection).
In the preprocessing, we compute the shortest path tree \mbox{S!P!T}(s) and shortest path map \mbox{S!P!M}(s) from in , which can be done in time [17]. We then build a point location data structure on \mbox{S!P!M}(s) in time [14, 25]. Further, we compute the canonical cycle \mathcal{C}(\mbox{S!P!T}(s)) in time.
Let be the root of the cell of \mbox{S!P!M}(s) containing such that contains . We first check whether intersects . If yes, we return the intersection. Otherwise, we proceed to compute the intersection between and the shortest path from to .
Let and be the two endpoints of , respectively. We first check whether is on , as follows. If , then must be on an edge of \pi(s,r_{t})\subseteq\mbox{S!P!T}(s), and further, must be a descendent of , where is the endpoint of farther to in . Therefore, to check whether is on , we can use the following approach. First, we determine whether is on an edge of \mbox{S!P!T}(s), which can be done in time by a point location query on the decomposition of \mbox{S!P!M}(s) by the edges of \mbox{S!P!T}(s). If is not on an edge of \mbox{S!P!T}(s), then we know that cannot be in . Otherwise, we proceed on determining whether is a descendent of . To this end, observe that is a descendent of if and only if the lowest common ancestor of and in \mbox{S!P!T}(s) is , which can be computed in time after time preprocessing on \mbox{S!P!T}(s) [3, 18].
Hence, we can check whether is in in time. Similarly we can check whether is in in time. If either or is on , then we stop the algorithm and return it as an intersection of and . Below, we assume neither nor is in . Thus, our goal is to compute the intersection between and the interior of .
Let be the root of the cell of \mbox{S!P!M}(s) containing . Define similarly. Let be the lowest common ancestor or and in \mbox{S!P!M}(s) (e.g., see Fig. 18), which can be found in constant time by a lowest common ancestor query. Let denote the funnel that is the region of bounded by , , and . Note that both and are convex with the convexity towards the interior of . We assume that if we traverse from counterclockwise around we will be on before arriving at (otherwise we exchange the notation and ). Observe that intersects the interior of if and only if there is an edge of such that intersects the interior of and one endpoint of is in and the other one is outside (e.g., see Fig. 18). Let be the endpoint of in and be the endpoint of outside . Observe that such an edge exists if and only if is between and counterclockwise in the circular list \mathcal{C}(\mbox{S!P!T}(s)), which can be determined in time by binary search on the list.
Further, if such an edge exists, then we further compute the intersection . To determine the edge , we first find the vertex as follows. We find the lowest common ancestor of and , denoted by . If is not , then must be on and is . Otherwise, the lowest common ancestor of and is . After is found, is the first edge in the shortest path from to , which can be found in time using a two-point shortest path query on the vertex pair with time preprocessing [16, 19]. ∎
Combining all our results above, the following lemma gives our final result.
Lemma 23
Given \mbox{S!P!M}(s), we can build a data structure of size in time that can answer each SP-segment-intersection query in time.
Proof
In the preprocessing, we build the tree , which takes time and space. For each cell of the decomposition , since it is a simple polygon, we build the data structure in Lemma 22 with respect to each super-root of ; this takes time and space in total.
Given and , our query algorithm works as follows. We first determine the cell of that contains . We also determine the super-root of such that . All this can be done in time. Note that is a vertex in . Hence, we can compute an intersection between and in time using the tree . If there is an intersection, we return it and stop the algorithm. Otherwise, we compute an intersection between and in the cell . To this end, we first compute the at most two sub-segments of by using the ray-shooting queries inside and outside . For this, in the preprocessing, for each cell of , we compute ray-shooting data structures on both the inside and outside of (e.g., by the similar techniques as in Lemma 20). Computing these ray-shooing data structure on all cells of takes time. Then, for each sub-segment of , we compute the intersection (if any) between and in time by Lemma 22. Hence, the overall query algorithm runs in time.
The lemma thus follows. ∎
4.6.3 The -Region Range Queries
In the following, we give our data structure for answering the -region queries. Specifically, given a range of indices of the regions of and an extended-window , the query asks for the ccw-largest index such that crosses the region boundary (or report none if such an index does not exist). We actually consider a more general query where can be any segment in (not necessarily in ). Our goal is to show the following result.
Lemma 24
Given \mbox{S!P!M}(s), we can build a data structure in time and space such that each -region range query can be answered in time.
Recall that for each region , its boundary consists of three portions: , , and .
Recall that . We build a complete binary search tree as follows. Like in Section 4.6.2, the leaves of from left to right correspond to . For each node of , we construct the same auxiliary data structure as in . In addition, we build another auxiliary data structure for each internal node of as follows.
We use to denote the subtree of rooted at and use to denote the set of the leaves of . As in in Section 4.6.2, each point of corresponds to a leaf of and is also a leaf of . Let be the point of the path in that is farthest from . In the case where is empty, let be for the parent of if and otherwise. Note that is a node of . Let be the union of the paths of from to all leaves of in , excluding the sub-path from to in . It is not difficult to see that is actually a subtree of . Recall that the points of are consecutive in the list . Let be with . If (i.e., is not a leaf), for each , recall that belongs to and is either a bisector super-curve or a chain of obstacle edges, and we add to if is a bisector super-curve. The resulting is . Note that is connected since every point of has a path on connecting to the point . We consider as a subdivision of the plane by all edges of , without considering the obstacles of .
We claim that each cell (excluding the outer unbounded one) of is simply connected. Indeed, if does not contain any bisector super-curve , then is a connected subtree of and thus there is only one cell, which is the outer unbounded one. If contains a bisector super-curve for some , then along with (which is also the path from to in and is in ) and forms a closed cell of . Note that is also a cell in the decomposition . Also, for any closed cell of (i.e., is not the outer unbounded one), must be formed by a bisector super-curve in as discussed above. Therefore, each closed cell of is simply connected.
For each closed cell of , we build a ray-shooting data structure. Although has a bisector super-curve, which consists of hyperbolic curves instead of line segments, Melissarators and Souvaine [26] showed that we can still build a ray-shooting data structure for in linear time and space such that each query can be answered in logarithmic time111In fact, since each bisector edge of \mbox{S!P!M}(s) is a convex curve, is naturally a splinegon [26]..
For the outer cell of , we can use the similar approach as Lemma 20 to preprocess it in linear time such that each ray-shooting query on can be answered in logarithmic time.
In addition, recall that connects and . If is a bisector super-curve, then we build a ray-shooting data structure for [26].
This finishes the description of our data structure .
Lemma 25
The space of is and can be built in time.
Proof
First of all, the auxiliary data structures on all nodes of can be built in time and space as in Lemma 21. In the following, we focus on the second auxiliary data structure . To analyze the total space, we first show that each edge of can be in for at most two nodes in each level of .
Indeed, assume to the contrary that there are three such nodes. Since the points of whose paths from in that contain must be consecutive in the list (and thus in the consecutive leaves of ), by the similar analysis as in Lemma 21, we can find two nodes and sharing the same parent such that is contained in both and . But this implies that must be stored in for a proper ancestor of (or ). This further implies that cannot be stored in either or .
Hence, each edge of can be in for at most two nodes in the same level of . Consequently, each edge of is contained in for at most nodes of , as the height of is .
Next we show that for each bisector super-curve , it is stored in for at most nodes of . Recall that the two endpoints of are two leaves and of . Notice that is in if and only if , where (resp., ) is the index of the leftmost (resp., rightmost) leaf in the subtree . Clearly, if and only if is in the path from the root to the lowest common ancestor of and , and there are such nodes .
Since the total size of all bisector super-curves is , the space of in used to store the bisector super-curves is .
Combining the above discussions, the size of is .
For each node of , constructing can be done in linear time in the size of as follows. Let be the leaves in . We consider the paths from to these leaves in one by one in a bottom-up manner. Initially we let contain the only path . In general, suppose has been considered (initially, ). Then we process as follows. We traverse on from to in until we meet an obstacle vertex that is on the current , and then add all traversed edges of to . We continue the algorithm as above until is processed. Finally, for each (if ), if is a bisector super-curve, then we add to . The above algorithm constructs in linear time.
Then, we construct the ray-shooting data structures for the cells of , which can also be done in linear time in the size of .
Since the total size of of all nodes of is , the total time for constructing the second auxiliary data structures is . Therefore, can be computed in time. ∎
By using the tree , the following lemma gives our query algorithm, which proves Lemma 24.
Lemma 26
Each -region range query can be answered in time.
Proof
Given a range of indices of the regions of and a segment , we want to compute the ccw-largest index such that crosses the boundary (if no such index exists, then we return none). Let be the sought index.
Recall that both and are possible. We first consider the case where . In this case, consists of . We begin with finding the lowest common ancestor of the two leaves and in , denoted by . Our algorithm consists of four procedures.
The first procedure.
The first procedure considers the nodes in the path of from the root to . For each node in the path, we check whether crosses by a ray-shooting query. If yes, then crosses the shortest path and thus crosses . Hence, we can simply return and stop the algorithm. Otherwise, we proceed on the next node until is considered.
After is considered, if is not found, then we go to the second procedure.
The second procedure.
The second procedure considers the nodes in the path of from up to in a bottom-up fashion. For each node , there are three cases.
If , we stop the second procedure and go to the third procedure. 2. 2.
If , then we check whether whether intersects by calling a ray-shooting query. If there is an intersection, we return . Otherwise, we proceed on the parent of . 3. 3.
Suppose is neither nor .
If is in the left sub-tree of , then we check whether intersects by a ray-shooting query. If there is an intersection, then we return . Otherwise, we proceed on the parent of .
If is in the right sub-tree of , then we first check whether intersects . If yes, then we return . Otherwise, let be the left child of (if does not have a left child, then we proceed on the parent of ). We proceed as follows.
We check whether intersects . If yes, we return as the rightmost index of the leaves in the subtree . Otherwise, we check whether intersects by first locating the cell of containing an endpoint of and then calling a ray-shooting query on . If not, we proceed on the parent of (not ). Otherwise, we set and go to the fourth procedure.
The third procedure.
In this procedure, we consider the vertices on the path of from the left child of down to , which is symmetric to the second procedure. For each node , there are two cases.
If , we first check whether intersects by a ray-shooting query. If yes, we return the index of the rightmost leaf of as . Otherwise, if is at the right subtree of , then we proceed on the right child of .
If is at the left subtree of , let be the right child of (if does not have a right child, then we proceed on the left child of ). We first check whether intersects . If yes, we return the index of the rightmost leaf of as . Otherwise, we check whether intersects . If not, we proceed on the left child of . Otherwise, we set and go to the fourth procedure. 2. 2.
If , then we check whether intersects . If yes, we return . Otherwise, we return none, i.e., does not intersect for any .
The fourth procedure.
In the fourth procedure, we have a vertex of such that does not intersect but intersects . Starting from , the procedure works as follows. If is a leaf, then we simply return the index of the leaf as . Otherwise, let be the right child of . If intersects , then we return as the index of the rightmost leaf of . Otherwise, we check whether intersects . If yes, we set to and proceed as above. Otherwise, we set to the left child of and proceed as above.
For the running time of the algorithm, observe that the algorithm only visits vertices of and makes ray-shooting queries as the height of is . Each ray-shooting query is either on or for some node of , which runs in time. Hence, the total time of the algorithm is .
The above gives the query algorithm for the case . If , then the index range consists of . For this case, we first apply the above query algorithm on the range . If the query does not return none, then we return as the answer to the original query on . Otherwise, if is a bisector super-curve, then we check whether intersects by a ray-shooting query; if there is an intersection, then we return . Otherwise, we apply the above query algorithm on the range , and the result of the query is the answer to the original query on . The total time of the query algorithm is still .
The lemma thus follows. ∎
4.7 Wrapping Things Up
We summarize our overall result in the following theorem.
Theorem 4.1
Given \mbox{S!P!M}(s), we can build a data structure of size in time, such that each quickest visibility query can be answered in time, where is the size of the visibility polygon of the query point .
Proof
In the preprocessing, we compute the visibility polygon query data structure in [9] for computing \mbox{V!i!s}(q), which is of size and can be built in time. The rest of the preprocessing work includes building the decomposition and the segment query data structure as in Section 3, performing the preprocessing in Lemmas 8, 10, 16, 23, and 24; these work takes time and space in total.
Given any query point , we first compute \mbox{V!i!s}(q) in time by the query algorithm in [9]. Then, we obtain the extended window set . Let , which is . Next, we compute a closest point on a segment of in time. To this end, we compute a set of candidate points as follows. We first add to . Then, we compute the closest point of and add to . Next we compute the point in time by using our pruning algorithm in Sections 4.3 and 4.5. By a symmetric algorithm, we can also compute . We add both and to . By our analysis, must be one of the points of . Since , we can find in in additional time by using the shortest path map \mbox{S!P!M}(s). ∎
In fact, we have the following more general result, which might have independent interest.
Corollary 1
Given \mbox{S!P!M}(s), we can build a data structure of size in time, such that given segments in intersecting at the same point, we can compute a shortest path from to all these segments in time.
Proof
The preprocessing step is the same as in Theorem 4.1 except that the visibility polygon query data structure [9] is not necessary any more. Hence, the total preprocessing time and space is .
Given a set of segments intersecting at the same point, denoted by , we break each segment at to obtain two segments and we still use to denote the new set of at most segments. Next we compute a closest point on the segments of . To do so, we can apply the same algorithm as in Theorem 4.1 for computing on the extended-windows of . Indeed, the only key property of the segments of we need is that all segments of have a common endpoint at . Now that all segments of have a common endpoint , the same algorithm still works (some degenerate cases may happen, but can be handled easily). ∎
5 The Quickest Visibility Queries: The Improved Result
In this section, we reduce the query time of Theorem 4.1 to , independent of . The key idea is the following. First, we show that for any query point , there exists a subset of windows such that a closest point is on a segment of . Second, we give an algorithm that can compute in time, without computing \mbox{V!i!s}(q). Our idea relies on the extended corridor structure [8, 9, 11] and modifying the query algorithm for computing \mbox{V!i!s}(q) in [9].
Below we first review the extended corridor structure in Section 5.1. We then introduce the set in Section 5.2. Finally we present our algorithm for computing in Section 5.3.
5.1 The Extended Corridor Structure
The corridor structure has been used for solving shortest path problems, e.g., [7, 23]. Later some new concepts such as “bays,” “canals,” and the “ocean” were introduced, e.g., [8, 11], referred to as the “extended corridor structure”. We review it here for the completeness of this paper and also for introducing the notation that will be needed later.
Let \mbox{T!r!i}(\mathcal{P}) denote an arbitrary triangulation of . Each edge of \mbox{T!r!i}(\mathcal{P}) that is not an obstacle edge of is called a (triangulation) diagonal. Let be the (planar) dual graph of \mbox{T!r!i}(\mathcal{P}) (i.e., each triangle defines a node and two triangles that share a diagonal define an edge). The degree of each node in is at most three. Using , we compute a planar 3-regular graph, denoted by (the degree of each node in is three), possibly with loops and multi-edges, as follows. First, remove every degree-one node from together with its incident edge; repeat this process until no degree-one node remains. Second, remove every degree-two node from and replace its two incident edges by a single edge; repeat this process until no degree-two node remains. The resulting graph is (see Fig. 20), which has faces, nodes, and edges [23]. Each node of corresponds to a triangle of \mbox{T!r!i}(\mathcal{P}), which is called a junction triangle. Removing all junction triangles results in corridors (defined below), each of which corresponds to an edge of .
The boundary of a corridor consists of four parts (see Fig. 20): (1) A boundary portion of from a point to a point ; (2) a diagonal of a junction triangle from to ; (3) a boundary portion of from to a point ; (4) a diagonal of a junction triangle from to . The above (1) and (3) are called the two sides of . The corridor is a simple polygon.
Let (resp., ) be the shortest path from to (resp., to ) in . The region bounded by , and the two diagonals and is called an hourglass, which is open if and closed otherwise (see Fig. 20). If is open, then both and are convex chains and are called the sides of ; otherwise, consists of two “funnels” and a path joining the two apices of the two funnels, called the corridor path of . Each side of every funnel is also a convex chain.
The triangulation \mbox{T!r!i}(\mathcal{P}) can be computed in either time or time for any constant [2]. After \mbox{T!r!i}(\mathcal{P}) is produced, computing all corridors and hourglasses takes time.
Let be the union of all junction triangles, open hourglasses, and funnels. We call the ocean, which is a subset of . Since the sides of open hourglasses and funnels are all convex, the boundary of consists of convex chains with a total of vertices.
The space of not in , i.e., , consists of two types of regions: bays and canals, defined as follows. Consider the hourglass of a corridor .
We first discuss the case where is open (see Fig. 20). The boundary of has two sides. Let and be any two consecutive vertices on one side of such that is not an obstacle edge (see the left figure in Fig. 20). Both and must be on the same side of the corridor . The region enclosed by and the side of between and is called a bay. We call the gate of the bay, which is a common edge of the bay and .
If the hourglass is closed, let and be the two apices of its two funnels. Consider two consecutive vertices and on a side of a funnel such that is not an obstacle edge. If and are on the same side of the corridor , then also defines a bay. Otherwise, one of and must be a funnel apex, say, , and we call a canal gate (see Fig. 20). Similarly, there is also a canal gate at the other funnel apex , say . The region of bounded by the two canal gates and that contains the corridor path is the canal of .
Each bay or canal is a simple polygon. While the total number of all bays is , the total number of all canals is since the number of corridors is . The two obstacle vertices of each bay/canal gate are called gate vertices.
5.2 Defining the Window Set
We consider the source point as an obstacle and build the extended corridor structure. This means that is on the boundary of the ocean and thus is not in any bay or canal.
Consider any query point . For any bay, if is not in the bay, since the bay has only one gate, cannot see any point outside the bay “through” its gate. Although a canal has two gates, the next lemma, proved in [11], gives an important property that if is outside a canal, then cannot see any point outside the canal through the canal (and its two gates).
Lemma 27
[11]* (The Opaque Property) For any canal, for any line segment in (i.e., is visible to ) such that neither nor is in the canal. Then cannot contain any point of the canal that is not on its two gates.*
Consider any window of defined by , i.e., is the first point on hit by the ray from along the direction from to . Clearly, the extended-window is locally tangent at , i.e., the two incident obstacle edges to must be on the same side of the supporting line of . In the following, we partition all windows of into different types.
Recall that is comprised of convex chains. We call an ocean window if is a vertex of a convex chain of such that is outer tangent to that convex chain at . Since has at most two extended-windows outer tangent to each convex chain, has ocean windows.
Suppose is not an ocean window. If does not contain any point in , then is in a bay/canal . In this case, we say is an outer-bay/outer-canal window defined by (we use “outer” because it is possible that contains points outside ); e.g., see Fig. 21.
If contains a point in , then . Depending on whether is on , there are two cases.
If is on , then is in this is because cannot traverse through the interior of a canal due to the opaque property of Lemma 27. If we move from to on , since is not an ocean window, after we pass , we must move into the inside of a bay/canal , and further, regardless of whether is a bay or a canal, we will never get out of due to the opaque property, which implies that must be in . In this case, we say that is an inner-bay/inner-canal window defined by (we use “inner” because is in ).
If is not on , then is a non-gate vertex of a bay/canal . This implies that if we move from to on , we must cross a gate of . Again, regardless of whether is a bay or a canal, must be in . In this case, we also call an inner-bay/inner-canal window (e.g., see Fig. 23 and Fig. 23).
As a summary, a window may be an ocean window, an outer-bay/canal window, or an inner-bay/canal window.
A window of is called a closest window if it contains a closest point of \mbox{V!i!s}(q).
The set is defined as follows. We first add all ocean windows to . We will show several observations. First, no inner-bay window can be a closest window. Second, among all inner-canal windows defined by the same canal, there are at most two that can be closest windows and we add them to . Since there are canals, has inner-canal windows. Third, among all outer-bay windows, there are at most two that can be closest windows; we add them to . Fourth, among all outer-canal windows, there are at most four that can be closest windows; we add them to . This finishes the definition of . In summary, has ocean windows, inner-canal windows, at most two outer-bay windows, and at most four outer-canal windows. Thus, the size of is .
For a window , we assume it is directed from to and also assume is directed from to .
Observation 10
Suppose is a closest window, i.e., . If the two obstacle edges incident to are on the left (resp., right) side of , then the shortest path from to must be from the left (resp., right) side of .
Proof
As discussed before, is either from the left or from the right side of . Without loss of generality, we assume that the two obstacle edges incident to are on the left side of .
Assume to the contrary that is from the right side of . Let be a point on infinitely close to but . Since the two obstacle edges incident to are on the left side of , is visible to , i.e., p\in\mbox{V!i!s}(q). Since , cannot be a closest point of \mbox{V!i!s}(q), a contradiction. ∎
Lemma 28
None of the inner-bay windows is a closest window.
Proof
Suppose is an inner-bay window defined by a bay . By definition, is in . Assume to the contrary that is a closest window.
Without loss of generality, assume the two obstacle edges of incident to is on the left side of (e.g., see Fig. 23). Since both and are on the boundary of , partitions into two sub-polygons and one of them contains the only gate of . Let be the sub-polygon that does not contain . Observe that must be locally on the left side of . By Observation 10, since , must be from the left side of , implying that must be in the interior of , where is a point on infinitely close to . Clearly, is not in . Thus, must cross , but this is not possible since is on . Thus, cannot be an closest window. ∎
Lemma 29
For any canal that defines an inner-canal window , if is not an endpoint of the corridor path of , then cannot be a closest window.
Proof
Since is an inner-canal window defined by , must be in and both and are on the boundary of . Further, has a point and crosses a gate of . Let such that is the endpoint of the corridor path of on (e.g., see Fig. 23). Let be the corridor that defines the canal .
Assume without loss of generality that the two obstacle edges of incident to are on the left side of . Since is not , according to the results in [11] (see the proof of Lemma 3) that and must be on the same side of that contains (e.g., see Fig. 23). This implies that partitions into two sub-polygons one of which contains both gates of , and let be the sub-polygon that does not contain the gates. Then, as in the proof of Lemma 28, must be locally on the left side of , and by the similar analysis we can show that cannot be a closest window. ∎
Since each canal has one corridor path, the preceding lemma implies that every canal can define at most two inner-canal windows that are possibly closest windows.
Consider a bay with gate that defines an outer-bay window . By definition, is in . Let be the vertex of such that is in the shortest path in from to an endpoint of ; similarly, define with respect to the other endpoint of .
Lemma 30
If is an outer-bay window defined by and is neither nor , then cannot be a closest window.
Proof
By the definitions of and , since is a simple polygon and is neither nor , must be in . Hence, the window partitions into two sub-polygons and one of them contains . Let be the sub-polygon that does not contain . Then, by using the same analysis as in Lemma 28, cannot be a closest window. ∎
Consider a canal that defines an outer-canal window . This case is similar to the above bay case except that we need to consider both gates of . Again, is in . Define , , , and similarly as in the bay case but with respect to the four gate vertices of , respectively.
Lemma 31
If is an outer-bay window defined by and is not in , then cannot be a closest window.
Proof
By the definitions of for , since is a simple polygon and , must be in and is not on a gate of . Further, it can be verified that the window partitions into two sub-polygons and one of them contains both gates of . Let be the sub-polygon that does not contain the gates of . Then, by using the same analysis as in Lemma 28, cannot be a closest window. ∎
The above discussions lead to the following lemma.
Lemma 32
Given any query point , there is a set of windows of such that and contains a closest window.
5.3 Computing the Window Set
In this section we present our algorithm for computing , by modifying the query algorithm in [9] for computing \mbox{V!i!s}(q). Our result is summarized in the following lemma.
Lemma 33
With time and space preprocessing, given any query point in , we can compute the set in time.
We first do the same preprocessing as in [9], which takes time and space. In the following, we give our query algorithm for computing . Depending on whether is in the ocean , a bay, or a canal, there are three cases. In each case, we will first briefly review the algorithm in [9] for computing \mbox{V!i!s}(q) and then modify it to compute .
5.3.1 The Ocean Case
Suppose is in . The algorithm in [9] first computes the region of that is visible to , denoted by \mbox{V!i!s}(q,\mathcal{M}), which is also the visibility polygon of in due to the opaque property of canals. Then, the algorithm computes the region in all bays and canals visible to . To this end, it traverses on the boundary of \mbox{V!i!s}(q,\mathcal{M}). If a gate of a bay/canal is encountered, then the region of visible to through is computed, where is a maximal portion of on the boundary of \mbox{V!i!s}(q,\mathcal{M}). The visible regions computed above for all such ’s are pairwise disjoint. Hence, \mbox{V!i!s}(q) is a trivial union of \mbox{V!i!s}(q,\mathcal{M}) and the visible regions in all bays and canals.
We modify the above algorithm to compute , as follows.
The algorithm in [9] computes \mbox{V!i!s}(q,\mathcal{M}) by using the visibility complex [29, 30]. More specifically, it uses the approach of crossing faces [30] such that all rays originating from in the plane define a curve in the visibility complex and each intersection of and the boundary of a cell of the visibility complex corresponds to an outer tangent in from to a convex chain of . Note that such tangents correspond exactly to our ocean windows. If we traverse the curve in the visibility complex, each such intersection can be computed in time. Hence, if there are convex chains of that are visible to , then the endpoints of the maximal sub-chains of these convex chains that are visible to can be computed in time by using the approach of crossing faces. Note that [9]. After this, all ocean windows are computed.
Remark.
Traversing each such sub-chain can explicitly construct \mbox{V!i!s}(q,\mathcal{M}). But for our problem of computing , we can avoid this step; indeed, this is part of the reason our algorithm avoids the time.
Next, we compute other windows of . Since is in , does not have outer-bay/outer-canal windows, and we only need to compute the inner-canal windows, as follows.
The above has computed the endpoints of each such sub-chain that is visible to . If does not contain any portion of any canal gate, then we simply ignore . Otherwise, we need to compute the inner-canal windows through for each canal gate that has a portion in . To this end, we need to first find these canal gates. For this, in the preprocessing step, for each convex chain of , we maintain a list of canal gates on by a balanced binary search tree such that given the two endpoints and of , we can determine whether contains any portion of any canal gate in time, and if yes, report all these portions in time, where is the number of these portions. The number of such in the entire algorithm is since the total number of canal gates is . For each such canal gate portion , we compute the corresponding inner-canal window (if any) as follows.
Let be the canal gate containing and let be the canal. Let be the endpoint of the corridor path of at . If is not on , then we ignore . Otherwise, is visible to and defines an inner-canal window with . Our goal is to compute . This can be easily done by using a ray-shooting query in as follows. Consider the ray originating from with direction from to . Using a ray-shooting query on , we find the first point on the boundary of that is hit by the ray. Again, due to the opaque property of canals, must be on an obstacle edge of , and thus . For answering each ray-shooting query in in time, we need to preprocess each canal for ray-shooting queries in linear time since a canal is a simple polygon, and this requires time in total for all canals.
Since the number of all visible sub-chains is , we can compute all inner-canal windows in time.
In summary, we can compute the set in time for the ocean case.
5.3.2 The Bay Case
If is in a bay , then the algorithm in [9] for computing \mbox{V!i!s}(q) first computes the region of that is visible to , denoted by \mbox{V!i!s}(s,A). If the gate of does not have any point on the boundary of \mbox{V!i!s}(s,A), then is not visible to , which further implies that no point outside the bay is visible to and thus \mbox{V!i!s}(s)=\mbox{V!i!s}(s,A). If has a sub-segment on the boundary of \mbox{V!i!s}(s,A), then the points of visible to are all visible to through . Next, the region \mbox{V!i!s}(q,\mathcal{M}) of that are visible to through is computed. After \mbox{V!i!s}(q,\mathcal{M}) is computed, the rest of the algorithm is the same as the ocean case. Namely, by traversing the boundary of \mbox{V!i!s}(q,\mathcal{M}), other regions of in bays and canals visible to can be computed.
Next we modify the above algorithm to compute .
Since is in , we first compute the (at most two) outer-bay windows. Let and be the two endpoints of , respectively. In the preprocessing, we compute the shortest path maps of and in , respectively. We also compute a ray-shooting data structure in . The total such preprocessing takes time for all bays. Then, using the shortest path maps of and , the two vertices and as defined before can be computed in time.
If , then consider the ray originating from along the direction from to . Let be the first point on the boundary of hit by . Since , must be on an obstacle edge of (i.e., is not on the gate of ), and thus is an outer-bay window. In fact, in this case is the only window in , and thus we can stop our algorithm.
If , then for each with , the intersection of with the supporting line of is an endpoint of [17]. Hence, can be determined immediately once and are available. Similarly as in the above ocean case, the algorithm in [9] uses the approach of crossing faces to compute \mbox{V!i!s}(q,\mathcal{M}) through , which is actually a “cone” visibility query since the visibility of in is delimited by the cone bounded by the ray from to and the ray from to . All rays from in the cone define a segment of the curve (discussed in the ocean case) in the visibility complex. To use the approach of crossing faces, the algorithm in [9] first finds the cell of the visibility complex that contains an endpoint of , which is done in time by a point location data structure on the visibility complex. After this, the rest of the algorithm is the same as the ocean bases. This is also the case for our problem for computing . After locating the cell , we can use the crossing face approach to compute the maximal sub-chains of the convex chains of that are visible to through . As in the ocean case, this will also compute all ocean windows of . After that, we use the same approach as in the ocean case to compute all inner-canal windows. The total time is .
Finally, we compute the two outer-bay windows defined by and . Namely, we need to compute and . For each , let be the ray originating from and along the direction from to . The above algorithm for computing the sub-chains will also determine the point on first hit by . If is on an obstacle edge of , then is . Otherwise, is on a bay/canal gate of a bay/canal . Then, we use a ray-shooting query on to find the first point on the boundary of hit by . Regardless of whether is a bay or a canal, is always on an obstacle edge, and thus is . Since the ray-shooting query on takes time, the two outer-bay windows can be computed in time.
In summary, the window set can be computed in time for the bay case.
5.3.3 The Canal Case
If is in a canal , then the algorithm is similar to the bay case with the difference that we apply the same algorithm on the two gates of the canal separately. Specifically, let be a gate of . We first compute the vertices and with respect to and , respectively. Then, we apply exactly the same algorithm as in the bay case. After that, we consider the other gate of and apply the same algorithm. Then is computed and the total time is time.
This proves Lemma 33. After is computed, we can apply the query algorithm of Theorem 4.1 (or Corollary 1) on the windows of to compute . Thus we can obtain the following result.
Theorem 5.1
Given \mbox{S!P!M}(s), we can build a data structure of size in time, such that each quickest visibility query can be answered in time.
6 Conclusions
In this paper, we present a new data structure for answering quickest visibility queries. Our result is particularly interesting when , the number of holes of , is relatively small. For example, when , our result matches the best result for the simple polygon case (i.e., ) and is optimal. To achieve the result, we also solve many other problems that may be interesting in their own right. We highlight some of them below. We assume that the shortest path map \mbox{S!P!M}(s) of the source point has been given.
We present an algorithm that can compute a shortest path from to in time for any query segment , after time and space preprocessing. 2. 2.
We present an algorithm that can compute in time an intersection between and the shortest path for any segment and any point in , after time and space preprocessing. 3. 3.
We present an algorithm that can answer each -region range query in time, after time and space preprocessing. 4. 4.
We present an algorithm that can compute in time a shortest path from to any set of segments in that intersect at a same point, after time and space preprocessing.
These results are particularly interesting when is relatively small, and at least the first three results are optimal when .
In addition, the decomposition of , the regions of , and some other techniques proposed in the paper (e.g., bundles) may find other applications as well.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] E.M. Arkin, A. Efrat, C. Knauer, J.S.B. Mitchell, V. Polishchuk, G. Rote, L. Schlipf, and T. Talvitie. Shortest path to a segment and quickest visibility queries. Journal of Computational Geometry , 7:77–100, 2016.
- 2[2] R. Bar-Yehuda and B. Chazelle. Triangulating disjoint Jordan chains. International Journal of Computational Geometry and Applications , 4(4):475–481, 1994.
- 3[3] M. Bender and M. Farach-Colton. The LCA problem revisited. In Proc. of the 4th Latin American Symposium on Theoretical Informatics , pages 88–94, 2000.
- 4[4] M. de Berg, O. Cheong, M. van Kreveld, and M. Overmars. Computational Geometry — Algorithms and Applications . Springer-Verlag, Berlin, 3rd edition, 2008.
- 5[5] P. Bose, A. Lubiw, and J.I. Munro. Efficient visibility queries in simple polygons. Computational Geometry: Theory and Applications , 23(3):313–335, 2002.
- 6[6] B. Chazelle, H. Edelsbrunner, M. Grigni, L. Guibas, J. Hershberger, M. Sharir, and J. Snoeyink. Ray shooting in polygons using geodesic triangulations. Algorithmica , 12(1):54–68, 1994.
- 7[7] D.Z. Chen and H. Wang. A nearly optimal algorithm for finding L 1 subscript 𝐿 1 L_{1} shortest paths among polygonal obstacles in the plane. In Proc. of the 19th European Symposium on Algorithms (ESA) , pages 481–492, 2011.
- 8[8] D.Z. Chen and H. Wang. L 1 subscript 𝐿 1 L_{1} shortest path queries among polygonal obstacles in the plane. In Proc. of 30th Symposium on Theoretical Aspects of Computer Science (STACS) , pages 293–304, 2013.
