Abstract 1 Introduction 2 Preliminaries 3 The algorithm 4 Concluding remarks References

Counting Unit Circular Arc Intersections

Haitao Wang ORCID Kahlert School of Computing, University of Utah, Salt Lake City, UT, USA
Abstract

Given a set of n 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 O(n4/3+ϵ) time [Agarwal, Pellegrini, and Sharir, SIAM J. Comput., 1993], for any constant ϵ>0. No progress has been made on the problem for more than 30 years. We present a new algorithm of O(n4/3log16/3n) time and improve it to O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n) time for small K, where K is the number of intersections of all arcs.

Keywords and phrases:
circular arc intersections, unit circles, arrangements, cuttings, segment intersections
Copyright and License:
[Uncaptioned image] © Haitao Wang; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Computational geometry
; Theory of computation Design and analysis of algorithms
Related Version:
Full Version: https://arxiv.org/abs/2602.01074
Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim Thắng

1 Introduction

Given a set of n 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 O(n4/3+ϵ) time; throughout the paper, we let ϵ denote an arbitrarily small positive constant. On the negative side, Erickson’s results [11] show that Ω(n4/3) 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 O(n4/3log16/3n) time and thus improve the previous result in [3]. Although the improvement looks minor, a factor of O(nϵ), it is significant from the following perspective: it reduces the gap between the upper and lower bounds from poly(n) to poly(logn), where poly() is a polynomial function. Further, for small K, where K is the number of intersections of all arcs, we improve the algorithm to O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n) time. Note that this matches the above O(n4/3log16/3n) complexity in the worst case when K=Θ(n2). If K=O(n2δ) for any δ>0, then the time complexity is o(n4/3).

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 O(n3/2+ϵ) time algorithm to compute the number of intersections of all arcs.

For computing the number of intersections among a set of n circles of the same radius, Katz and Sharir [13] gave an algorithm of O(n4/3logn) time and the randomized algorithm of Agarwal, Aronov, Sharir, and Suri [2] can solve it in O(n4/3log2/3n) expected time. Recently, Wang [16] derived an O(n4/3) time algorithm for it, matching the Ω(n4/3) lower bound [11]. If the circles have different radii, then the problem is solvable in O(n3/2+ϵ) time [3]. Recently, Chan, Cheng, and Zheng [7] extended the result and gave an O(n3/2+ϵ)-time algorithm to compute the number of intersections among a set of n 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 Ω(n4/3)-time lower bound [11] still applies. On the positive side, Chazelle [9] gave an O(n1.695) time algorithm for the problem. Guibas, Overmars, and Sharir [12] developed a randomized algorithm of O(n4/3+ϵ) expected time. Agarwal [1] solved the problem in O(n4/3log1.78n) time and Chazelle [10] further improved the algorithm to O(n4/3(logn)1/3) time. For small K, where K is the number of all segment intersections, Pellegrini [15] gave an algorithm of O(n1+ϵ+K1/3n2/3+ϵ) time. De Berg and Schwarzkopf [6] presented a randomized algorithm of O(nlognlogK+K1/3n2/3log1/3n) expected time. Recently, Chan and Zheng [8] solved the problem in O(n4/3) time, matching the Ω(n4/3) 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 O(n1+ϵ+K1/3n2/3(n2n+K)ϵ) time, or in O(nlognlogK+K1/3n2/3) 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 a and b in the plane, we use ab¯ to denote the segment with endpoints a and b; we call ab¯ the defining segment of a (resp., b). For any compact region A in the plane, we use A to denote the boundary of A.

Cuttings.

Let H be a set of n lines in the plane. For a compact region A in the plane, we use HA to denote the subset of lines of H that intersect the interior of A (we also say that these lines cross A). 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 r with 1rn, a (1/r)-cutting for H is a cutting Ξ satisfying |Hσ|n/r for every cell σΞ.

We say that a cutting Ξ c-refines a cutting Ξ if every cell of Ξ is contained in a single cell of Ξ and each cell of Ξ contains at most c cells of Ξ. Let Ξ0,Ξ1,,Ξk be a sequence of cuttings for H such that Ξ0 is the entire plane, and every Ξi is a (1/ρi)-cutting of size O(ρ2i) which c-refines Ξi1, for two constants c and ρ>1. To make Ξk a (1/r)-cutting, we set k=logρr. The above sequence of cuttings is called a hierarchical (1/r)-cutting for H. If a cell σΞj1 contains a cell σΞj, we say that σ is the parent of σ and σ is a child of σ.

For any 1rn, a hierarchical (1/r)-cutting of size O(r2) for H (together with the sets Hσ for every cell σ of Ξi for all i=0,1,,k) can be computed in O(nr) time [10]. Note that this implies that the total size of Hσ for all cells σΞi, 0ik, is O(nr).

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 H is a set of n circular arcs (not necessarily with the same radius) in the plane, then we can also define cuttings for H 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 H is a set of n circular arcs (or line segments) in the plane and K is the number of intersections of the arcs of H. For any rn, a hierarchical (1/r)-cutting of size O(r2) for H (together with the subsets Hσ for every cell σ of Ξi for all 0ik) can be computed in O(nr) time; more specifically, the size of the cutting is O(r1+ϵ+Kr2/n2) and the runtime of the algorithm is O(nrϵ+Kr/n), for any ϵ>0.

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.

Figure 1: Illustrating a pseudo-trapezoid. The top (resp., bottom) side is a circular arc that is part of an input arc. The left (resp., right) side a vertical segment.

3 The algorithm

We present an O(n4/3log16/3n)-time algorithm for computing the number of intersections of n circular arcs of the same radius in the plane. At the very end of this section, we reduce the time to O(K1/3n2/3(n2n+K)ϵlog16/3n), where K is the number of intersections of all arcs.

Let S be a set of n circular arcs of the same radius in the plane. Without loss of generality, we assume that the radius is 1, and each arc is thus a unit circular arc. Our goal is to compute the number of intersections of all arcs of S. 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 1; the boundary of a unit disk is a unit circle. For each arc s, 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 s. We use α(s) and D(s) to denote the underlying circle and disk of s, respectively. Let P denote the set of the centers of the arcs of S. For any region A in the plane, let P(A) denote the subset of points of P in A, i.e., P(A)=PA.

With respect to P, Wang [16] gave an algorithm to compute a set 𝒞 of O(n) axis-parallel square cells in the plane whose interiors are pairwise disjoint and whose union covers all the points of P, with the following properties: (1) Each cell has side length 1/2. (2) Every two cells are separated by an axis-parallel line. (3) For a unit disk Dp with center p, if p is not in any cell of 𝒞, then DpP=. (4) Each cell C of 𝒞 is associated with a subset N(C) of O(1) cells of 𝒞, such that for any disk D with center in C, every point of PD is in one of the cells of N(C); e.g., see Fig. 2. (5) Each cell C of 𝒞 is in N(C) for a constant number of cells C𝒞. In addition to 𝒞, Wang’s algorithm [16] also computes the subsets P(C) and N(C) for all cells C𝒞, in a total of O(nlogn) time and O(n) space. Using the properties of 𝒞, we can obtain the following lemma.

Figure 2: The set N(C) is a subset of the grey cells. Because the side-length of each cell is 1/2, the length between any point in C and any point not in a grey cell must be larger than 1.
Lemma 2.

(1) Each arc of S is covered by the union of all cells of 𝒞. (2) If an arc sS intersects C, then the center of s must be in one of the cells of N(C). (3) Each arc of S only intersects a constant number of cells of 𝒞. (4) C𝒞CN(C)|P(C)|=O(n).

Proof.

To prove the first lemma statement, it suffices to show that for any point p of an arc of S, p must be in a cell C of 𝒞. Assume to the contrary this is not the case for a point p of an arc sS. Then, by property (3) of 𝒞, DpP=. However, this is not true since Dp contains the center of s, which is in P. We thus obtain contradiction.

For the second lemma statement, consider a point p in a cell C and p is also on a segment s. Let q be the center of s. Since Dp contains q, by the property (4) of 𝒞, q must be in one of the cells of N(C).

For the third lemma statement, consider an arc s whose center is in a cell C. If s intersects a cell C, then by the second lemma statement, C must be in N(C). According to the property (5) of 𝒞, each cell C of 𝒞 is in N(C) for a constant number of cells C𝒞. This implies that s only intersects a constant number of cells of 𝒞.

The fourth lemma statement simply follows the property (5) of 𝒞.

For each cell C𝒞, we use S(C) to denote the set of arcs of S whose centers are in P(C).

With Lemma 2, we will compute the number of intersections of the arcs of S inside each cell C of 𝒞 and then add these numbers together. In what follows, we focus on one such cell C. Our goal is to compute the number of intersections of the arcs of S inside C. By Lemma 2, we only need to consider the arcs in S(C) for all CN(C). To this end, for each pair of cells (C1,C2) of N(C), including the case where C1=C2, we will compute the number of intersections inside C between the arcs of S(C1) and the arcs of S(C2); the sum of these numbers is the number of intersections inside C among all arcs of S. In the following, we discuss our algorithm for such a pair (C1,C2).

We assume that C1 and C2 are two different cells since the other case can be solved by the same techniques. Let nj=|S(Cj)|, j=1,2. Since we are interested in the intersections inside C, for each arc sS(Cj), we only keep its portions inside C. As the radius of s is 1 and C is an axis-parallel square of side length 1/2, s has at most two (maximal) sub-arcs in C. Let Sj denote the set of these sub-arcs of S(Cj). Thus, |Sj|2nj. Our goal is to compute the number of intersections between the arcs of S1 and the arcs of S2.

3.1 Counting intersections between 𝑺𝟏 and 𝑺𝟐: Algorithm overview

To simplify the notation, we temporarily let n=|S1|+|S2| and S=S1S2. For each arc sS, by definition, s is inside C; we extend both endpoints of s along the underlying circle of s until C, and we refer to the new arc as the extending arc of s. Let S denote the set of all extending arcs of S. Note that every two arcs of S intersect at most twice.

We will start with computing a cutting of S 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 C. Let S(τ) be the set of arcs of S intersecting τ and let nτ=|S(τ)|. Let S1(τ)=S1S(τ) and S2(τ)=S2S(τ). The goal of the restricted subproblem is to compute the number of intersections between the arcs of S1(τ) and S2(τ) inside τ. If we color the arcs of S1(τ) red and color those of S2(τ) 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 sS(τ) is a short arc if it has at least one endpoint in the interior of τ. Otherwise, s is a long arc. Because the radius of s is 1, τ is a pseudo-trapezoid inside C (and the radii of the circular arcs on the boundary of τ are also 1), and C a square cell of side-length 1/2, the intersection of τ and s consists of at most two (maximal) sub-arcs. Since we are only interested in intersections inside τ, for each arc sS(τ), we trim it and only keep its portion (possibly two sub-arcs) inside τ. If s has two trimmed sub-arcs in τ, then both sub-arcs are treated as independent arcs, which are considered as long (resp., short) arcs if s 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 S(τ) to denote the set of all trimmed arcs in τ and use nτ to denote the size of S(τ). Let mτ denote the number of short arcs of S(τ).

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 O(mτ4/3+ϵ) time. We will give an O(nτlog2mτ+mτnτlogmτ)-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 O(nτlog2mτ+mτnτlogmτ) 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 O(mτ2/logmτ+nτlog2mτ) time.

3.2.1 Counting type (3.1) intersections

For any long arc sS(τ), the intersection of its underlying circle α(s) and τ consists of at most two arcs (one of which is s). If the intersection is only one arc, which is s, then we call s 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.

Figure 3: The grey area is lune(sb). p is the center of sr. The two dashed circles are unit circles centered at the two endpoints of sb, respectively.
Counting type (3.1.1) intersections.

Consider a short blue arc sb. Let D1 and D2 be the two unit disks centered at the two endpoints of sb, respectively. We call the region of D1 that is not in D2 a lune; similarly, region of D2 that is not in D1 is also a lune. We use lune(sb) refer to the union of the two lunes (for simplicity, we consider lune(sb) as a single lune defined by sb), i.e., lune(sb)=D1D2D1D2, the symmetric difference of D1 and D2 (e.g., the grey area in Fig. 3). By definition, a point is in lune(sb) if and only if the unit disk centered at the point contains exactly one endpoint of sb, implying that the unit circle centered at the point intersects sb 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 sb and a long red full arc sr, sr intersects sb exactly once if and only if the center of sr lies in lune(sb); e.g., see Fig. 3.

Proof.

Let p be the center of sr and D be the underlying disk of sr.

If sr intersects sb exactly once, then one endpoint of sb must be inside D while the other is outside D. Therefore, p must be in lune(sb). Below we prove the other direction of the observation.

If p is in lune(sb), then by the definition of lune(sb), one endpoint of sb is in D while the other is not. Hence, sb must cross D at exactly one point, say, q, which is the only intersection between sb and D. As sb is in the cell τ, qτ. Since qD, we obtain that qDτ. Further, since sr is a long full arc, we have sr=Dτ. Hence, qsr. This implies that qsrsb. Since srD and sb and D has exactly one intersection, we conclude that sb and sr has exactly one intersection.

Lemma 4.

Counting type (3.1.1) intersections takes O(mτ2/logmτ+nτlogmτ) time.

Proof.

For notational convenience, let n=nτ and m=mτ in this proof. Recall that centers of red arcs are in the cell Cr𝒞. For each short blue arc sb, since the radius of sb is 1 and Cr is a square cell of the side-length 1/2, the boundary of the intersection of Cr and lune(sb) has at most four circular arcs (which are on the unit circles centered at the two endpoints of sb, respectively); let H be the set of these circular arcs defined by all short blue arcs. Hence, |H|=O(m). By Observation 3, it suffices to compute the number of lunes lune(sb) containing the center of each long red arc. Let L denote the set of the lunes lune(sb) of all short blue arcs sb.

We build a hierarchical (1/r)-cutting Ξ0,Ξ1,,Ξk on the arcs of H, with r=m/logm. This can be done in O(mr) time by Theorem 1. For each cell σΞi, 1ik, we define mσ as the number of lunes of L that contain σ but do not contain the parent cell of σ in Ξi1 (i.e., the boundary of the lune crosses the parent cell). We can compute mσ for all cells σΞi, for all i=1,2,,k, as follows.

Recall that the algorithm of Theorem 1 for computing the hierarchical cutting also produces the sets Hσ for all cells σΞi, 0ik, where Hσ is the subset of arcs of H crossing σ, in O(mr) time. As discussed in Section 2, the total size of these sets for all cells is O(mr).

Next, we show that the values mσ for all cells σΞi, 1ik can be computed in O(mr) time using the sets Hσ. Define L(σ) as the subset of lunes of L that contain σ but does not contain the parent cell of σ. Hence, mσ=|L(σ)|. Observe that one of the bounding arcs of each lune of L(σ) must cross σ, where σ is the parent of σ in Ξi1. This implies that we can compute L(σ) and thus mσ using Hσ as follows. For each arc sHσ, we check whether the lune of L bounded by s contains σ; if yes, we add the lune to L(σ). Since each cell of the hierarchical cutting has O(1) child cells, the above algorithm for computing mσ for all cells σΞi, 1ik, runs in time linear in the total size of Hσ for all cells σΞi, 0ik, which is O(mr) as explained above. As such, after the hierarchical cutting is computed, mσ for all cells σΞi, 1ik, can be computed in O(mr) time.

For each long red arc s, we locate the cell σi of Ξi containing q for each 1ik, where q is the center of s; we add all these values mσi to a total count ms (initially, ms=0). Finally, for the cell σΞk, for each arc sHσ, we check whether the lune of L bounded by s contains q; if yes, we increases ms by one. It is not difficult to see the value ms thus obtained is equal to the number of lunes of L containing q. Since |Hσ|=O(m/r)=O(logm) for any σΞk and k=O(logr), the time of the above algorithm for computing ms is O(logm). 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 n long red arcs, the total time of the algorithm is O(mr+nlogm), which is O(m2/logm+nlogm) as r=m/logm.

Counting type (3.1.2) intersections.

We now discuss type (3.1.2) intersections. Consider a long red partial arc sr. Recall that the center of sr is in the square cell Cr. By property (2) of 𝒞, the two cells Cr and C are separated by an axis-parallel line. Depending on whether the line is horizontal or vertical, without loss of generality, we assume that Cr is either below C or to the right of C. Recall that the pseudo-trapezoid τ is in C, 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 sr is a partial arc, the underlying circle α(sr) intersects C at another arc, denoted by sr; we call sr the coupled arc of sr (and sr is also the coupled arc of sr).

Consider a type (3.1.2) intersection between a long red partial arc sr and a short blue arc sb. We further partition type (3.1.2) intersections into two types: (3.1.2.1) sb does not intersect the coupled arc sr of sr; (3.1.2.2) sb intersects sr (since sr and sr are on the same circle and sb intersects sr, sb intersects sr 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 sb, we use lune(sb) to denote the region of the plane outside the union of the two unit disks centered at the two endpoints of sb.

Recall that Cr is either below C or to the right of C. 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.

Figure 4: Illustrating sr, sr, and z(sr) for the case where Cr is below C. The point p is the center of sr and the dashed curve is the upper semicircle of α(sr). Top: sr and sb form a type (3.1.2.1) intersection (i.e., sr and sb intersect exactly once and sr does not intersect sb). Bottom: sr and sb form a type (3.1.2.2) intersection (i.e., sb and sr intersect exactly once and sb intersects sr).

Suppose Cr is below C. Then, sr and sr are both on the upper semicircle of α(sr) (e.g., see Fig. 4). Thus, both sr and sr are x-monotone, and sr is either to the left or to the right of sr. Let z(sr) denote the endpoint of sr closer to sr, e.g., z(sr) is the right (resp., left) endpoint of sr if sr is to the left (resp., right) of sr. 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 sr be a long red partial arc and sb a short blue arc. Suppose Cr is below C.

  1. 1.

    sr and sb form a type (3.1.2.1) intersection (i.e., sr and sb intersect exactly once and sr does not intersect sb) if and only if the following two conditions hold: (1) the center of sr lies in lune(sb); (2) the endpoint of sb not in the disk D(sr) is to the left (resp., right) of z(sr) if sr is to the left (resp., right) of sr. See Fig. 4 (top).

  2. 2.

    sr and sb form a type (3.1.2.2) intersection (i.e., sb and sr intersect exactly once and sb intersects sr) if and only if the following two conditions hold: (1) the center of sr lies in lune(sb); (2) one endpoint of sb is left of z(sr) while the other endpoint is right of z(sr). See Fig. 4 (bottom).

If Cr is to the right of C, sr and sr are both in the left semicircle of α(sr); e.g., see Fig. 5. Thus, both sr and sr are y-monotone, and sr is either above or below sr. Let z(sr) denote the endpoint of sr closer to sr, e.g., z(sr) is upper (resp., lower) endpoint of sr if sr is below (resp., above) sr. We have the following observation, which is similar in spirit to Observation 5.

Figure 5: Illustrating sr, sr, and z(sr) where Cr is right of C. The point p is the center of sr and the dashed curve is the left semicircle of α(sr). Left: sr and sb form a type (3.1.2.1) intersection (i.e., sr and sb intersect exactly once and sr does not intersect sb). Right: sr and sb form a type (3.1.2.2) intersection (i.e., sb and sr intersect exactly once and sb intersects sr).
Observation 6.

Let sr be a long-red partial arc and sb a short-blue arc. Suppose Cr is right of C.

  1. 1.

    sr and sb form a type (3.1.2.1) intersection if and only if the following two conditions hold: (1) the center of sr lies in lune(sb); (2) the endpoint of sb not in the disk D(sr) is below (resp., above) z(sr) if sr is below (resp., above) sr. See Fig. 5 (left).

  2. 2.

    sr and sb form a type (3.1.2.2) intersection if and only if the following two conditions hold: (1) the center of sr lies in lune(sb); (2) one endpoint of sb is above z(sr) while the other endpoint is below z(sr). 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 O(mτ2/logmτ+nτlog2mτ) time.

Lemma 7.

Counting type (3.1.2.1) intersections takes O(mτ2/logmτ+nτlog2mτ) time.

Proof.

We assume that Cr is below C and the other case where Cr is right of C 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 n=nτ and m=mτ in this proof.

We follow the same algorithm as in Lemma 4 but set r=m/log2m. Recall that for each cell σΞi, i=1,2,,k, we have defined a subset L(σ)L consisting of the lunes of L that contain σ but do not contain the parent cell of σ in Ξi1. The total size of all these subsets is O(mr). For each subset L(σ), for each lune(sb)L(σ), since lune(sb) contains σ, all unit disks centered in σ contain exactly the same endpoint of sb and let p(sb,σ) denote the other endpoint; we use P(σ) to denote set of all these endpoints p(sb,σ) for all lune(sb)L(σ). Note that |P(σ)|=|L(σ)|. We explicitly maintain P(σ). Computing these subsets P(σ) for all cells can be done in O(mr) time by using the sets L(σ). We further sort each set P(σ) by their x-coordinates. As the total size of P(σ) for all cells σ is O(mr), the sorting for P(σ) of all cells σ can be done in O(mrlogm) time.

For each long red arc sr, we first check whether it is a partial arc (this can be done in O(1) time). If not, we ignore it. If yes, we proceed as follows. Without loss of generality, we assume that sr is to the left of sr and thus z(sr) is the right endpoint of sr. Let q be the center of sr. We locate the cell σi of Ξi containing q for each 1ik. For each σi, according to Observation 5(1), we perform binary search on the sorted list of P(σ) to find the number of points of P(σ) to the left of z(sr), and let mσi denote this number. We add all these values mσi to a total count msr (initially, msr=0). Finally, for the cell σΞk, for each arc sHσ, we do the following. Note that s is an arc of lune(sb) for a short blue arc sb. We check in O(1) time whether sr and sb form a type (3.1.2.1) intersection; if yes, we increase msr by one. The value msr thus obtained is equal to the number of type (3.1.2.1) intersections involving sr. The time for computing msr is O(log2m). 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 O(mrlogm+nlog2m), which is O(m2/logm+nlog2m) as r=m/log2m.

Lemma 8.

Counting type (3.1.2.2) intersections takes O(mτ2/logmτ+nτlog2mτ) time.

Proof.

We assume that Cr is below C and the other case where Cr is right of C can be handled similarly. Our algorithm will be based on Observation 5(2). For notational convenience, let n=nτ and m=mτ in this proof.

We still follow the algorithm in the Lemma 4 but set r=m/log2m and use lune(sb) to replace lune(sb). Note that the intersection of Cr and lune(sr) is still bounded by at most two circular arcs (other than the boundary of Cr). Let H be the set of all these circular arcs for all short blue arcs. Let L denote the set of lune(sb) of all short blue arcs sb. Next, we build a hierarchical cutting for H in the same way as in the proof of Lemma 4. We define L(σ) in the same way. Let B(σ) denote the set of short blue arcs sb with lune(sb)L(σ). Using L(σ), we can obtain B(σ) for all cells σΞi, i=1,2,,k, in O(mr) time. For each arc sbB(σ), it defines an interval [x1(sb),x2(sb)], where x1(sb) and x2(sb) are the x-coordinates of the left and right endpoints of sb, respectively; let I(σ) denote the set of all these intervals for all arcs of B(σ). We build an interval tree (Section 10.1 [5]) on the intervals of I(σ) in O(|I(σ)|log|I(σ)|) time so that given a query x-coordinate x, we find in O(log|I(σ)|) time the number of intervals of I(σ) containing x. As |I(σ)|=O(m) and the total size of the sets I(σ)’s of all cells in the cutting is O(mr), the total time for building the interval trees is O(mrlogm).

For each long red arc sr, we first check whether it is a partial arc (this can be done in O(1) time). If not, we ignore it. If yes, we proceed as follows. Without loss of generality, we assume that sr is to the left of sr and thus z(sr) is the right endpoint of sr. Let q be the center of sr. We locate the cell σi of Ξi containing q for each i=1,2,,k. For each σi, we query the interval tree of I(σi) to find number of intervals of I(σi) containing z(sr); let mσi denote this number. We add all these values mσi to a total count msr (initially, msr=0). Finally, for the cell σΞk, for each arc sHσ, we do the following. Let sb be the short-blue arc such that s is an arc of lune(sb). We check whether sr and sb form a type (3.1.2.1) intersection, which can be done in O(1) time; if yes, we increases msr by one. The value msr thus obtained is equal to the number of type (3.1.2.2) intersections involving sr. The time for computing msr is O(log2m). 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 O(mrlogm+nlog2m), which is O(m2/logm+nlog2m) as r=m/log2m.

3.2.2 Counting type (3.2) intersections

We now compute the number of type (3.2) intersections. The runtime of the algorithm is O(mτ2log2mτ+nτlog4mτ). Our goal is to compute the number of pairs of a long red arc sr and a short blue arc sb such that sr and sb intersect twice.

Figure 6: Illustrating the wedge w(s) (the grey area): p is the center of s.

Let s be either a blue short arc or a long red arc. Since the radius of s is 1, s is contained in τ, which is in C, and C is a square cell of side-length 1/2, s does not span more than a semicircle of the underlying circle α(s) of s. The two lines through the center of s and its two endpoints partition the plane into four wedges, one of which contains s completely (we use w(s) 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.

Figure 7: Illustrating Observation 9: p is the center of sb and q is the center of sr.
Observation 9.

Consider a short blue arc sb and a long red arc sr. If sb and sr intersect twice, then the following four conditions must hold (e.g., see Fig. 7): (1) the center of sr is in the wedge w(sb); (2) the center of sb is in the wedge w(sr); (3) the underlying disk D(sr) of sr does not contain either endpoint of sb; (4) the underlying circles α(sb) and α(sr) intersect. On the other hand, if the above four conditions all hold, then exactly one of the following two cases must happen: (1) sb and sr intersect twice; (2) sr is a partial arc and sb intersects both sr and its coupled arc sr.

Notice that in the second case of Observation 9 sr and sb form a type (3.1.2.2) intersection. Thus, if k1 is the number of pairs of a long red arc sr and a short blue arc sb that intersect twice, then k1=k2k3, where k2 is the number of pairs (sr,sb) that satisfy the four conditions in Observation 9 and k3 is the number of type (3.1.2.2) intersections. We have already computed k3 in Lemma 8. It remains to compute k2, which is done in Lemma 10.

Lemma 10.

Counting type (3.2) intersections takes O(mτ2log2mτ+nτlog4mτ) time.

Proof.

We first apply Lemma 8 and compute k3 in O(mτ2/logmτ+nτlog2mτ) time. As discussed before, it suffices to compute k2, i.e., the number of pairs (sr,sb) that satisfy the four conditions in Observation 9. We show below that k2 can be computed in O(mτ2log2mτ+nτlog4mτ) time. For notational convenience, we let n=nτ and m=mτ in this proof.

Let B denote the set of short blue arcs and let R be the set of long red arcs of S(τ). For each short blue arc sb, define A(sb) as the common intersection of the wedge w(sb) and lune(sb). Note that the underlying disk of a long-red arc sr does not contain either endpoint of a short-blue arc sb if and only if the center of sr is in lune(sb). Hence, the first two conditions of Observation 9 are satisfied if and only if the center of sr is in A(sb).

Recall that centers of all red arcs are in the square cell Cr. Let A(sb)=A(sb)Cr. Note that other than those on Cr, A(sb) 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, A(sb) has at most four general-arcs. We call A(sb) the interesting region of sb. Let I denote the set of interesting regions of all arcs of B. Let E denote the set of general-arcs of all regions of I. Hence, |E|=O(m).

We compute a hierarchical (1/r)-cutting Ξ0,Ξ1,,Ξk on the general-arcs of E, with r=m and a constant ratio ρ as described in Section 2. This can be done in O(mr) time by Theorem 1. For each cell σΞi, 1ik, we define a canonical pair (Bσ,Rσ), with BσB and RσR, so that centers of all arcs of Rσ lie in the interesting region of each short blue arc of Bσ. Specifically, Rσ consists of all long red arcs whose centers are located in the cell σ and Bσ consists of the arcs of B whose interesting regions contain σ but do not contain the parent cell of σ in Ξi1. The canonical pairs of all cells of all cuttings Ξi, 1ik, can be computed in O(mr+nlogm) time, as follows.

For the center p of each long red arc sr, we locate the cell σ of Ξi containing p, for all 1ik, and add sr to Rσ, which can be done in O(logr) time. As such, computing the canonical sets Rσ for all cells σ takes O(nlogm) time in total. For computing Bσ, we can use an algorithm similar to the one in Lemma 4 (i.e., replacing lune(sb) by the interesting region A(sb)). More specifically, for each child cell σΞi of a cell σ in Ξi1, for each general-arc of Eσ (i.e., the set of general-arcs of E crossing σ), suppose it is a general-arc of A(sb) of a blue arc sb. We check whether A(sb) contains σ; if yes, we add sb to Bσ. In this way, computing all canonical subsets Bσ takes time proportional to the total size of the subsets Eσ for all cells σ of all cuttings Ξi, i=0,1,,k1, which is O(mr).

By the definition of canonical subset pairs (Bσ,Rσ), to compute k2, it suffices to compute the number of pairs of arcs (sb,sr) such that sbBσ, srRσ, α(sb) intersects α(sr), and the center of sb is in w(sr), for all cells σΞi, i=1,2,,k. Below we describe an algorithm of O(mσ2/logm+nσlogm) time for one such cell σΞi, where mσ=|Bσ| and nσ=|Rσ|.

Recall that all centers of red arcs are in the square cell Cr. Define 𝒟 as the set of disks of radius 2 centered at the centers of all blue arcs of Bσ. Let P be the set of all centers of the arcs of Rσ; if pP is the center of an arc srRσ, we use s(p) to refer to sr. It is not difficult to see that the problem is equivalent to computing the number of pairs (p,D), pP, D𝒟, such that p is contained in D and the center of D is in w(s(p)). 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 D is in w(s(p)). We briefly discuss it below. Note that mσ=|𝒟| and nσ=|P|.

For each disk D𝒟, the intersection of D and Cr consists of at most two circular arcs. Let H denote the set of circular arcs DCr for all disks D𝒟. We build a hierarchical (1/r)-cutting Ξ0,Ξ1,,Ξk for H, with r=mσ/logm and a constant ratio ρ1, in O(mσr) time [10]. For each cell βΞi, for all i=1,2,,k, define 𝒟(β) as the set of disks of 𝒟 that contain β but do not contain the parent cell of β in Ξi1. We can compute 𝒟(β) explicitly for all cells of in O(mσr) 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 p=2), which takes O(|𝒟(β)|2/log1δ|𝒟(β)|) preprocessing time for any δ>0 and can answer each query in O(log2|𝒟(β)|) time. In addition, for each cell βΞk, we explicitly store the subset Hβ of arcs of H crossing β.

All above can be done in O(mσr) 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 βΞi, it holds that |𝒟(β)|=O(mσ/ρ1i1). Since Ξi has O(ρ12i) cells, the total time for constructing the data structures is big-O of i=1kρ12imσ2/ρ12(i1)/log1δ(mσ/ρ1i1), which is bounded by O(mσ2logm) as ρ1 is a constant.

For each point pP, we locate the cell βi of Ξi containing p for each i=1,2,,k; using the wedge range searching data structure on the centers of 𝒟(βi), we find the number mβi of centers of disks of 𝒟(βi) contained in the wedge w(s(p)). We add all these values mβi to a total count mp (initially, mp=0). Finally, for the cell βkΞk, for each arc sHβk, we check whether the underlying disk of s contains p and the center of s is in w(s); if yes, we increases mp by one. The value mp thus obtained is equal to the number of disks D of 𝒟 that contain p and whose centers are in w(s(p)). The time for computing mp is O(logrlog2m) as |Hβ|=O(logm) for any cell βΞk. The sum pPmp is equal to the number of pairs (p,D), pP, D𝒟, such that p is contained in D and the center of D is in w(s(p)). As nσ=|P|, the total time of the algorithm is O(mσr+mσ2logm+nσlogrlog2m)), which is O(mσ2logm+nσlog3m) for r=mσ/logm.

The above shows that processing each canonical subset pair (Bσ,Rσ) for a cell σΞi takes O(mσ2logm+nσlog3m) time, with mσ=|Bσ| and nσ=|Rσ|. Processing all cells σΞi for all i=1,2,,k will compute the number k2. We now analyze the total time. For each 1ik, σΞi|Rσ|=n and mσ|Eσ|, where σ is the parent cell of σ in Ξi1. Since |Eσ|=O(m/ρi1), we have mσ=O(m/ρi1). Because Ξi has O(ρ2i) cells, the total time for processing all cells in Ξi is on the order of ρ2imσ2logm+nlog3mρ2im2/ρ2i2logm+nlog3m, which is bounded by O(m2logm+nlog3m) as ρ is a constant. Since k=O(logr) and r=m, the total time for processing all cells σΞi for all i=1,2,,k is O(m2log2m+nlog4m).

3.2.3 Counting type (3) intersections: a final step

The above shows that the number of type (3) intersections can be computed in O(mτ2log2mτ+nτlog4mτ) time. Using the result, we finally show that an alternative algorithm can compute the number of type (3) intersections in O(nτlog4mτ+mτnτlog3mτ) time.

If mτ<nτlogmτ, then mτ2log2mτnτlog4mτ and thus the runtime of the above algorithm is O(nτlog4mτ). Otherwise, we partition the short blue arcs into t groups of size mτ/t, with t=mτnτlogmτ. For each group, we apply the above algorithm on the group with all long-red arcs. The total time is O(t(mτ2/t2log2(mτ/t)+nτlog4(mτ/t))), which is O(mτnτlog3mτ). As such, the number of type (3) intersections can be computed in O(nτlog4mτ+mτnτlog3mτ) 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 (1/r)-cutting Ξ0,Ξ1,,Ξk on the arcs of S with n=|S|. For each cell τ of Ξk, we have the pseudo-trapezoid-restricted subproblem of counting the intersections of arcs of S(τ) inside τ, with nτ=|S(τ)| and mτ as the number of short arcs of S(τ). By the definition of short and long arcs, we have mτnτ=O(n/r) and τΞkmτ=O(n). By setting r=n1/3/(logn)2/3, we obtain the following lemma.

Lemma 11.

By setting r=n1/3/(logn)2/3, the total time for computing the number of type (2), (3), and (4) intersections for all cells τΞk is bounded by O(n4/3(logn)10/3).

Proof.

To solve the pseudo-trapezoid-restricted subproblem on each cell τΞk, we have shown above that counting type (2) intersections can be done in O(mτ4/3+ϵ) time and counting types (3) and (4) intersections takes O(nτlog4mτ+mτnτlog3mτ) time. Therefore, the total time for counting type (2) intersections for all cells τΞk is O(τΞkmτ4/3+ϵ). Since Ξk has O(r2) cells, τΞkmτ=O(n), and mτ=O(n/r), τΞkmτ4/3+ϵ achieves the maximum when r mτ’s have value n/r, i.e., τΞkmτ4/3+ϵ=O(r(n/r)4/3+ϵ), which is O(n4/3+ϵ/r1/3+ϵ). Hence, the total time for counting type (2) intersections is O(n4/3+ϵ/r1/3+ϵ).

The total time for counting types (3) and (4) intersections is τΞk(nτlog4mτ+mτnτlog3mτ). Since Ξk has O(r2) cells and nτ=O(n/r), we have τΞknτlog4mτ=O(r2n/rlog4n), which is O(nrlog4n). Since τΞkmτ=O(n), we can now derive τΞkmτnτlog3mτ=O(nnrlog3n).

As such, the total time for computing the number of intersections of types (2-4) is O(n4/3+ϵ/r1/3+ϵ+nrlog4n+nnrlog3n). Setting r=n1/3/(logn)2/3 makes the time bounded by O(n4/3(logn)10/3).

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 Ξk 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 Ξ0,Ξ1,,Ξk in the hierarchy. For each cell σΞi for any 0ik, we define long and short arcs of σ in the same way as before (i.e., suppose an arc sS intersects the interior of σ; then s is a long arc of σ if s does not have either endpoint in the interior of σ and is a short arc of σ otherwise). For a long arc s of σ, we say that s is a long-long arc if i>0 and s is also a long arc of σ, where σ is the parent cell of σ in Ξi1, and s is a short-long arc otherwise. A critical observation is that for a long arc s of any cell σΞk, s 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 Ξ0, which is the entire square cell C.

Recall that a type (1) intersection refers to an intersection in a cell σΞk between a long red arc of σ and a long blue arc of σ. Consider a type (1) intersection q in a cell σΞk between a long red arc sr and a long blue arc sb. Observe that σ has one and only one ancestor cell σ such that both sr and sb 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 q). This means that in order to count type (1) intersections, we can count, for all cells σΞi, i=0,1,,k, 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 σΞi, for any 0ik. Let Sr be the set of all long red arcs of σ and Sb the set of all long blue arcs of σ. Let Sr1 and Sr2 be the subsets of long-long and short-long arcs of σ in Sr, respectively. Let Sb1 and Sb2 be the subsets of long-long and short-long arcs of σ in Sb, respectively. Let nσ=|Sr|+|Sb| and mσ=|Sr2|+|Sb2|. As such, the above three types of intersections are: (1.1) intersections between arcs of Sr1 and Sb2, (1.2) intersections between arcs of Sr2 and Sb1, and (1.3) intersections between arcs of Sr2 and Sb2.

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 Ξi, i=0,1,,k, cannot be bounded by O(n4/3poly(logn)) since now we need to consider the cells in all cuttings Ξi, i=0,1,,k, not just the last cutting Ξk 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 mσnσ.

Lemma 12.

There exists an algorithm of O(mσlog4nσ+nσlog5nσ+nσ2/3mσ2/3(lognσ)13/3) 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 O(n4/3log16/3n) 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 σΞi, i=0,1,,k. We next analyze the total time for solving these subproblems. We follow the notation as defined before. Note that nσ=O(nρi) and Ξi has O(ρ2i) cells.

We first claim that σΞimσ=O(n) for all 0ik. Indeed, it is obviously true that σΞimσ=O(n) for i=0. We assume that i>0. Consider a short-long arc s of σ. By definition, s is a short arc of the parent cell σΞi1 of σ, implying that s has at least one endpoint in the interior of σ. Let σ1 and σ2 be the two cells of Ξi1 that contain the two endpoints of s, respectively (σ1=σ2 is possible). According to the above discussion, if s is short-long arc of σ for some cell σΞi, then σ must be a child cell of either σ1 or σ2. As σj has O(1) cells in Ξi, for j=1,2, s can be a short-long arc of at most O(1) cells σΞi. As such, σΞimσ=O(n) holds.

We now consider the three terms in the time complexity of Lemma 12 separately.

  1. 1.

    For the first term, i=0kσΞimσlog4nσ=O(i=1knlog4n)=O(nlog5n), for k=O(logr) and r=n1/3/(logn)2/3.

  2. 2.

    For the second term, we have i=0kσΞinσlog5nσ=O(i=1kρ2inρilog5n), which is bounded by O(nrlog5n) as r=Θ(ρk).

  3. 3.

    For the third term, σΞinσ2/3mσ2/3(lognσ)13/3 is big-O of σΞi(nρi)2/3mσ2/3(logn)13/3=(nρi)2/3(logn)13/3σΞimσ2/3. As σΞimσ=O(n) and Ξi has O(ρ2i) cells, by Hölder’s Inequality, σΞimσ2/3=O(ρ2i(nρ2i)2/3). As such, we can obtain that σΞinσ2/3mσ2/3(lognσ)13/3 is big-O of (nρi)2/3(logn)13/3ρ2i(nρ2i)2/3, which is bounded by O(n4/3(logn)13/3) as ρ is a constant. Hence i=0kσΞinσ2/3mσ2/3(lognσ)13/3=O(n4/3(logn)16/3), for k=O(logr) and r=n1/3/(logn)2/3.

Therefore, the total time for solving the subproblems for all cells σΞi for all i=0,1,,k is O(nlog5n+nrlog5n+n4/3log16/3n), which is O(n4/3log16/3n) as r=n1/3/(logn)2/3. Hence, the number of type (1.1) intersections can be computed in time bounded by O(n4/3log16/3n).

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 O(n4/3log16/3n) time.

By Lemmas 11 and 13, we conclude that the total number of intersections all types (i.e., the number of intersections in the square cell C) can be computed in O(n4/3log16/3n) time. Note that the time complexities in the two lemmas imply that computing type (1) intersections is the bottleneck.

3.4 Putting it all together

The above solves the problem of computing the number of intersections in the square cell C between the arcs of S(C1) and the arcs of S(C2). The time of the algorithm is O((n1+n2)4/3log16/3(n1+n2)), where n1=|S(C1)| and n2=|S(C2)|. The algorithm is based on the assumption that C1C2. If C1=C2, then the problem becomes computing the intersections in C among all arcs of S(C1). Our algorithm can be easily adapted to this case. For example, we can duplicate all arcs of S(C1) and make the duplications as S(C2), and then apply the algorithm (one subtle issue that in this case an arc of S(C1) and its duplication in S(C2) should not be considered intersected).

Enumerating all pairs (C1,C2) of N(C) and solving the problem as above can compute the number of all arc intersections in C. Processing all cells C𝒞 can finally compute the number of all arc intersections of S in the plane. As such, the total time of the overall algorithm is O(C𝒞(C1,C2)N(C)(n1+n2)4/3log16/3(n1+n2)). Recall that |S(C)|=|P(C)| for any cell C𝒞. Because |N(C)|=O(1), we have (C1,C2)N(C)(n1+n2)4/3log16/3(n1+n2))=O(nC4/3log16/3n), where nC=CN(C)|P(C)|. By Lemma 2(4), C𝒞nC=O(n). Hence, C𝒞nC4/3=O(n4/3). As such, the runtime of the overall algorithm is O(n4/3log16/3n).

Theorem 14.

The number of intersections among a set of n circular arcs of the same radius in the plane can be computed in O(n4/3log16/3n) 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 n circular arcs of the same radius in the plane can be computed in O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n) time, for any ϵ>0, where K is the number of intersections of all arcs.

Proof.

Let S denote the set of all arcs. Let r=n2/(n+K). By Theorem 1, we first compute a (1/r)-cutting Ξ for S of size O((n2/(n+K))1+ϵ) in O(nrϵ+Kr/n) time, so that each cell of Ξ is intersected by at most n/r=(n+K)/n arcs of S. Note that nrϵ+Kr/n=O(n1+ϵ). Hence, constructing the cutting takes O(n1+ϵ) time. For each cell σ of Ξ, we compute the number of intersections of arcs inside σ, in O(((n+K)/n)4/3log16/3n) time by Theorem 14. The total time of the overall algorithm is therefore on the order of n1+ϵ+(n2n+K)1+ϵ(n+Kn)4/3log16/3n, which is bounded by O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n).

The above algorithm depends on the unknown value K. To overcome of the issue, we guess the value of K by the trick of doubling. We start with K=K0 for a constant K0, and run the algorithm with K. If the algorithm takes too long, then our guess is too low and we double K. Using this strategy, the algorithm is expected to stop within a constant number of rounds when K is larger than K for the first time. Hence, the total time is asymptotically the same as if we had plugged in the right value of K, except that we call the cutting construction algorithm for O(logK) (which is O(logn)) times. Hence, the total time the algorithm spends on constructing the cutting is still O(n1+ϵ) as the logn factor is absorbed by ϵ. Therefore, the total time of the overall algorithm is still O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n).

4 Concluding remarks

In this paper, we present an O(n4/3log16/3n) time algorithm for computing the number of intersections among a set of n circular arcs of the same radius, which nearly matches the Ω(n4/3) 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 n 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 C𝒞 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 C𝒞, for each pair of cells (C1,C2) of N(C), we compute the number of intersections between the blue arcs of S(C1) and the red arcs of S(C2) as well as the number of intersections between the red arcs of S(C1) and the blue arcs of S(C2), by applying our algorithm in Sections 3.1, 3.2, and 3.3. In this way, the bichromatic problem can be solved in O(n4/3log16/3n) time. The time can then be further reduced to O(n1+ϵ+K1/3n2/3(n2n+K)ϵlog16/3n) time, for any ϵ>0, where K 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 K. Then, we compute the number of intersections among the red arcs, denoted by Kr, and also compute the number of intersections among the blue arcs, denoted by Kb. Observe that KKrKb 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 S is a set of n line segments in the plane. To compute the number of intersections of S, using Chan and Zheng’s recent O(n4/3) time algorithm [8] and the techniques of Theorem 15, we can solve the problem in O(n1+ϵ+K1/3n2/3(n2n+K)ϵ) time. Indeed, applying Theorem 1 with r=n2/(n+K), we first compute a (1/r)-cutting Ξ for S of size O((n2/(n+K))1+ϵ) in O(nrϵ+Kr/n) time, so that each cell of Ξ is intersected by at most n/r=(n+K)/n segments of S. Since nrϵ+Kr/n=O(n1+ϵ), constructing the cutting takes O(n1+ϵ) time. For each cell σ of Ξ, we compute the number of intersections of segments inside σ, in O(((n+K)/n)4/3) time by Chan and Zheng’s algorithm [8]. Hence, the total time is on the order of n1+ϵ+(n2n+K)1+ϵ(n+Kn)4/3, which is bounded by O(n1+ϵ+K1/3n2/3(n2n+K)ϵ). The above algorithm depends on the unknown value K. 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 O(n1+ϵ+K1/3n2/3(n2n+K)ϵ).

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 S can be computed in O(nlognlogK+K1/3n2/3) 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 (1/r)-cutting of size O(r+Kr2/n2) for S in O(nlogr+Kr/n) 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.