Abstract
We study the following problem: preprocess a set of objects into a data structure that allows us to efficiently report all pairs of objects from that intersect inside an axis-aligned query range . We present data structures of size and with query time time, where k is the number of reported pairs, for two classes of objects in : axis-aligned rectangles and objects with small union complexity. For the 3-dimensional case where the objects and the query range are axis-aligned boxes in , we present a data structure of size and query time . When the objects and query are fat, we obtain query time using storage.
Keywords: Data structures, Computational geometry, Intersection searching
Introduction
The study of geometric data structures is an important subarea within computational geometry, and range searching forms one of the most widely studied topics within this area [4, 15]. In a range-searching query, the goal is to report or count all points from a given set that lie inside a query range . The more general version, where contains other objects than just points and the goal is to report all objects intersecting , is often called intersection searching and it has been studied extensively as well. A common characteristic of almost all range-searching and intersection-searching problems studied so far, is that whether an object should be reported (or counted) depends only on and . In this paper we study a range-searching variant where we are interested in reporting pairs of objects that satisfy a certain criterion. In particular, we want to preprocess a set of n objects in or such that, given a query range , we can efficiently report all pairs of objects that intersect inside .
Our motivation for studying these problems is the following. Suppose we are given a collection of n discrete trajectories representing the movements of, say, people. Each trajectory is a sequence of locations (points in ) with a corresponding time stamp; for discrete trajectories the movement in between consecutive locations is not considered. The query we are interested in is: which pairs of people met inside a given rectangular query region ? A natural way to define that two people meet is to require that they are within a given distance D from each other. When we restrict our attention to a fixed time instance, we can place a disk of radius D / 2 around the location of each person and the question becomes: which pairs of disks intersect within ? When we consider the metric, we get the same problem but now for squares instead of disks. A more general version of the query also specifies a time interval I: which pairs of people met within a region during time interval I? To deal with the fact that the time stamps may not be synchronized for the different trajectories, we assume that each location is valid for some interval of time. If we then model time as the third dimension and consider distances in the metric, we get the question: which pairs of boxes (which are the product of a square around a location and a time interval) intersect with the query box ?
An obvious approach to our problem is to precompute all intersections between the objects and store the intersections in a suitable intersection-searching data structure. This may give fast query times, but in the worst case any two objects intersect, so is a lower bound on the storage for this approach. The main question is thus: can we achieve fast query times with a data structure that uses subquadratic (and preferably near-linear) storage in the worst case?
Rahul et al. [21] answered this question affirmatively when is an axis-aligned rectangle in and the objects are axis-aligned line segments. Their data structure uses storage and answers queries in time , where k is the number of answers. Our contribution is to obtain similar results for a broader class of objects than those of [21], namely axis-aligned rectangles and objects with small union complexity. For axis-aligned rectangles our data structure uses storage and has query time,1 where k is the number of reported pairs of objects. Our data structure for classes of objects with small union complexity—disks and other types of fat objects are examples—uses storage, where U(n) is maximum union complexity of n objects from the given class, and it has query time. We also consider a 3-dimensional version of the problem, where the range and the objects in are axis-aligned boxes. Here our data structure uses storage and query time. When the query range and the objects are fat, we improve this to storage and query time.
Related work The paper by Rahul et al. [21] mentioned above studies the same problem as we do (in a less general setting). There are a few more papers dealing with related problems. Das et al. [10] have studied the problem of preprocessing a set H of n horizontal and V of n vertical segments in the plane into a data structure such that given an axis-parallel query rectangle and a parameter , all the triples (h, v, p) where , , and p is an endpoint of either of the segments and and can be reported efficiently. Their data structure needs space and is able to answer the desired queries in time. Abam et al. [1], Gupta [16], and Gupta et al. [17] have presented data structures that return the closest pair inside a query range.
Axis-Aligned Objects
In this section we study the case where the set is a set of n axis-aligned rectangles in or boxes in . We assume throughout the paper that the objects in as well as the query rectangles are closed sets. Our approach for these cases is the same and uses the following two-step query process.
Compute a seed set of objects such that the following holds: for any two objects in such that and intersect inside , at least one of is in .
For each seed object , perform an intersection query with the range in the set , to find all objects intersecting inside .
For this approach to be efficient, should not contain too many objects that do not give an answer in Step 2. For the planar case we will ensure , where k is the number of pairs of objects intersecting inside , while for the 3-dimensional case we will have .
The Planar Case
Let be a set of axis-aligned rectangles in . The key to our approach is to be able to efficiently find the seed set . To this end, during the preprocessing we compute a set W of axis-aligned witness segments. For each rectangle we define at most ten witness segments, two for each edge of and two in the interior of , as follows—see also Fig. 1.
Fig. 1.
Gray areas are intersections of other rectangles with black segments indicate witness segments
Let e be an edge of , and consider the set , that is, the part of e covered by the other rectangles. The set S(e) consists of a number of sub-edges of e. If e is vertical then we add the topmost and bottommost sub-edge from S(e) (if any) to W; if e is horizontal we add the leftmost and rightmost sub-edge to W. The two witness segments in the interior of are defined as follows. Suppose there are vertical edges (belonging to other rectangles ) completely crossing from top to bottom. Then we put into W, where is the rightmost such crossing edge. Similarly, we put into W the topmost horizontal edge completely crossing from left to right. Our data structure to find the seed set now consists of the following components.
We store the witness set W in a data structure that allows us to report the witness segments that intersect the query rectangle .
We store the vertical edges of the rectangles in in a data structure that allows us to decide if the set of edges that completely cross a query rectangle from top to bottom, is non-empty. The data structure should also be able to report all (rectangles corresponding to) the edges in .
We store the horizontal edges of the rectangles in in a data structure that allows us to decide if the set of edges that completely cross a query rectangle from left to right, is non-empty.
-
We store the set in a data structure that allows us to report the rectangles that contain a query point q.
Step 1 of the query procedure, where we compute , proceeds as follows.- Perform a query in to find all witness segments intersecting . For each reported witness segment, insert the corresponding rectangle into .
- Perform queries in and to decide if the sets and are both non-empty. If so, report all rectangles corresponding to edges in and put them into .
- For each corner point q of , perform a query in to report all rectangles in that contain q, and put them into .
The following lemma proves the correctness of our query procedure.
Lemma 1
Let be two rectangles in such that . Then at least one of is put into by the above query procedure.
Proof
Let . Each edge of I is either contributed by or , or by . Let E(I) denote the (possibly empty) set of edges of and that contribute an edge to I. We distinguish two cases, with various subcases.
Case A: At least one edge has an endpoint, v, inside . Now the witness sub-edge on e closest to v must intersect and, hence, the corresponding rectangle will be put into in Step 1(i).
Case B: All edges in E(I) cross completely. We now have several subcases.
Case B-1: . Now contributes at least three edges to I, so at least one corner of I is a corner of . Hence, both and are put into in Step 1(iii).
Case B-2: . Since each edge of E(I) crosses completely and , both and are non-empty. Thus at least one of and is put into in Step 2(ii).
Case B-3: . Let and denote the segments in E(I). If one of is vertical and the other is horizontal, we can use the argument from Case B-2. It remains to handle the case where and have the same orientation, say vertical.
Case B-3-i: Edges and belong to the same rectangle, say , as in Fig. 2. If has an endpoint, v, inside , then has a witness sub-edge starting at v that intersects , so is put into in Step 1(i). If contains a corner of then will be put into in Step 1(iii). In the remaining case the right edge of crosses and there are vertical edges completely crossing (namely and ). Hence, the rightmost edge completely crossing , which is a witness for , intersects . Thus is put into in Step 1(i).
Fig. 2.
Example of Case B-3-I
Case B-3-ii: Edge is an edge of and is an edge of (or vice versa). Assume without loss of generality that the y-coordinate of the top endpoint of is less than or equal to the y-coordinate of the top endpoint of . Then the top endpoint, v, of must lie in , and so has a witness sub-edge starting at v that intersects . Hence, is put into in Step 1(i).
In the second part of the query procedure we need to report, for each rectangle in the seed set , the rectangles intersecting . Thus we store in a data structure that can report all rectangles intersecting a query rectangle. Putting everything together we obtain the following theorem.
Theorem 1
Let be a set of n axis-aligned rectangles in . There is a data structure that uses storage and can report, for any axis-aligned query rectangle , all pairs of rectangles in such that intersects inside in time, where k denotes the number of answers.
Proof
For the data structure on the set W we use the data structure developed by Edelsbrunner et al. [13], which uses preprocessing time and storage, and has query time. For data structure (and, similarly, ) we note that a vertical segment crosses if and only if the point lies in the range . Hence, we can use the data structure of Afshani et al. [2], which uses storage and has query time. For data structure we use the point-enclosure data structure developed by Chazelle [6], which uses O(n) storage and can be used to report all rectangles in containing a query point in time.
Note that where k is the total number of reported pairs. Indeed, each rectangle in intersects at least one other rectangle inside and for every reported pair we put at most two rectangles into the seed set; the extra term “+4” is because in Step 1 (iii) we may report at most one rectangle per corner of that does not have an intersection inside . Hence, the time for Step 1 is .
It remains to analyze Step 2 of the query procedure, where we need to find for a given all such that intersects . First notice that a rectangle intersects a rectangle if and only if (i) a corner of is inside , or (ii) a corner of is inside , or (iii) an edge of intersects an edge of . Thus consists of three components: All satisfying (i) can be found in time using a range tree with fractional cascading [11], which uses storage. All satisfying (ii) and (iii) can be found using, respectively, the data structure by Chazelle [6] and the one by Edelsbrunner et al. [13]. Thus the running time of Step 2 is , where denotes the number of rectangles in that intersect inside , and so the total time for Step 2 is .
The 3-Dimensional Case
We now study the case where the set of objects and the query range are axis-aligned boxes in . We first present a solution for the general case, and then an improved solution for the special case where the input as well as the query are cubes. Both solutions use the same query strategy as above: we first find a seed set that contains at least one object from every pair that intersects inside and then we find all other objects intersecting inside .
The general case Let be a set of axis-aligned boxes. The pairs of boxes intersecting inside come in three types: (i) fully contains , (ii) lies completely inside , (iii) intersects a face of .
Type (i) is easy to handle without using seed sets: we simply store in a data structure for 3-dimensional point-enclosure queries [19], which allows us to report all boxes containing a query point in time. If we query this structure with a corner q of and report all pairs of boxes containing q then we have found all intersecting pairs of Type (i).
Lemma 2
We can find all intersecting pairs of boxes of Type (i) in time, where k is the number of such pairs, with a structure of size .
Remark
The query bound in Lemma 2 can be improved to at the cost of storage, by using the data structure of Afshani et al. [3] instead of that of Rahul [19].
For Type (ii) we proceed as follows. Note that a vertex of is either a vertex of or , or it is the intersection of an edge e of one of these two boxes and a face f of the other box. To handle the first case we create a set W of witness points, which contains for each box all its vertices that are contained in at least one other box. We store W in a data structure for 3-dimensional orthogonal range reporting [3]. In the query phase we then query this data structure with , and put all boxes corresponding to the witness vertices inside into the seed set . For the second case we show next how to find the intersecting pairs e, f where e is a vertical edge (that is, parallel to the z-axis) and f is a horizontal face (that is, parallel to the xy-plane); the intersecting pairs with other orientations can be found in a similar way.
Let E be the set of vertical edges of the boxes in and let F be the set of horizontal faces. We sort F by z-coordinate—we assume for simplicity that all z-coordinates of the faces are distinct—and partition F into clusters: the cluster contains the first faces in the sorted order, the second cluster contains the next faces, and so on. We call the range between the minimum and maximum z-coordinate in a cluster its z-range. For each cluster we store, besides its z-range and the set itself, the following information. Let be the subset of edges that intersect at least one face in , and let denote the set of points obtained by projecting the edges in onto the xy-plane. We store in a data structure for 2-dimensional orthogonal range reporting. Note that for a query box whose z-range contains the z-range of we have: an edge intersects at least one face inside if and only if and lies in , the projection of onto the xy-plane.
A query with a box is now answered as follows. We first find the clusters and whose z-range contains and , respectively, and we put (the boxes corresponding to) the faces in these clusters into the seed set . Next we perform, for each , a query with the projected range in the data structure . For each of the reported points we put the box corresponding to the edge e into the seed set . Finally, we remove any duplicates from the seed set. This leads to the following lemma.
Lemma 3
Using a data structure of size we can find in time a seed set of boxes containing at least one box from every intersecting pair of Type (ii), where k is the number of such pairs. Here is an arbitrary small, but fixed, positive constant.
Proof
The Type (ii) intersections either have a vertex that is a vertex of or inside , or they have an edge-face pair intersecting inside . To find seed objects for the former pairs we used storage and query time [3], and we put O(k) boxes into the seed set. For the latter pairs, we used an approach based on clusters. For each cluster we have a data structure , namely the 2-dimensional orthogonal range reporting structure of Chazelle [7], that uses storage, giving storage in total. Besides the boxes in the two clusters and , we put boxes into the seed set for the clusters with , namely when querying the data structures . This means that the same box may be put into up to times. (Note that these duplicates are later removed.) However, each copy we put into the seed set for some corresponds to a different intersecting pair. Together with the fact that the query time in each is this means the total query time and size of the seed set are as claimed.
It remains to handle the Type (iii) pairs, in which intersects a face of . We describe how to find the pairs such that intersects the bottom face of ; the pairs intersecting the other faces can be found in a similar way.
We first sort the z-coordinates of the horizontal faces of the boxes in . For , let be a horizontal plane containing the th horizontal face. These planes partition into horizontal slabs . We call a box short at if it has a horizontal face inside , and we call it long if it completely crosses . For each , we store the short boxes in a list. We store the projections of the long boxes onto the xy-plane in a data structure for the 2-dimensional version of the problem, namely the structure of Theorem 1.
A query with the bottom face of is now answered as follows. We first find the slab containing the face. We put all short boxes of into our seed set . We then perform a query with , the projection of onto the xy-plane, in the data structure . For each answer we get from this 2-dimensional query—that is, each pair of projections intersecting inside —we directly report the corresponding pair of long boxes. (There is no need to go through the seed set for these pairs.) This leads to the following lemma for the Type (iii) pairs.
Lemma 4
Using a data structure of size we can find in time a seed set of boxes plus a collection of pairs of boxes intersecting inside such that, for each pair of Type (iii) boxes, either at least one of these boxes is in or is a pair in .
In Step 2 of our query procedure we need to report all boxes intersecting a query box , where . Note that B intersects if (i) B contains a vertex of , or (ii) a vertex of B is contained in , or (iii) an edge e of B intersects a face of , or (iv) a face f of B intersects an edge of . We build a data structure consisting of several components to handle all of the cases.
All satisfying (i) and (ii) can be found using a 3-dimensional range reporting data structure and the 3-dimensional point-enclosure data structure of Afshani et al. [3]. Next we present the components of needed to deal with (iii) and (iv).
For (iii), assume e is parallel to the z-axis and consider the faces of parallel to the xy-plane. Then we can use a 2-level structure whose first level is a tree on the z-coordinates of the faces, and whose second-level structures are 2-dimensional point-enclosure structures [6] on the projections onto the xy-plane. Note that e intersects a face f if and only if the z-coordinate of f lies in the z-range of e, and the projection of e onto the xy-plane lies inside the projection of f onto the xy-plane. A query with an edge e is now answered as follows. We first query the first level of tree with the z-range of e to locate canonical nodes whose union covers the set of all faces whose z-coordinates lie in the queried range. We then query the associated structures of each of the selected nodes with the projection of e onto the xy-plane to report all faces that contain the point corresponding to the projected edge. Since the point-enclosure data structure uses storage and has query time, this component of needs storage and a query can be answered in time.
For (iv), we build a 2-level structure whose first level is a segment tree storing all the edges of all boxes. Each node of the first level is then associated with a 2D range tree storing the points corresponding to projections of the edges stored at the subtree rooted at onto the xy-plane. Now a query with a face f parallel to xy-plane can be answered as follows. We first query the first level of the structure with the z-coordinate of f to find a collection of canonical nodes that together contain the set of edges whose z-ranges contain the queried y-coordinate. We then query the associated structures of each of the selected nodes with the projection of f onto the xy-plane to report all edges whose corresponding projections onto the xy-plane lie inside the queried projected range. Since this component of needs storage and a query can be answered in only time we end up with the following theorem.
Theorem 2
Let be a set of n axis-aligned boxes in . Then there is a data structure that uses storage and that allows us to report, for any axis-aligned query box , all pairs of boxes in such that intersects inside in time, where k denotes the number of answers.
As observed by Rahul [20] one can prove a conditional lower bound for our 3-dimensional queries by a reduction from set intersection queries. The set intersection query problem is to preprocess m sets of positive real numbers into a data structure that supports set intersection queries asking whether or not the sets and are disjoint, for given query indices i and j. Davoodi et al. [9] make the following conjecture. Here and hide polylog-factors.
Conjecture 1
Given a collection of m sets of N real numbers in total, where the maximum cardinality of the sets in polylogarithmic in m, any real-RAM data structure that supports set intersection queries in time without using the floor function, requires storage, for .
Davoodi et al. [9] use this conjecture for a conditional lower bound for diameter queries. As observed by Rahul [20], we can also use it to prove a conditional lower bound for our problem, as described next.
Let be a collection of sets and let . We transform the sets into a set of 2N boxes in . We map each element into two boxes and as follows, letting . We set , and we set . Note that the boxes of all elements of will have the same xy-projections. Only their z-ranges are different. See Fig. 3a for an example. In addition, notice that for and with the boxes and (as well as the boxes and ) intersect each other at . Also, for and with none of the corresponding boxes of and intersect each other, since they have different z-ranges. Therefore, to verify the disjointness of and , we ask to check if there is a pair of boxes that intersect each other inside the range . See Fig. 3b for an illustration.
Fig. 3.
Left figure: the two boxes at height (resp. ) are the boxes and (resp. ) for some integer and (resp. ). Right figure: the two blue boxes are the boxes and for some integer and . The two red boxes are the boxes and for some integer with and . Either of the two red-blue intersections verifies the non-disjointness of and (Color figure online)
The above reduction implies the following result.
Theorem 3
Suppose we have a data structure storing a set of n axis-aligned boxes in that uses s(n) storage and that can decide in t(n) time for a given query axis-aligned box if there is a pair of boxes from that intersect inside . Then we can build a data structure of size s(2N) supporting set intersection queries in t(2N) time, for input sets containing N elements in total.
Now Theorem 3 along with Conjecture 1 imply the following result.
Theorem 4
Let be a set of n axis-aligned boxes in . Assuming Conjecture 1, any real-RAM data structure that can decide for a given query box in time, and without using the floor function, if there is a pair of boxes from that intersect inside , requires storage.
Fat boxes Next we obtain better bounds when the boxes in and the query box are fat, that is, when their aspect ratio—the ratio between the length of the longest edge and the length of the shortest edge—is bounded by a constant . First we consider the case of cubes.
Let be a set of n cubes in and let be the query cube. We compute a set W of witness points for each cube , as follows. Let e be an edge of , and consider the set , that is, the part of e covered by the other cubes. We put the two extreme points from S(e)—in other words, the two points closest to the endpoints of e—into W. Similarly, we assign each face f of at most four witness points, namely points from that are extreme in the axis-aligned directions parallel to f. For example, if f is parallel to the xy-plane, then we take points of maximum and minimum x-coordinate in S(f) and points of maximum and minimum y-coordinate in S(f) as witnesses. Our data structure to find the seed set now consists of the following components.
We store the set W of witness points in a data structure for 3-dimensional orthogonal range queries.
We store in a data structure that allows us to report the set of cubes that contain a query point q.
The first step of the query procedure, where we compute , now proceeds as follows.
Perform a query in to find all witness points inside . For each reported witness point, insert the corresponding cube into .
For each corner point q of , perform a query in to report all cubes in that contain q, and put them into .
The next lemma proves correctness of this procedure.
Lemma 5
Let be two cubes in such that . Then at least one of is put into by the above query procedure.
Proof
Suppose intersects , and assume without loss of generality that is not larger than . If or contains a corner q of then the corresponding cube will be put into the seed set when we perform a point-enclosure query with q, so assume and do not contain a corner. We have two cases.
Case A: does not intersect any edge of . Because and are cubes, this implies that is contained in or intersects exactly one face of . Assume that intersects the bottom face of ; the cases where intersects another face and where is contained in can be handled similarly. We claim that at least one of the vertical faces of contributes a witness point inside . To see this, observe that will intersect at least one vertical face, f, of inside , since intersects inside and is not larger than . Hence, the witness point on f with maximum z-coordinate will be inside . Thus will be put into .
Case B: intersects one edge of . (If intersects more than one edge of then it would contain a corner of .) Assume without loss of generality that intersects the bottom edge of the front face of ; see Fig. 4. Observe that if intersects the top face of then the witness point of the face with minimum x-coordinate is inside . Similarly, if intersects the back face of (the face parallel to the yz-plane and with minimum x-coordinate) then the witness point of the face with maximum z-coordinate is inside . Otherwise, as illustrated in Fig. 5, must have an edge e parallel to the y-axis that intersects inside , and one of the witness points on e will be inside —note that e lies fully inside because does not contain a corner of .
Fig. 4.
Case B in the proof of Lemma 5; is not shown
Fig. 5.
Cross-section of , , and with a plane parallel to the xz-plane. The gray area indicates in the cross-section
To handle fat boxes, we need the following observation.
Observation 1
Let b be a box of aspect ratio . Then we can cover b by cubes such that any cube in the covering intersects at most three other cubes from the covering.
To adapt the above solution to boxes of aspect ratio at most , we cover each box by cubes, and preprocess the resulting collection of cubes as described above, making sure we do not introduce witness points for pairs of cubes used in the covering of the same box . To perform a query, we cover by query cubes and compute a seed set for each query cube. We take the union of these seed sets, replace the cubes from in the seed set by the corresponding boxes in , and filter out duplicates. This gives us our seed set for the second phase of the query procedure.
In the second phase we take each and report all intersecting , using the data structure described just before Theorem 2. We obtain the following theorem.
Theorem 5
Let be a set of n axis-aligned boxes in of aspect ratio at most . Then there is a data structure that uses storage and that allows us to report, for any axis-aligned query box of aspect ratio at most , all pairs of cubes in such that intersects inside in time, where k denotes the number of answers.
Proof
The data structures and can be implemented such that they use storage in total, and have and query time, respectively [3]. Since Step 2 of the query procedure is the same as the second step of query procedure of Sect. 2.2 we can use the data structures that we designed there, which need storage and have query time. The conversion of boxes of aspect ratio to cubes give an additional factor . Each input box now has witness points, but each witness point will be reported by at most three of the query cubes, by Observation 1. Similarly, each corner of a query cube is inside at most two cubes from the covering of any box .
Objects with Small Union Complexity in
In the previous section we presented efficient solutions for the case where consists of axis-aligned rectangles. In this section we obtain results for classes of constant-complexity objects (which may have curved boundaries) with small union complexity. More precisely, we need that U(n), the maximum union complexity of any set of n objects from the class, is small. This is for instance the case for disks (where [18]) and for locally fat objects (where [5]).
In Step 2 of the query algorithm of the previous section, we performed a range query with for each . When we are dealing with arbitrary objects, this will be expensive, so we modify our query procedure.
Compute a seed set of objects such that, for any two objects in intersecting inside , both and are in . (Contrary to before, where we only required one of to be in the seed set.)
Compute all intersecting pairs of objects in the set by a plane-sweep algorithm.
Next we describe how to efficiently find , which should contain all objects intersecting at least one other object inside , when the union complexity U(n) is small. For each object we define as the union of all intersections between and all other objects in . See Fig. 6 for an illustration. Let denote the complexity (that is, number of vertices and edges) of .
Fig. 6.
An illustration of the regions for disks. Only and are shown. is shown in red, and is shown in blue (Color figure online)
Lemma 6
.
Proof
Consider the arrangement induced by the objects in . We define the level of a vertex v in this arrangement as the number of objects from that contain v in their interior. We claim that every vertex of any is a level-0 or level-1 vertex. Indeed, a level-k vertex for is in the interior of more than one object, which implies it cannot be a vertex of any .
Since the level-0 vertices are exactly the vertices of the union of , the total number of level-0 vertices is U(n). It follows from the Clarkson–Shor technique [8] that the number of level-1 vertices is O(U(n)) as well. The lemma now follows, because each level-0 or level-1 vertex contributes to at most two different ’s.
Our goal in Step 1 is to find all objects such that intersects . To this end consider the connected components of . If intersects then one of these components lies completely inside or an edge of intersects .
Lemma 7
We can find all that have a component completely inside in time, where k is the number of pairs of objects that intersect inside , with a data structure that uses storage.
Proof
For each , take an arbitrary representative point inside each component of , and store all the representative points in a structure for orthogonal range reporting. By Lemma 6 we store O(U(n)) points, and so the structure for orthogonal range reporting uses storage.
The query time is , where t is the number of representative points inside . This implies the query time is , because if has representative points inside then intersects other objects inside . This is true because the objects have constant complexity, so a single object cannot generate more than a constant number of components of .
Next we describe a data structure for reporting all intersecting a vertical edge of ; the horizontal edges of can be handled similarly. The data structure is a balanced binary tree , whose leaves are in one-to-one correspondence to the objects in . For an (internal or leaf) node in , let denote the subtree rooted at and let denote the set of objects corresponding to the leaves of . Define . At node , we store a point-location data structure [12] on the trapezoidal map of . (If the objects are curved, then the “trapezoids” may have curved top and bottom edges.)
Lemma 8
The tree uses storage and allows us to report all intersecting a vertical edge s of in time, where t is the number of answers.
Proof
To report all intersecting s we walk down , only visiting the nodes such that s intersects . This way we end up in the leaves corresponding to the intersecting s. To decide if we have to visit a child of an already visited node, we do a point location with both endpoints of s in the trapezoidal map of . Now s intersects if and only if one of these endpoints lies in a trapezoid inside and/or the two endpoints lie in different trapezoids. Thus we spend time for the decision. Since we visit nodes, the total query time is as claimed.
To analyze the storage we claim that the sum of the complexities of over all nodes at any fixed height of is O(U(n)). The bound on the storage then follows because the point-location data structures take linear space [12] and the height of is . It remains to prove the claim. Consider a node at a given height h in . Lemma 9 argues that each vertex in is either a level-0 or level-1 vertex of the arrangement induced by the objects in , or a vertex of , for some in . The proof of the claim then follows from the following two facts. First, the number of vertices of the former type is , which sums to O(U(n)) over all nodes at height h. Second, by Lemma 6 the number of vertices of the latter type over all nodes at height h sums to O(U(n)).
Lemma 9
Each vertex in is either a level-0 or level-1 vertex of the arrangement induced by the objects in , or a vertex of , for some in .
Proof
Define . Any vertex u of that is not a vertex of some must be an intersection of the boundaries of some . Note that the boundary of an object consists of two types of pieces: regular arcs, which are parts of the boundary of itself, and irregular arcs, which are parts of the boundary of some other object . To bound the number of vertices of of the form we now distinguish three cases.
Case A: Intersections between two regular arcs. In this case u is either a level-0 vertex of the arrangement defined by (namely when u is contained in no other object ), or a level-1 vertex of that arrangement (when u is contained in a single object ). Note that u cannot be contained in two objects from , because then u would be in the interior of some , contradicting that u is a vertex of . See Fig. 7a.
Fig. 7.
Different cases in the proof of Lemma 9. To simplify the presentation we assumed the objects are disks. and are surrounded by dark green and dark red, respectively. Regular arcs are in solid and irregular arcs are in dashed. The blue vertex refers to vertex u in the proof. a Case A in the Proof of Lemma 9. b Case B in the Proof of Lemma 9 (Color figure online)
Case B: Intersections between a regular arc and an irregular arc. Without loss of generality, assume that u is the intersection of a regular arc of and an irregular arc of . Note that this implies that u lies in the interior of . If there is no other object containing u then u would be a vertex of , and if there is at least one object containing u then u would not lie on . So, under the assumption that u is not already a vertex of , Case B does not happen. See Fig. 7b.
Case C: Intersections between two irregular arcs. In this case u lies in the interior of both and . But then u should also be in the interior of and , so this case cannot happen.
Putting everything together we obtain the following result.
Theorem 6
Let be a set of n constant-complexity objects in from a class of objects such that the maximum union complexity of any m objects from the class is U(m). Then there is a data structure that uses storage and that allows us to report for any axis-aligned query rectangle , in time all pairs of objects in such that intersects inside , where k denotes the number of answers.
Discussion
We presented data structures for finding intersecting pairs of objects inside a query rectangle. An obvious open problem is whether our bounds can be improved. In particular, one would hope that better solutions are possible for 3-dimensional boxes, where we obtained query time with storage. (We can reduce the query time to , for any , but at the cost of increasing the storage to .)
Two settings where we have not been able to obtain efficient solutions are when the objects are balls in , and when they are arbitrary segments in . Especially the latter case is challenging. Indeed, suppose consists of n / 2 horizontal lines and n / 2 lines of slope 1. Suppose furthermore that the query is a vertical line and that we only want to check if contains at least one intersection. A data structure for this can be used to solve the following 3Sum-hard problem: given three sets of parallel lines, decide if there is a triple intersection [14]. Thus it is unlikely that we can obtain a solution with sublinear query time and subquadratic preprocessing time. However, storage is not the same as preprocessing time. This raises the following question: is it possible to obtain sublinear query time with subquadratic storage? Another interesting question would be to see whether or not the query time in Theorem 1 can be improved to .
Acknowledgements
M. de Berg and A. D. Mehrabi were supported by the Netherlands Organization for Scientific Research (NWO) under Grants 024.002.003 and 612.001.118, respectively. J. Gudmundsson was supported by the Australian Research Council (Project Nos. FT100100755 and DP150101134). The authors also thank the anonymous reviewers for useful comments.
Footnotes
Here denotes the iterated logarithm.
Contributor Information
Mark de Berg, Email: mdberg@win.tue.nl.
Joachim Gudmundsson, Email: joachim.gudmundsson@gmail.com.
Ali D. Mehrabi, Email: amehrabi@win.tue.nl
References
- 1.Abam M, Carmi P, Farshi M, Smid M. On the power of semi-separated pair decomposition. Comput. Geom. 2013;46:631–639. doi: 10.1016/j.comgeo.2013.02.003. [DOI] [Google Scholar]
- 2.Afshani, P., Arge, L., Larsen, K.D.: Orthogonal range reporting in three and higher dimensions. In: Proceedings of IEEE Symposium, pp. 149–158 (2009)
- 3.Afshani, P., Arge, L., Larsen, K.D.: Orthogonal range reporting: query lower bounds, optimal structures in 3-d, and higher-dimensional improvements. In: Proceedings of ACM Symposium on Computational Geometry, pp. 240–246 (2010)
- 4.Agarwal PK, Erickson J. Geometric range searching and its relatives. Contemp. Math. 1999;223:1–56. doi: 10.1090/conm/223/03131. [DOI] [Google Scholar]
- 5.Aronov B, de Berg M, Ezra E, Sharir M. Improved bounds for the union of locally fat objects in the plane. SIAM J. Comput. 2014;43(2):543–572. doi: 10.1137/120891241. [DOI] [Google Scholar]
- 6.Chazelle B. Filtering search: a new approach to query-answering. SIAM J. Comput. 1986;15(3):703–724. doi: 10.1137/0215051. [DOI] [Google Scholar]
- 7.Chazelle B. A functional approach to data structures and its use in multidimensional searching. SIAM J. Comput. 1988;17:427–462. doi: 10.1137/0217026. [DOI] [Google Scholar]
- 8.Clarkson KL, Shor PW. Applications of random sampling in computational geometry. II. Discrete Comput. Geom. 1989;4:387–421. doi: 10.1007/BF02187740. [DOI] [Google Scholar]
- 9.Davoodi, P., Smid, M., van Walderveen, F.: Two-dimensional range diameter queries. In: Proceedings of Latin American Symposium on Theoretical Informatics, pp. 219-230 (2012)
- 10.Das AS, Gupta P, Srinathan K. Data structures for extension violations in a query range. J. Math. Model. Algorithms. 2011;10(1):79–107. doi: 10.1007/s10852-010-9144-y. [DOI] [Google Scholar]
- 11.de Berg M, Cheong O, van Kreveld M, Overmars M. Computational Geometry: Algorithms and Applications. 3. Berlin: Springer; 2008. [Google Scholar]
- 12.Edelsbrunner H, Guibas LJ, Stolfi J. Optimal point location in a monotone subdivision. SIAM J. Comput. 1986;15:317–340. doi: 10.1137/0215023. [DOI] [Google Scholar]
- 13.Edelsbrunner H, Overmars MH, Seidel R. Some methods of computational geometry applied to computer graphics. Comput. Vis. Graphics Image Proc. 1984;28:92–108. doi: 10.1016/0734-189X(84)90142-7. [DOI] [Google Scholar]
- 14.Gajentaan A, Overmars MH. On a class of problems in computational geometry. Comput. Geom. Theory Appl. 1995;5:165–185. doi: 10.1016/0925-7721(95)00022-2. [DOI] [Google Scholar]
- 15.Goodman, J.E., O’Rourke, J.: Range searching. In: Handbook of Discrete and Computational Geometry, Chapter 36, 2nd edn (2004)
- 16.Gupta P. Range-aggregate query problems involving geometric aggregation operations. Nord. J. Comput. 2006;13(4):294–308. [Google Scholar]
- 17.Gupta P, Janardan R, Kumar Y, Smid M. Data structures for range-aggregate extent queries. Comput. Geom. Theory Appl. 2014;47:329–347. doi: 10.1016/j.comgeo.2009.08.001. [DOI] [Google Scholar]
- 18.Keden K, Livne R, Pach J, Sharir M. On the union of Jordan regions and collision-free translational motion amidst polygonal obstacles. Discr. Comput. Geom. 1986;1:59–71. doi: 10.1007/BF02187683. [DOI] [Google Scholar]
- 19.Rahul, S.: Improved bounds for orthogonal point enclosure query and point location in orthogonal subdivisions in . In: ACM-SIAM Symposium on Discrete Algorithms, pp. 200–211 (2015)
- 20.Rahul, S.: Personal communication
- 21.Rahul, S., Das, A.S., Rajan, K.S., Srinatan, K.: Range-aggregate queries involving geometric aggregation operations. In: Workshop on Algorithms and Computation, vol. 1, pp. 122–133 (2011)







