Counting Unit Circular Arc Intersections
Abstract
Given a set of circular arcs of the same radius in the plane, we consider the problem of computing the number of intersections among the arcs. The problem was studied before and the previously best algorithm solves the problem in time [Agarwal, Pellegrini, and Sharir, SIAM J. Comput., 1993], for any constant . No progress has been made on the problem for more than 30 years. We present a new algorithm of time and improve it to time for small , where is the number of intersections of all arcs.
Keywords and phrases:
circular arc intersections, unit circles, arrangements, cuttings, segment intersections2012 ACM Subject Classification:
Theory of computation Computational geometry ; Theory of computation Design and analysis of algorithmsEditors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Given a set of circular arcs of the same radius in the plane, we consider the problem of computing the number of intersections among the arcs; here we count the number of intersecting points (i.e., if two arcs intersect at two points, then they are counted twice). Agarwal, Pellegrini, and Sharir [3] previously solved the problem in time; throughout the paper, we let denote an arbitrarily small positive constant. On the negative side, Erickson’s results [11] show that is a lower bound for the problem in a so-called partition algorithm model. No progress has been made on the problem for more than 30 years. In this paper, we present a new algorithm of time and thus improve the previous result in [3]. Although the improvement looks minor, a factor of , it is significant from the following perspective: it reduces the gap between the upper and lower bounds from to , where is a polynomial function. Further, for small , where is the number of intersections of all arcs, we improve the algorithm to time. Note that this matches the above complexity in the worst case when . If for any , then the time complexity is .
In addition, our results can be used to solve the following bichromatic problem (with the same time complexity): Given a set of red circular arcs and another set of blue circular arcs such that all arcs (of both colors) have the same radius, compute the number of red-blue intersections.
Related work.
If the circular arcs have different radii, Agarwal, Pellegrini, and Sharir [3] gave an time algorithm to compute the number of intersections of all arcs.
For computing the number of intersections among a set of circles of the same radius, Katz and Sharir [13] gave an algorithm of time and the randomized algorithm of Agarwal, Aronov, Sharir, and Suri [2] can solve it in expected time. Recently, Wang [16] derived an time algorithm for it, matching the lower bound [11]. If the circles have different radii, then the problem is solvable in time [3]. Recently, Chan, Cheng, and Zheng [7] extended the result and gave an -time algorithm to compute the number of intersections among a set of algebraic arcs of constance description complexity in the plane.
The case where all arcs are line segments has been extensively studied. First of all, Erickson’s -time lower bound [11] still applies. On the positive side, Chazelle [9] gave an time algorithm for the problem. Guibas, Overmars, and Sharir [12] developed a randomized algorithm of expected time. Agarwal [1] solved the problem in time and Chazelle [10] further improved the algorithm to time. For small , where is the number of all segment intersections, Pellegrini [15] gave an algorithm of time. De Berg and Schwarzkopf [6] presented a randomized algorithm of expected time. Recently, Chan and Zheng [8] solved the problem in time, matching the lower bound [11].
With Chan and Zheng’s new result [8] and our techniques, we can show that the segment case problem is solvable in time, or in expected time with the randomized techniques of de Berg and Schwarzkopf [6].
One essential difference between the segment case and the circular arc case is that two segments have at most one intersection while two circular arcs may have two intersections. This difference makes the technique of Chan and Zheng’s new result [8] not applicable to the arc case. Indeed, this difference also makes the circular arc case more challenging.
In addition to a polynomial-time improvement over the 30-year old previous work [3] on a fundamental problem, our contribution also lies on many new geometric observations and techniques on the unit circular arcs. These new techniques may find applications in solving other related problems on unit circular arcs as well.
Outline.
After introducing some concepts in Section 2, we present our algorithm in Section 3 for computing the number of intersections among circular arcs. Section 4 concludes and also demonstrates that our techniques may be extended to solve other variations, such as the bichromatic version and the segment case. Due to the space limit, some proofs are omitted but can be found in the full paper.
2 Preliminaries
We introduce some notation that will be used later. For two points and in the plane, we use to denote the segment with endpoints and ; we call the defining segment of (resp., ). For any compact region in the plane, we use to denote the boundary of .
Cuttings.
Let be a set of lines in the plane. For a compact region in the plane, we use to denote the subset of lines of that intersect the interior of (we also say that these lines cross ). A cutting is a collection of closed cells (each of which is a triangle) with disjoint interiors, which together cover the entire plane [10, 14]. The size of is the number of cells in . For a parameter with , a -cutting for is a cutting satisfying for every cell .
We say that a cutting -refines a cutting if every cell of is contained in a single cell of and each cell of contains at most cells of . Let be a sequence of cuttings for such that is the entire plane, and every is a -cutting of size which -refines , for two constants and . To make a -cutting, we set . The above sequence of cuttings is called a hierarchical -cutting for . If a cell contains a cell , we say that is the parent of and is a child of .
For any , a hierarchical -cutting of size for (together with the sets for every cell of for all ) can be computed in time [10]. Note that this implies that the total size of for all cells , , is .
As indicated by Agarwal and Sharir [4], similar results on cuttings for other more general curves in the plane (e.g., circles or circular arcs of different radii, pseudo-lines, line segments) can also be obtained by extending Chazelle’s algorithm [10]; Wang [16] provided algorithm details for that. For our purpose, if is a set of circular arcs (not necessarily with the same radius) in the plane, then we can also define cuttings for in the same way as above. A difference is that a cell of a cutting becomes a pseudo-trapezoid (more specifically, each pseudo-trapezoid in general has four sides, with the left/right side as a vertical line segment and the top/bottom side as part of an input circular arc; e.g., see Fig. 1). The following result, which will be used later, has been obtained in [16].
Theorem 1 ([16]).
Suppose is a set of circular arcs (or line segments) in the plane and is the number of intersections of the arcs of . For any , a hierarchical -cutting of size for (together with the subsets for every cell of for all ) can be computed in time; more specifically, the size of the cutting is and the runtime of the algorithm is , for any .
Cuttings are one of our main tools. Although cuttings is a standard technique, the novelty of our approach lies in how to combine cuttings with the newly discovered geometric observations and techniques on unit circular arcs.
3 The algorithm
We present an -time algorithm for computing the number of intersections of circular arcs of the same radius in the plane. At the very end of this section, we reduce the time to , where is the number of intersections of all arcs.
Let be a set of circular arcs of the same radius in the plane. Without loss of generality, we assume that the radius is , and each arc is thus a unit circular arc. Our goal is to compute the number of intersections of all arcs of . In the following, unless otherwise stated, a circular arc refers to a unit circular arc.
We call a disk a unit disk if its radius is ; the boundary of a unit disk is a unit circle. For each arc , the circle that contains it is called its underlying circle (the disk bounded by the circle is called the underlying disk), and the center of the circle is also called the center of . We use and to denote the underlying circle and disk of , respectively. Let denote the set of the centers of the arcs of . For any region in the plane, let denote the subset of points of in , i.e., .
With respect to , Wang [16] gave an algorithm to compute a set of axis-parallel square cells in the plane whose interiors are pairwise disjoint and whose union covers all the points of , with the following properties: (1) Each cell has side length . (2) Every two cells are separated by an axis-parallel line. (3) For a unit disk with center , if is not in any cell of , then . (4) Each cell of is associated with a subset of cells of , such that for any disk with center in , every point of is in one of the cells of ; e.g., see Fig. 2. (5) Each cell of is in for a constant number of cells . In addition to , Wang’s algorithm [16] also computes the subsets and for all cells , in a total of time and space. Using the properties of , we can obtain the following lemma.
Lemma 2.
(1) Each arc of is covered by the union of all cells of . (2) If an arc intersects , then the center of must be in one of the cells of . (3) Each arc of only intersects a constant number of cells of . (4) .
Proof.
To prove the first lemma statement, it suffices to show that for any point of an arc of , must be in a cell of . Assume to the contrary this is not the case for a point of an arc . Then, by property (3) of , . However, this is not true since contains the center of , which is in . We thus obtain contradiction.
For the second lemma statement, consider a point in a cell and is also on a segment . Let be the center of . Since contains , by the property (4) of , must be in one of the cells of .
For the third lemma statement, consider an arc whose center is in a cell . If intersects a cell , then by the second lemma statement, must be in . According to the property (5) of , each cell of is in for a constant number of cells . This implies that only intersects a constant number of cells of .
The fourth lemma statement simply follows the property (5) of .
For each cell , we use to denote the set of arcs of whose centers are in .
With Lemma 2, we will compute the number of intersections of the arcs of inside each cell of and then add these numbers together. In what follows, we focus on one such cell . Our goal is to compute the number of intersections of the arcs of inside . By Lemma 2, we only need to consider the arcs in for all . To this end, for each pair of cells of , including the case where , we will compute the number of intersections inside between the arcs of and the arcs of ; the sum of these numbers is the number of intersections inside among all arcs of . In the following, we discuss our algorithm for such a pair .
We assume that and are two different cells since the other case can be solved by the same techniques. Let , . Since we are interested in the intersections inside , for each arc , we only keep its portions inside . As the radius of is and is an axis-parallel square of side length , has at most two (maximal) sub-arcs in . Let denote the set of these sub-arcs of . Thus, . Our goal is to compute the number of intersections between the arcs of and the arcs of .
3.1 Counting intersections between and : Algorithm overview
To simplify the notation, we temporarily let and . For each arc , by definition, is inside ; we extend both endpoints of along the underlying circle of until , and we refer to the new arc as the extending arc of . Let denote the set of all extending arcs of . Note that every two arcs of intersect at most twice.
We will start with computing a cutting of and then solve a pseudo-trapezoid-restricted subproblem in each cell of the cutting. Below we first describe our algorithm for solving the restricted subproblem. Consider a pseudo-trapezoid of the cutting, which is in . Let be the set of arcs of intersecting and let . Let and . The goal of the restricted subproblem is to compute the number of intersections between the arcs of and inside . If we color the arcs of red and color those of blue, then we essentially have a bichromatic arc intersection problem: compute the number of intersections between red arcs and blue arcs.
We say that an arc is a short arc if it has at least one endpoint in the interior of . Otherwise, is a long arc. Because the radius of is , is a pseudo-trapezoid inside (and the radii of the circular arcs on the boundary of are also ), and a square cell of side-length , the intersection of and consists of at most two (maximal) sub-arcs. Since we are only interested in intersections inside , for each arc , we trim it and only keep its portion (possibly two sub-arcs) inside . If has two trimmed sub-arcs in , then both sub-arcs are treated as independent arcs, which are considered as long (resp., short) arcs if is a long (resp., short) arc. A useful property of long arcs is that each long arc has both endpoints on . To simplify the notation, we still use to denote the set of all trimmed arcs in and use to denote the size of . Let denote the number of short arcs of .
The arc intersections we are interested in can be classified into four types: (1) long-red and long-blue intersections (i.e., intersections between long red arcs and long blue arcs), (2) short-red and short-blue intersections, (3) long-red and short-blue intersections, and (4) short-red and long-blue intersections. For counting type (2) intersections, we use the algorithm of [3], which runs in time. We will give an -time algorithm for counting type (3) intersections in Section 3.2, and type (4) intersections can be counted in a similar way. Counting type (1) intersections is discussed in Section 3.3.
3.2 Counting type (3) intersections
We describe an algorithm to compute the number of type (3) intersections in time. To this end, we further partition type (3) intersections into two sub-types: (3.1) a pair of a long red arc and a short blue arc that intersect only once; (3.2) a pair of a long red arc and a short blue arc that intersect twice. We first describe an algorithm to count type (3.1) intersections in time.
3.2.1 Counting type (3.1) intersections
For any long arc , the intersection of its underlying circle and consists of at most two arcs (one of which is ). If the intersection is only one arc, which is , then we call a full arc; otherwise it is a partial arc. We further partition type (3.1) intersections into two sub-types: (3.1.1) a pair of a long red full arc and a short blue arc that intersect only once; (3.1.2) a pair of a long red partial arc and a short blue arc that intersect only once. Below, we first describe an algorithm to compute the number of type (3.1.1) intersections. The algorithm for type (3.1.2) is more complicated.
Counting type (3.1.1) intersections.
Consider a short blue arc . Let and be the two unit disks centered at the two endpoints of , respectively. We call the region of that is not in a lune; similarly, region of that is not in is also a lune. We use refer to the union of the two lunes (for simplicity, we consider as a single lune defined by ), i.e., , the symmetric difference of and (e.g., the grey area in Fig. 3). By definition, a point is in if and only if the unit disk centered at the point contains exactly one endpoint of , implying that the unit circle centered at the point intersects exactly once. Observation 3 is crucial to our algorithm for counting type (3.1.1) intersections in Lemma 4.
Observation 3.
For a short blue arc and a long red full arc , intersects exactly once if and only if the center of lies in ; e.g., see Fig. 3.
Proof.
Let be the center of and be the underlying disk of .
If intersects exactly once, then one endpoint of must be inside while the other is outside . Therefore, must be in . Below we prove the other direction of the observation.
If is in , then by the definition of , one endpoint of is in while the other is not. Hence, must cross at exactly one point, say, , which is the only intersection between and . As is in the cell , . Since , we obtain that . Further, since is a long full arc, we have . Hence, . This implies that . Since and and has exactly one intersection, we conclude that and has exactly one intersection.
Lemma 4.
Counting type (3.1.1) intersections takes time.
Proof.
For notational convenience, let and in this proof. Recall that centers of red arcs are in the cell . For each short blue arc , since the radius of is and is a square cell of the side-length , the boundary of the intersection of and has at most four circular arcs (which are on the unit circles centered at the two endpoints of , respectively); let be the set of these circular arcs defined by all short blue arcs. Hence, . By Observation 3, it suffices to compute the number of lunes containing the center of each long red arc. Let denote the set of the lunes of all short blue arcs .
We build a hierarchical -cutting on the arcs of , with . This can be done in time by Theorem 1. For each cell , , we define as the number of lunes of that contain but do not contain the parent cell of in (i.e., the boundary of the lune crosses the parent cell). We can compute for all cells , for all , as follows.
Recall that the algorithm of Theorem 1 for computing the hierarchical cutting also produces the sets for all cells , , where is the subset of arcs of crossing , in time. As discussed in Section 2, the total size of these sets for all cells is .
Next, we show that the values for all cells , can be computed in time using the sets . Define as the subset of lunes of that contain but does not contain the parent cell of . Hence, . Observe that one of the bounding arcs of each lune of must cross , where is the parent of in . This implies that we can compute and thus using as follows. For each arc , we check whether the lune of bounded by contains ; if yes, we add the lune to . Since each cell of the hierarchical cutting has child cells, the above algorithm for computing for all cells , , runs in time linear in the total size of for all cells , , which is as explained above. As such, after the hierarchical cutting is computed, for all cells , , can be computed in time.
For each long red arc , we locate the cell of containing for each , where is the center of ; we add all these values to a total count (initially, ). Finally, for the cell , for each arc , we check whether the lune of bounded by contains ; if yes, we increases by one. It is not difficult to see the value thus obtained is equal to the number of lunes of containing . Since for any and , the time of the above algorithm for computing is . We apply the above algorithm for each long red arc, after which the number of type (3.1.1) intersections is computed. As there are at most long red arcs, the total time of the algorithm is , which is as .
Counting type (3.1.2) intersections.
We now discuss type (3.1.2) intersections. Consider a long red partial arc . Recall that the center of is in the square cell . By property (2) of , the two cells and are separated by an axis-parallel line. Depending on whether the line is horizontal or vertical, without loss of generality, we assume that is either below or to the right of . Recall that the pseudo-trapezoid is in , and typically the upper (resp., lower) side of is a unit circular arc while both the left and right sides of are vertical segments. Since is a partial arc, the underlying circle intersects at another arc, denoted by ; we call the coupled arc of (and is also the coupled arc of ).
Consider a type (3.1.2) intersection between a long red partial arc and a short blue arc . We further partition type (3.1.2) intersections into two types: (3.1.2.1) does not intersect the coupled arc of ; (3.1.2.2) intersects (since and are on the same circle and intersects , intersects exactly once in this case). We will present algorithms to count type (3.1.2.1) and type (3.1.2.2) intersections separately.
For each short-blue arc , we use to denote the region of the plane outside the union of the two unit disks centered at the two endpoints of .
Recall that is either below or to the right of . Below we give observations for both cases, which lead to algorithms for counting type (3.1.2.1) and type (3.1.2.2) intersections.
Suppose is below . Then, and are both on the upper semicircle of (e.g., see Fig. 4). Thus, both and are -monotone, and is either to the left or to the right of . Let denote the endpoint of closer to , e.g., is the right (resp., left) endpoint of if is to the left (resp., right) of . We have the following observation for type (3.1.2.1) and type (3.1.2.2) intersections. See the full paper for the proof.
Observation 5.
Let be a long red partial arc and a short blue arc. Suppose is below .
-
1.
and form a type (3.1.2.1) intersection (i.e., and intersect exactly once and does not intersect ) if and only if the following two conditions hold: (1) the center of lies in ; (2) the endpoint of not in the disk is to the left (resp., right) of if is to the left (resp., right) of . See Fig. 4 (top).
-
2.
and form a type (3.1.2.2) intersection (i.e., and intersect exactly once and intersects ) if and only if the following two conditions hold: (1) the center of lies in ; (2) one endpoint of is left of while the other endpoint is right of . See Fig. 4 (bottom).
If is to the right of , and are both in the left semicircle of ; e.g., see Fig. 5. Thus, both and are -monotone, and is either above or below . Let denote the endpoint of closer to , e.g., is upper (resp., lower) endpoint of if is below (resp., above) . We have the following observation, which is similar in spirit to Observation 5.
Observation 6.
Let be a long-red partial arc and a short-blue arc. Suppose is right of .
-
1.
and form a type (3.1.2.1) intersection if and only if the following two conditions hold: (1) the center of lies in ; (2) the endpoint of not in the disk is below (resp., above) if is below (resp., above) . See Fig. 5 (left).
-
2.
and form a type (3.1.2.2) intersection if and only if the following two conditions hold: (1) the center of lies in ; (2) one endpoint of is above while the other endpoint is below . See Fig. 5 (right).
Based on Observations 5 and 6, Lemmas 7 and 8 below compute the numbers of type (3.1.2.1) and type (3.1.2.2) intersections, respectively. Hence, the number of type (3.1.2) intersections can be computed in time.
Lemma 7.
Counting type (3.1.2.1) intersections takes time.
Proof.
We assume that is below and the other case where is right of can be handled similarly. Our algorithm will be based on Observation 5(1). The algorithm is similar to Lemma 4 but with an additional level data structure. In what follows, we follow the notation in the proof of Lemma 4 and only point out the differences. For notational convenience, we let and in this proof.
We follow the same algorithm as in Lemma 4 but set . Recall that for each cell , , we have defined a subset consisting of the lunes of that contain but do not contain the parent cell of in . The total size of all these subsets is . For each subset , for each , since contains , all unit disks centered in contain exactly the same endpoint of and let denote the other endpoint; we use to denote set of all these endpoints for all . Note that . We explicitly maintain . Computing these subsets for all cells can be done in time by using the sets . We further sort each set by their -coordinates. As the total size of for all cells is , the sorting for of all cells can be done in time.
For each long red arc , we first check whether it is a partial arc (this can be done in time). If not, we ignore it. If yes, we proceed as follows. Without loss of generality, we assume that is to the left of and thus is the right endpoint of . Let be the center of . We locate the cell of containing for each . For each , according to Observation 5(1), we perform binary search on the sorted list of to find the number of points of to the left of , and let denote this number. We add all these values to a total count (initially, ). Finally, for the cell , for each arc , we do the following. Note that is an arc of for a short blue arc . We check in time whether and form a type (3.1.2.1) intersection; if yes, we increase by one. The value thus obtained is equal to the number of type (3.1.2.1) intersections involving . The time for computing is . We apply the above algorithm for each long red arc, after which the number of type (3.1.2.1) intersections is computed. The total runtime is , which is as .
Lemma 8.
Counting type (3.1.2.2) intersections takes time.
Proof.
We assume that is below and the other case where is right of can be handled similarly. Our algorithm will be based on Observation 5(2). For notational convenience, let and in this proof.
We still follow the algorithm in the Lemma 4 but set and use to replace . Note that the intersection of and is still bounded by at most two circular arcs (other than the boundary of ). Let be the set of all these circular arcs for all short blue arcs. Let denote the set of of all short blue arcs . Next, we build a hierarchical cutting for in the same way as in the proof of Lemma 4. We define in the same way. Let denote the set of short blue arcs with . Using , we can obtain for all cells , , in time. For each arc , it defines an interval , where and are the -coordinates of the left and right endpoints of , respectively; let denote the set of all these intervals for all arcs of . We build an interval tree (Section 10.1 [5]) on the intervals of in time so that given a query -coordinate , we find in time the number of intervals of containing . As and the total size of the sets ’s of all cells in the cutting is , the total time for building the interval trees is .
For each long red arc , we first check whether it is a partial arc (this can be done in time). If not, we ignore it. If yes, we proceed as follows. Without loss of generality, we assume that is to the left of and thus is the right endpoint of . Let be the center of . We locate the cell of containing for each . For each , we query the interval tree of to find number of intervals of containing ; let denote this number. We add all these values to a total count (initially, ). Finally, for the cell , for each arc , we do the following. Let be the short-blue arc such that is an arc of . We check whether and form a type (3.1.2.1) intersection, which can be done in time; if yes, we increases by one. The value thus obtained is equal to the number of type (3.1.2.2) intersections involving . The time for computing is . We apply the above algorithm for each long red arc, after which the number of type (3.1.2.2) intersections is computed. The total time of the algorithm is , which is as .
3.2.2 Counting type (3.2) intersections
We now compute the number of type (3.2) intersections. The runtime of the algorithm is . Our goal is to compute the number of pairs of a long red arc and a short blue arc such that and intersect twice.
Let be either a blue short arc or a long red arc. Since the radius of is , is contained in , which is in , and is a square cell of side-length , does not span more than a semicircle of the underlying circle of . The two lines through the center of and its two endpoints partition the plane into four wedges, one of which contains completely (we use to denote the wedge; e.g., see Fig. 6). Observation 9 is crucial to our algorithm in Lemma 10 for counting type (3.2) intersections. See the full paper for the proof.
Observation 9.
Consider a short blue arc and a long red arc . If and intersect twice, then the following four conditions must hold (e.g., see Fig. 7): (1) the center of is in the wedge ; (2) the center of is in the wedge ; (3) the underlying disk of does not contain either endpoint of ; (4) the underlying circles and intersect. On the other hand, if the above four conditions all hold, then exactly one of the following two cases must happen: (1) and intersect twice; (2) is a partial arc and intersects both and its coupled arc .
Notice that in the second case of Observation 9 and form a type (3.1.2.2) intersection. Thus, if is the number of pairs of a long red arc and a short blue arc that intersect twice, then , where is the number of pairs that satisfy the four conditions in Observation 9 and is the number of type (3.1.2.2) intersections. We have already computed in Lemma 8. It remains to compute , which is done in Lemma 10.
Lemma 10.
Counting type (3.2) intersections takes time.
Proof.
We first apply Lemma 8 and compute in time. As discussed before, it suffices to compute , i.e., the number of pairs that satisfy the four conditions in Observation 9. We show below that can be computed in time. For notational convenience, we let and in this proof.
Let denote the set of short blue arcs and let be the set of long red arcs of . For each short blue arc , define as the common intersection of the wedge and . Note that the underlying disk of a long-red arc does not contain either endpoint of a short-blue arc if and only if the center of is in . Hence, the first two conditions of Observation 9 are satisfied if and only if the center of is in .
Recall that centers of all red arcs are in the square cell . Let . Note that other than those on , consists of at most two line segments and at most two circular arcs; we use general-arcs to refer to these arcs and segments (a segment can be considered as a circular arc of infinite radius). Hence, has at most four general-arcs. We call the interesting region of . Let denote the set of interesting regions of all arcs of . Let denote the set of general-arcs of all regions of . Hence, .
We compute a hierarchical -cutting on the general-arcs of , with and a constant ratio as described in Section 2. This can be done in time by Theorem 1. For each cell , , we define a canonical pair , with and , so that centers of all arcs of lie in the interesting region of each short blue arc of . Specifically, consists of all long red arcs whose centers are located in the cell and consists of the arcs of whose interesting regions contain but do not contain the parent cell of in . The canonical pairs of all cells of all cuttings , , can be computed in time, as follows.
For the center of each long red arc , we locate the cell of containing , for all , and add to , which can be done in time. As such, computing the canonical sets for all cells takes time in total. For computing , we can use an algorithm similar to the one in Lemma 4 (i.e., replacing by the interesting region ). More specifically, for each child cell of a cell in , for each general-arc of (i.e., the set of general-arcs of crossing ), suppose it is a general-arc of of a blue arc . We check whether contains ; if yes, we add to . In this way, computing all canonical subsets takes time proportional to the total size of the subsets for all cells of all cuttings , , which is .
By the definition of canonical subset pairs , to compute , it suffices to compute the number of pairs of arcs such that , , intersects , and the center of is in , for all cells , . Below we describe an algorithm of time for one such cell , where and .
Recall that all centers of red arcs are in the square cell . Define as the set of disks of radius centered at the centers of all blue arcs of . Let be the set of all centers of the arcs of ; if is the center of an arc , we use to refer to . It is not difficult to see that the problem is equivalent to computing the number of pairs , , , such that is contained in and the center of is in . To solve the problem, we use an algorithm similar to that for Lemma 4, with an additional level of range searching data structure for handling the constraint that the center of is in . We briefly discuss it below. Note that and .
For each disk , the intersection of and consists of at most two circular arcs. Let denote the set of circular arcs for all disks . We build a hierarchical -cutting for , with and a constant ratio , in time [10]. For each cell , for all , define as the set of disks of that contain but do not contain the parent cell of in . We can compute explicitly for all cells of in time. We further build a range searching data structure on the centers of for answering the following queries: Given a query wedge, compute the number of disk centers in the wedge. For this, we use a data structure of Matoušek’s [14] (i.e., Lemma 6.1 [14] by setting ), which takes preprocessing time for any and can answer each query in time. In addition, for each cell , we explicitly store the subset of arcs of crossing .
All above can be done in time except that for building the wedge range searching data structures. We now analyze the total time for constructing these wedge range searching data structures. For each cell , it holds that . Since has cells, the total time for constructing the data structures is big-O of , which is bounded by as is a constant.
For each point , we locate the cell of containing for each ; using the wedge range searching data structure on the centers of , we find the number of centers of disks of contained in the wedge . We add all these values to a total count (initially, ). Finally, for the cell , for each arc , we check whether the underlying disk of contains and the center of is in ; if yes, we increases by one. The value thus obtained is equal to the number of disks of that contain and whose centers are in . The time for computing is as for any cell . The sum is equal to the number of pairs , , , such that is contained in and the center of is in . As , the total time of the algorithm is , which is for .
The above shows that processing each canonical subset pair for a cell takes time, with and . Processing all cells for all will compute the number . We now analyze the total time. For each , and , where is the parent cell of in . Since , we have . Because has cells, the total time for processing all cells in is on the order of , which is bounded by as is a constant. Since and , the total time for processing all cells for all is .
3.2.3 Counting type (3) intersections: a final step
The above shows that the number of type (3) intersections can be computed in time. Using the result, we finally show that an alternative algorithm can compute the number of type (3) intersections in time.
If , then and thus the runtime of the above algorithm is . Otherwise, we partition the short blue arcs into groups of size , with . For each group, we apply the above algorithm on the group with all long-red arcs. The total time is , which is . As such, the number of type (3) intersections can be computed in time.
3.3 Counting type (1) intersections
Before giving our algorithm for counting the type (1) intersections, we analyze the total time for counting all intersections of other types in our original problem. Recall that initially we build a hierarchical -cutting on the arcs of with . For each cell of , we have the pseudo-trapezoid-restricted subproblem of counting the intersections of arcs of inside , with and as the number of short arcs of . By the definition of short and long arcs, we have and . By setting , we obtain the following lemma.
Lemma 11.
By setting , the total time for computing the number of type (2), (3), and (4) intersections for all cells is bounded by .
Proof.
To solve the pseudo-trapezoid-restricted subproblem on each cell , we have shown above that counting type (2) intersections can be done in time and counting types (3) and (4) intersections takes time. Therefore, the total time for counting type (2) intersections for all cells is . Since has cells, , and , achieves the maximum when ’s have value , i.e., , which is . Hence, the total time for counting type (2) intersections is .
The total time for counting types (3) and (4) intersections is . Since has cells and , we have , which is . Since , we can now derive .
As such, the total time for computing the number of intersections of types (2-4) is . Setting makes the time bounded by .
We now discuss how to compute the number of type (1) intersections, i.e., intersections between long red arcs and long blue arcs. If we consider each individual cell of the cutting as above, it would be difficult to achieve a satisfying time bound because each long arc may intersect many cells. Instead, we will count these intersections using the cuttings in the hierarchy. For each cell for any , we define long and short arcs of in the same way as before (i.e., suppose an arc intersects the interior of ; then is a long arc of if does not have either endpoint in the interior of and is a short arc of otherwise). For a long arc of , we say that is a long-long arc if and is also a long arc of , where is the parent cell of in , and is a short-long arc otherwise. A critical observation is that for a long arc of any cell , must be a short-long arc of exactly one ancestor cell of since any arc must be a short arc of the only cell of , which is the entire square cell .
Recall that a type (1) intersection refers to an intersection in a cell between a long red arc of and a long blue arc of . Consider a type (1) intersection in a cell between a long red arc and a long blue arc . Observe that has one and only one ancestor cell such that both and are long arcs of but at least one of them is a short-long arc of (also note that since is an ancestor cell of , contains and thus contains ). This means that in order to count type (1) intersections, we can count, for all cells , , the type (1) intersections in involving at least one short-long arc, and more precisely, we can count the following three types of intersections: (1.1) intersections between long-long red arcs of and short-long blue arcs of ; (1.2) intersections between long-long blue arcs of and short-long red arcs of ; (1.3) intersections between short-long blue arcs and short-long red arcs of .
Consider a cell , for any . Let be the set of all long red arcs of and the set of all long blue arcs of . Let and be the subsets of long-long and short-long arcs of in , respectively. Let and be the subsets of long-long and short-long arcs of in , respectively. Let and . As such, the above three types of intersections are: (1.1) intersections between arcs of and , (1.2) intersections between arcs of and , and (1.3) intersections between arcs of and .
To compute the number of type (1.1) intersections, one could apply the algorithm in Section 3.2. However, the total time of the overall algorithm for all cells of , , cannot be bounded by since now we need to consider the cells in all cuttings , , not just the last cutting as before. Instead, we present a new algorithm in Lemma 12 (see the full paper for the proof). Type (1.2) intersections can be handled similarly as it is symmetric to type (1.1). For type (1.3), we actually also apply Lemma 12 because the algorithm works for any two sets of long arcs of , and the running time is also bounded as stated in Lemma 12 due to .
Lemma 12.
There exists an algorithm of time to compute the number of type (1.1) intersections.
Using Lemma 12, the following lemma analyzes the total time of our algorithm for computing the number of type (1) intersections.
Lemma 13.
Counting type (1) intersections takes time.
Proof.
As discussed before, the number of type (1.1) intersections can be computed once the subproblems stated in Lemma 12 are solved for all cells , . We next analyze the total time for solving these subproblems. We follow the notation as defined before. Note that and has cells.
We first claim that for all . Indeed, it is obviously true that for . We assume that . Consider a short-long arc of . By definition, is a short arc of the parent cell of , implying that has at least one endpoint in the interior of . Let and be the two cells of that contain the two endpoints of , respectively ( is possible). According to the above discussion, if is short-long arc of for some cell , then must be a child cell of either or . As has cells in , for , can be a short-long arc of at most cells . As such, holds.
We now consider the three terms in the time complexity of Lemma 12 separately.
-
1.
For the first term, , for and .
-
2.
For the second term, we have , which is bounded by as .
-
3.
For the third term, is big-O of . As and has cells, by Hölder’s Inequality, . As such, we can obtain that is big-O of , which is bounded by as is a constant. Hence , for and .
Therefore, the total time for solving the subproblems for all cells for all is , which is as . Hence, the number of type (1.1) intersections can be computed in time bounded by .
As discussed before, Lemma 12 is also applicable to counting type (1.2) and type (1.3) intersections with asymptotically the same time complexity. As such, the total number of type (1) intersections can be computed in time.
3.4 Putting it all together
The above solves the problem of computing the number of intersections in the square cell between the arcs of and the arcs of . The time of the algorithm is , where and . The algorithm is based on the assumption that . If , then the problem becomes computing the intersections in among all arcs of . Our algorithm can be easily adapted to this case. For example, we can duplicate all arcs of and make the duplications as , and then apply the algorithm (one subtle issue that in this case an arc of and its duplication in should not be considered intersected).
Enumerating all pairs of and solving the problem as above can compute the number of all arc intersections in . Processing all cells can finally compute the number of all arc intersections of in the plane. As such, the total time of the overall algorithm is . Recall that for any cell . Because , we have , where . By Lemma 2(4), . Hence, . As such, the runtime of the overall algorithm is .
Theorem 14.
The number of intersections among a set of circular arcs of the same radius in the plane can be computed in time.
We further improve the algorithm when the number of intersections of the arcs is small.
Theorem 15.
The number of intersections among a set of circular arcs of the same radius in the plane can be computed in time, for any , where is the number of intersections of all arcs.
Proof.
Let denote the set of all arcs. Let . By Theorem 1, we first compute a -cutting for of size in time, so that each cell of is intersected by at most arcs of . Note that . Hence, constructing the cutting takes time. For each cell of , we compute the number of intersections of arcs inside , in time by Theorem 14. The total time of the overall algorithm is therefore on the order of , which is bounded by .
The above algorithm depends on the unknown value . To overcome of the issue, we guess the value of by the trick of doubling. We start with for a constant , and run the algorithm with . If the algorithm takes too long, then our guess is too low and we double . Using this strategy, the algorithm is expected to stop within a constant number of rounds when is larger than for the first time. Hence, the total time is asymptotically the same as if we had plugged in the right value of , except that we call the cutting construction algorithm for (which is ) times. Hence, the total time the algorithm spends on constructing the cutting is still as the factor is absorbed by . Therefore, the total time of the overall algorithm is still .
4 Concluding remarks
In this paper, we present an time algorithm for computing the number of intersections among a set of circular arcs of the same radius, which nearly matches the lower bound of Erickson in the partition algorithm model [11]. Our algorithm involves a partition of the problem into several cases. While this partition makes the algorithm somewhat tedious, it appears necessary to treat these different cases separately, which may be due to the nature of the problem. Indeed, this partition is one of the main reasons that our algorithm is superior to the previous work of Agarwal, Pellegrini, and Sharir [3]. It remains unclear whether this partition can be simplified.
Some of our techniques and observations may be useful for solving other related problems. We demonstrate two examples below.
The bichromatic problem.
It is straightforward to adapt our algorithm to solving the bichromatic problem, i.e., given a set of blue circular arcs and another set of red circular arcs of the same radius, with as the total number of all arcs, compute the number of intersections between red arcs and blue arcs. Indeed, our algorithm for solving the problem for a single cell in Sections 3.1, 3.2, and 3.3 is for the bichromatic problem. More specifically, we first compute the set of square cells in a similar way as before. Then, for each cell , for each pair of cells of , we compute the number of intersections between the blue arcs of and the red arcs of as well as the number of intersections between the red arcs of and the blue arcs of , by applying our algorithm in Sections 3.1, 3.2, and 3.3. In this way, the bichromatic problem can be solved in time. The time can then be further reduced to time, for any , where is the number of intersections of all arcs.
Alternatively, one can solve the bichromatic problem by using our algorithm for the monochromatic case as a black-box. First, we compute the number of intersections of all arcs, denoted by . Then, we compute the number of intersections among the red arcs, denoted by , and also compute the number of intersections among the blue arcs, denoted by . Observe that is the number of bichromatic intersections. The total runtime of the algorithm is asymptotically the same as that for the monochromatic case.
The segment case.
Suppose is a set of line segments in the plane. To compute the number of intersections of , using Chan and Zheng’s recent time algorithm [8] and the techniques of Theorem 15, we can solve the problem in time. Indeed, applying Theorem 1 with , we first compute a -cutting for of size in time, so that each cell of is intersected by at most segments of . Since , constructing the cutting takes time. For each cell of , we compute the number of intersections of segments inside , in time by Chan and Zheng’s algorithm [8]. Hence, the total time is on the order of , which is bounded by . The above algorithm depends on the unknown value . To overcome of the issue, we again use the doubling technique as in Theorem 15. As the analysis in Theorem 15, the total time of the algorithm is still .
We also remark that by plugging Chan and Zheng’s algorithm [8] into a randomized algorithm of de Berg and Schwarzkopf [6] (i.e., replacing Chazelle’s algorithm [10] with Chan and Zheng’s algorithm [8] in Theorem 3 [6]), the number of the intersections of can be computed in expected time. The algorithm is similar as above, except that it uses a cutting with slightly better bounds; specifically, de Berg and Schwarzkopf (Theorem 1 [6]) gave a randomized algorithm that can construct a -cutting of size for in expected time.
References
- [1] Pankaj K. Agarwal. Partitioning arrangements of lines II: Applications. Discrete and Computational Geometry, 5:533–573, 1990. doi:10.1007/BF02187809.
- [2] Pankaj K. Agarwal, Boris Aronov, Micha Sharir, and Subhash Suri. Selecting distances in the plane. Algorithmica, 9:495–514, 1993. doi:10.1007/BF01187037.
- [3] Pankaj K. Agarwal, Marco Pellegrini, and Micha Sharir. Counting circular arc intersections. SIAM Journal on Computing, 22:778–793, 1993. doi:10.1137/0222050.
- [4] Pankaj K. Agarwal and Micha Sharir. Pseudoline arrangements: Duality, algorithms, and applications. SIAM Journal on Computing, 34:526–552, 2005. doi:10.1137/S0097539703433900.
- [5] Mark de Berg, Otfried Cheong, Marc J. van Kreveld, and Mark H. Overmars. Computational Geometry — Algorithms and Applications. Springer-Verlag, Berlin, 3rd edition, 2008.
- [6] Mark de Berg and Otfried Schwarzkopf. Cuttings and applications. International Journal of Computational Geometry and Applications, 5:343–355, 1995. doi:10.1142/S0218195995000210.
- [7] Timothy M. Chan, Pingan Cheng, and Da Wei Zheng. Semialgebraic range stabbing, ray shooting, and intersection counting in the plane. In Proceedings of the 40th International Symposium on Computational Geometry (SoCG), pages 33:1–33:15, 2024. doi:10.4230/LIPIcs.SoCG.2024.33.
- [8] Timothy M. Chan and Da Wei Zheng. Hopcroft’s problem, log-star shaving, 2D fractional cascading, and decision trees. ACM Transactions on Algorithms, 2023. doi:10.1145/3591357.
- [9] Bernard Chazelle. Reporting and counting segment intersections. Journal of Computer and System Sciences, 32:156–182, 1986. doi:10.1016/0022-0000(86)90025-5.
- [10] Bernard Chazelle. Cutting hyperplanes for divide-and-conquer. Discrete and Computational Geometry, 9(2):145–158, 1993. doi:10.1007/BF02189314.
- [11] Jeff Erickson. New lower bounds for Hopcroft’s problem. Discrete and Computational Geometry, 16:389–418, 1996. doi:10.1007/BF02712875.
- [12] Leonidas J. Guibas, Mark H. Overmars, and Micha Sharir. Counting and reporting intersections in arrangements of line segments. Technical Report 434, Department of Computer Science, New York University, 1989.
- [13] Matthew J. Katz and Micha Sharir. An expander-based approach to geometric optimization. SIAM Journal on Computing, 26(5):1384–1408, 1997. doi:10.1137/S0097539794268649.
- [14] Jir̆í Matoušek. Range searching with efficient hierarchical cuttings. Discrete and Computational Geometry, 10(1):157–182, 1993. doi:10.1007/BF02573972.
- [15] Marco Pellegrini. On counting pairs of intersecting segments and off-line triangle range searching. Algorithmica, 17:380–398, 1997. doi:10.1007/BF02523679.
- [16] Haitao Wang. Unit-disk range searching and applications. Journal of Computational Geometry, 14:343–394, 2023. doi:10.20382/jocg.v14i1a13.
