Geometric Separability using Orthogonal Objects

V P Abidha 1, Pradeesha Ashok International Institute of Information Technology Bangalore, India

Abstract Given a bichromatic point set P = R ∪ B of red and blue points, a separator is an object of a certain type that separates R and B. We study the geometric separability problem when the separator is a) rectangular annulus of fixed orientation b) rectangular annulus of arbitrary orien- tation c) square annulus of fixed orientation d) orthogonal convex polygon. In this paper, we give polynomial time algorithms to construct separators of each of the above type that also optimizes a given parameter. Specifically, we give an O(n3 log n) algorithm that computes (non-uniform width) separating rectangular annulus in arbitrary orientation, of minimum possible width. Fur- ther, when the orientation is fixed, we give an O(n log n) algorithm that constructs a uniform width separating rectangular annulus of minimum possible width and an O(n log2 n) algorithm that constructs a minimum width separating concentric square annulus. We also give an opti- mal algorithm that computes a separating orthogonal convex polygon with minimum number of edges, that runs in O(n log n) time. Keywords: Geometric Separability, axis-parallel rectangular annulus, axis-parallel square annulus, orthogonal convex polygon

1. Introduction

In many applications, data is represented using points in Rd. In some of them, each data point belongs to a fixed number of categories or classes. In those cases, data from different classes can be represented by points of different colors. Thus the problems involving multicolored point sets are important in applications like data mining and machine learning. In this paper, we study the separability problem for bichromatic point sets in the plane. Given a bichromatic point set P = R ∪ B, where R represents a set of red points and B represents a set of blue points, the separability problem asks whether there exists a geometric object of a

arXiv:2010.12227v1 [cs.CG] 23 Oct 2020 particular type that separates R and B. The separability problem is closely related to the classifi- cation problem in Machine Learning and has also found applications in areas like Data mining, Computer graphics, Pattern recognition, etc. An important question studied in separability is to decide whether a separator of a particular type exists for a given bichromatic point set. For example, the linear separability question is to decide whether there exists a straight such that

Email addresses: [email protected] (V P Abidha ), [email protected] (Pradeesha Ashok) 1First author is supported by the TCS Research scholar program Preprint submitted to Information Processing Letters October 26, 2020 the blue points and red points are in different half-planes defined by the line. A generalization of this problem to higher dimensions is to check whether there exists a hyperplane that separates red and blue points. Both these problems can be solved in linear time [14]. The separability problem is also studied when the separator is a geometric object like circle, rectangle, convex polygon, etc. [9, 19, 8]. Another set of questions studied in separability is to find a separator that optimizes a given parameter. Edelsbrunner and Preparata [8] gave an algorithm to find a separating convex polygon with the minimum number of edges. However, it is NP-hard to find a separating simple polygon with the minimum number of edges [14]. O’Rourke et al. [16] gave algorithms for deciding separability using circles and to find the smallest and largest separating circles. Hurtado et al. [12] studied the separability problem for wedges and strips. Motivated by applications in urban scene reconstruction using LiDAR data, many researchers [5, 3, 4] considered the separability problem for various rectangular shapes. Rectilinear shapes are particularly important in urban scene reconstruction as many entities like roads and buidings tend to have orthogonal edges. In addition to the papers mentioned above, Sheikhi et al. [17] studied the separability problem for a family of non-convex rectilinear objects called L-shapes and gave polynomial time algorithms. We consider a more general class of these objects, namely rectangular annulus. We also consider the separability problem for a class of objects called orthogonal convex objects, which is a restriction of classical convexity to an orthogonal setting. Problems Studied and Related Work Let P = R ∪ B be a point set in R2 where R is a set of red points and B is a set of blue points and |R| + |B| = n, throughout the paper. For simplicity of explanation, we assume no two points in P have the same x or y coordinate. The separability problem is to find an object C such that all the blue points lie inside or on the boundary of C and all the red points lie outside or on the boundary of C. We study the separability problem for annuli. In general, an annulus refers to the region enclosed between two objects of the same type. In this paper, we study the separability problem for Rectangular and Square annuli of fixed and arbitrary orientation. We define the orientation of a line as the angle it makes with the X-axis. A rectangle/square (and a rectangular/square annulus) has orientation θ if the line containing each of its edges has orientation either θ or θ + π/2. We will now define these objects that we are considering. Rectangular Annulus: A rectangular annulus is a closed region between two rectangles D and D0 of same orientation such that D is contained in D0. For a rectangular annulus A, we shall call the larger rectangle and smaller rectangle that define A as its outer rectangle and inner rectangle respectively. The width of a rectangular annulus on a given side is the distance between the corresponding edges of the outer and inner rectangles. If the width is uniform on all the four sides of an annulus, we call it a uniform width rectangular annulus. Note that the center of inner and outer rectangles are the same in a uniform width rectangular annulus (The converse is not always true). When the width is not uniform on all the four sides, the width of the annulus is defined as the maximum width among the four sides. Square Annulus: A square annulus is a closed region between two squares S and S 0 of same orientation such that S is contained in S 0. The definition of the width of the square annulus is similar to that of the rectangular annulus. If the center (point of intersection of the diagonals) of the outer and inner squares are the same, or equivalently the width is uniform on all the four sides, then we call it a concentric square annulus. For a given bi-chromatic point set, we aim to find separating rectangular and square annuli

2 that minimize the width. A closely related problem that arises in the monochromatic setting is to find an annulus of minimum width that encloses a given point set. Enclosing a point set using a circular annulus of minimum width is studied in [6]. Gluchshenko et al. [11] gave an O(n log n) algorithm to compute a minimum width enclosing rectilinear annulus. Mukherjee et al. [15] gave an O(n) algorithm that computes minimum width enclosing axis-parallel rectangular annu- lus and an O(n2 log n) algorithm that computes minimum width enclosing rectangular annulus in arbitrary orientation. Bae [1] gave an algorithm that runs in O(n3 log n) time that computes the minimum width enclosing square annulus. Another closely related problem in the monochro- matic setting is to find a maximum width empty annulus in a point set. Bae [2] gave algorithms that run in O(n3) and O(n2 log n) time respectively to compute the maximum width empty square and rectangular annulus. Many techniques used for solving the monochromatic problems can be extended for solving the minimum width separating annulus problem. However, the presence of red points poses certain challenges in the separability problem. For instance, it is easy to extend a nonuniform width annulus to a uniform width annulus in the monochromatic setting whereas the two cases are very different in the bichromatic setting. The algorithms presented in this paper makes non-trivial modifications to the existing techniques to solve the bichromatic separability problem. We also consider the separability problem for orthogonal convex objects. Orthogonal Convex Polygon: A polygon C is said to be orthogonal convex if all the edges of C are either horizontal or vertical and the intersection of any vertical or horizontal line with C is either null, a point or a continuous [10]. An orthogonal convex polygon has alternate vertical and horizontal edges and alternate convex and reflex vertices (except for the vertices with highest and lowest x and y coordinates). A polynomial time algorithm to find a separating convex polygon with the minimum number of edges is given in [8]. We extend this result to orthogonal convexity. A summary of the results of this paper are given below. Object Orientation Parameter Running time Nonuniform width Rectangular Annulus Fixed width O(n) Uniform width Rectangular Annulus Fixed width O(n log n) Nonuniform width Rectangular Annulus Arbitrary width O(n3 log n) Uniform width Square Annulus Fixed width O(n log2 n) Orthogonal convex polygon Fixed edges O(n log n) All the above results for the separability problem using minimum width annulus can be ex- tended to the separability problem using maximum width annulus. Notations: For any point p ∈ P, let x(p) and y(p) respectively denote the x-coordinate and y- coordinate values of p . We further use the same notation for vertical and horizontal lines. For a rectangle D, let l(D), b(D), r(D) and t(D) denote the left, bottom, right and top edges of D respectively. For a rectangular (square) annulus A, we refer to the left boundary of A i.e., the union of left edges of the outer and inner rectangles (squares) of A, as the left side of A (similar for other sides). For a point set P, CH(P) denotes the of P.

2. Rectangular Annulus Separability in Fixed Orientation In this section, we consider the Rectangular Annulus Separability problem. For a given bi-chromatic set P, we give an algorithm to find a non-uniform and uniform width separating 3 axis-parallel rectangular annulus A of minimum width.

t(Bout)

t(Bin)

l(Bout) r(Bout)

Rin

Bin

Bout b(Bout)

Figure 1: Non-uniform width rectangular annulus of blue points

0 Let Bout be the smallest axis-parallel rectangle that contains all points of B. Let R be the set 0 of red points inside Bout and Rin be the smallest axis-parallel rectangle that contains R . If Rin contains blue points inside, then a separating rectangular annulus does not exist. If R0 is empty, then the problem can be solved by the algorithm that computes the minimum width enclosing rectangular annulus given in [15]. Lemma 1. A separating axis-parallel (non-uniform width)rectangular annulus of minimum width (if exists) can be constructed in O(n) time.

Proof. Let TA (resp. BA) be the set of all blue points pi inside Bout such that x(l(Rin)) ≤ x(pi) ≤ x(r(Rin)) and y(pi) ≥ y(t(Rin)) (resp. y(pi) ≤ y(b(Rin))). Let RA (resp. LA) be the set of all blue points pi inside Bout such that y(b(Rin)) ≤ y(pi) ≤ y(t(Rin)) and x(pi) ≥ x(r(Rin)) (resp. x(pi) ≤ x(l(Rin))). Define the set T(Bout) as the union of TA and the set of all points pi ∈ B\(BA ∪ RA ∪ LA) such that the perpendicular distance between pi and t(Bout) is not larger than the perpendicular distance between pi and any of the other three edges of Bout. Similarly define the sets B(Bout), R(Bout), and L(Bout) corresponding to the bottom, right and left edges of Bout(Fig 1). Let d(p, l) be the perpendicular distance between p and l, where p is a point and l is a vertical or horizontal line. Therefore T(Bout) = TA ∪ {pi|d(pi, t(Bout)) ≤ min{d(pi, b(Bout)), 0 d(pi, r(Bout)), d(pi, l(Bout))} where pi ∈ B\(BA ∪ RA ∪ LA)}. Let pt be the element of T(Bout) such 0 0 0 0 that d(pt , t(Bout)) = max{d(pi, t(Bout))|pi ∈ T(Bout)}. Similarly define pb, pr and pl from B(Bout), 0 0 0 0 R(Bout) and L(Bout) respectively. Construct Bin as the rectangle that contains pt , pb, pr and pl on 0 its top, bottom, right and left edges respectively. Now the annulus A , defined by Bin and Bout is a separating rectangular annulus. Moreover, by construction, any other rectangular annulus 0 0 0 0 0 0 with width less than that of A cannot contain all points from {pt , pb, pr, pl }, therefore A is a separating rectangular annulus with minimum width. Bin, Rin and Bout can be constructed in O(n) time. We now consider the Rectangular Annulus Separability problem for uniform width axis- parallel rectangular annulus. Let Bout be the set of (at most) four blue points that lie on t(Bout), b(Bout), r(Bout) and l(Bout). Similarly define the set Rin for Rin. Let Fp = Bout ∪ Rin. We call the points in Fp as fixed points. Note that an input point lying on a corner can be considered to be lying on two sides. For example, an input point on the top-left corner of a rectangle is considered as a point on the top edge as well as a point on the left edge. 4 Bout

Bin

Ain

Aout

Figure 2: The dotted lines show the annulus after moving

Theorem 2. A separating uniform width axis-parallel rectangular annulus of minimum possible width (if exists) can be constructed in O(n log n) time.

Proof. Let A be a separating uniform width axis-parallel rectangular annulus of minimum pos- sible width. Let Aout and Ain represent the outer and inner rectangles of A respectively (Fig. 2). Then both Aout and Ain contain at least one blue point on the boundary. Otherwise, we can expand Ain (shrink Aout) to get a rectangular annulus of smaller width. Consider any side of A. If this side does not contain a fixed point on its boundary, then we can move this side parallel to itself, towards the centre of the annulus till it touches a point from Bout or Rin. It is easy to see that the annulus still contains the same set of points inside. Therefore, we can assume that A contains a fixed point each on its four sides and a blue point on the boundary of Ain. The set of four fixed 8 points on the boundary of A can be determined in O( 4 ) time. The fifth input point that lie on the boundary of A belongs to the set B\Fp and can be determined in O(n) time. Thus the set of five 8 points on the boundary can be correctly guessed in O( 4 n) time. For a given set of five points, the uniform width rectangular annulus that contains them on the boundary can be constructed in constant time. By using a data structure like range tree, it can be checked whether a given rect- angular annulus is a separating rectangular annulus by a constant number of orthogonal range searching queries (We need to check whether Ain contains any blue point and Aout contains any red point from R \R0). A range tree can be constructed in O(n log n) time and each range search- ing query can be completed in O(log n) time [7]. Thus all valid separating rectangular annuli can be constructed in O(n log n) time and we can return the one with the minimum width.

3. Rectangular Annulus Separability in Arbitrary Orientation

In this section, we give an algorithm based on the rotating calipers method [18] to find a separating (non-uniform width) rectangular annulus of arbitrary orientation of minimum width. Let P be a set of points and MER(P)θ be the minimum enclosing rectangle of P in orientation θ. MER(P) in any orientation contain points from CH(P) on its four edges. Lemma 3. Let P, Q be two sets of points such that points in Q lie outside CH(P). Then all π θ values of θ ∈ [0, 2 ] where a given point q ∈ Q lies inside MER(P) form a continuous interval. Moreover, for all values of θ in this interval, MER(P)θ contains the same set of points from the convex hull of P on its edges.

5 Proof. Let t, r, b, l ∈ CH(P) respectively be the points that lie on top, right, bottom and left edges of MER(P)θ. The set of orientations θ where t, r, b, l are the points on MER(P)θ also form a continuous interval, say [α1, α2], defined by the orientations of the edges of CH(P) [15]. Consider two of these points which lie on adjacent sides of a minimum enclosing rectangle, say t and r. Then the top right corner of MER(P)θ will lie on a semicircle M with t and r as diameter points. We can consider three more similar semicircles such that any point of Q that lies inside MER(P)θ will also lie in the interior of one of them. Let q ∈ Q be a point that lie in the interior of M. Consider the point q1 where the line connecting q and r intersect the boundary of M. Similarly let q2 be the point where the line connecting q and t intersect the boundary of M. Then, q lies inside any MER(P) whose top-right corner lies between q1 and q2 on the boundary of M. This is precisely all orientations in the interval [γ1, γ2]∩[α1, α2] where γ1, γ2 are the orientations of lines tq1 and tq2 respectively.

Computing All Orientations where a Separating Rectangular Annulus exists : Let R0 be the set of red points inside CH(B). If CH(R0) contains any blue point inside then a separating rectangular annulus does not exist in any orientation. θ θ Let A be a separating rectangular annulus of minimum width in a fixed orientation θ and Aout θ θ θ be the outer rectangle of A . Then Aout is MER(B) and contains four blue points from CH(B) π on its boundary. Similar to the algorithms given in [15], we subdivide the interval [0, 2 ] into primary intervals such that for each orientation θ in a primary interval the set of blue points that lie on the boundary of MER(B)θ is the same. The number of primary intervals is O(k) where k is the number of points on CH(B). θ θ θ θ θ θ θ Let Bout be MER(B) and tb, rb, bb and lb be the blue points on the boundary of Bout, for π θ θ θ θ θ θ θ θ ∈ [0, 2 ]. We define Bout = {tb,rb,bb, lb}. Let R1 be the set of red points inside Aout for a θ θ θ given θ. Assume R1 is non empty (The case where R1 is empty is discussed later). The set R1 may vary in a primary interval based on the value of θ. This happens as some red points that lie outside CH(B) may lie inside MER(B)θ for some values of θ. For such a red point r and a θ primary interval [θi, θ j], the values of θ ∈ [θi, θ j] for which r lies in MER(B) forms a continuous subinterval of [θi, θ j], by Lemma 3. θ In the next step, we further subdivide the primary intervals based on the four points in R1 θ 2 with the smallest perpendicular distance to each side of Aout. For p, q ∈ R , let d(p, q, θ) denote the perpendicular distance between p and a straight line of orientation θ that passes through q. For a fixed p and q, this function is a continuous sinusoidal function. Based on this function, we define d0(r, ., θ), for r ∈ R as follows:

( θ 0 θ ∞ i f r < R1 d (r, tb, θ) = θ (1) d(r, tb, θ), otherwise 0 θ Now if we plot the function d (r, tb, θ) for all r ∈ R, the lower envelope gives the nearest point θ θ to t(Aout) for all θ. Similarly, repeat for other sides of Aout. Thus for every θ, we get a set of four θ θ θ θ θ θ points Rin = {tr , lr , br , rr } that defines the smallest rectangle of orientation θ, Rin, that contains θ all points in R1. We subdivide the primary intervals to secondary intervals, such that for every θ θ angle θ in a secondary interval, the set Bout ∪ Rin is the same. θ For a given θ, if Rin contains any blue point inside, then there is no separating rectangular annulus in orientation θ. In O(n) time we can verify that whether there exists a blue point inside θ θ θ CH(Rin) or not. There may be some blue points lying outside CH(Rin) and inside Rin. Such θ points will also lie in the interior of a semicircle with two defining points from Rin as diameter 6 θ points. By lemma 3, for every blue point b outside CH(Rin), we can compute the interval where θ b lies inside Rin within a secondary interval. Such an interval is now an invalid interval in that if θ belongs to that interval then there is no separating rectangular annulus of orientation θ. We remove the invalid interval corresponding to every blue point from the set of secondary intervals to get a set I of valid sub-intervals. Now we can state the following result. Lemma 4. For all the orientations θ that belong to a valid sub-interval in I, there exists a rectangular annulus of orientation θ which is a separating rectangular annulus for P.

θ θ Proof. Let θ belong to a sub-interval in I. Then there exist eight points in Bout ∪ Rin that will define a rectangular annulus, Nθ. We will show that Nθ is a separating rectangular annulus for P. The outer rectangle of Nθ is a minimum enclosing rectangle of B and contains all blue points θ inside. Also, the inner rectangle contains all red points of Ri inside since we have selected the points with the smallest perpendicular distance to each side of the outer rectangle. Also for each blue point, we have excluded the angles where it comes inside the inner rectangle.

Constructing a Rectangular Annulus of Minimum Width : Now, we will construct Aθ, the sepa- rating annulus of minimum width, for each orientation θ. Note that we know the outer rectangle θ θ θ of A is same as Bout. For each side of Bout, we will define a set of blue points that will lie closer θ to that side in a minimum width separating rectangular annulus. Consider the side t(Bout) that θ θ contains the point tb. Let TA intuitively be the set of blue points that will lie closer to t(Bout) in a minimum width separating rectangular annulus. We will call the points that lie inside a rectangle θ θ θ θ defined by the lines containing edges t(Rin), l(Rin), r(Rin) and t(Bout) as special top points. Clearly, the special top points belong to the set TA. Similarly, we can define the sets BA, LA and RA as special bottom points, special left points and special right points. Of the remaining blue points, θ TA contains all the points whose perpendicular distance to t(Bout) is smaller than the perpendic- θ ular distance to any other side of Bout (Similarly for other sets). Thus at any valid orientation θ, the sets TA, BA, LA, RA gives a partition of all blue points. For a given point b, we can compute the angular interval where it is a special point in constant time. When a point p is not a spe- θ θ θ θ θ cial point, it belongs to the set TA if min(d(p, tb, θ), d(p, lb, θ), d(p, rb, θ), d(p, bb, θ)) = d(p, tb, θ). Now consider the following function, ( d(p, tθ, θ) i f p ∈ T f (p, t, θ) = b A (2) 1 0 else

The upper envelope of the set of functions f1(p, t, θ) for all p ∈ B gives the width of the top side of a separating annulus of minimum width for each θ. By similar methods, we can compute the width of all sides of a separating annulus of minimum width. The value of θ that minimizes the width can be returned. Theorem 5. For a bichromatic point set P, a minimum width separating rectangular annulus of arbitrary orientation can be computed in O(n3 log n) time.

Proof. The algorithm computes the set of primary intervals in O(n log n) time [15]. In order to compute the set of secondary intervals, we compute the function d0(r, ∗, ∗) for all r ∈ R in O(n) time and compute the lower envelope of these functions in O(n log n) time [1]. Computing all valid intervals in a secondary interval includes finding the invalid subintervals corresponding to each blue point and merging all those intervals, which can be done in O(n log n) time. Therefore, finding all the valid intervals over all secondary intervals can be done in O(n2 log n) time. Now, 7 for a valid interval I ∈ I, we need to calculate the upper envelope of all the functions f1(p, ∗, θ) for all p ∈ B. Since the distance function is a sinusoidal function, this can be done in O(n log n) time [1]. Now we will prove that the number of valid intervals is O(n2). Within a secondary interval, a blue point will create at most one invalid interval. Therefore, a secondary interval can contain O(n) valid intervals. Also, any secondary interval can be labeled with exactly one of the following events thus showing that there are O(n) secondary intervals. 1. Addition/Removal of a point from the set Bout . θ 2. Addition/Removal of a red point that lies inside CH(B) to the set Rin. θ 3. Addition/Removal of a red point that lies outside CH(B) to the set Rin. Since there are O(n2) valid intervals, the total running time is O(n3 log n).

4. Square Annulus Separability in Fixed Orientation

In this section, we consider the Square Annulus Separability problem. Given a point set P = R ∪ B, we show how to construct a concentric square annulus of minimum width that separates R and B. Let S denote a separating concentric square annulus of minimum width. Let S out and S in respectively be the outer and inner squares that define S . The definitions of Rin, Bout and fixed points are the same as given in section 2. Both S out and S in contain at least one blue point on its boundary. Also, it can be assumed that S contains four input points on the boundary. In other words, there exists a unique square annulus that contains these four points on the boundary. We say that the square annulus is defined by these four points. Observation 6. S cannot be uniquely defined by four points if one of the following holds. 1. Two points are on adjacent edges of S out and the other two points are on adjacent edges of S in and no two of them are on the same side of S . 2. There is a point each on the left (respectively top) edges of S out and S in and a point each on the right (respectively bottom) edges of S out and S in.

0 Proof. To show case 1, consider a square annulus S with points p1 and p2 respectively on the 0 left and bottom edges of S out and points p3 and p4 respectively on the right and top edges of 0 00 S in. We can construct another square annulus S by moving the bottom and left edges of S in 0 diagonally away/towards the center of S and top and right edges of S out diagonally towards/away 0 00 from the center of S and S still containing p1, p2, p3 and p4 on the boundary. 0 Similarly for case 2, let S be a square annulus that contains the points p1, p2, p3 and p4 on 0 0 0 the left and right edges of S out and S in. If p1, p2, p3 and p4 does not lie on the corners of S out or 0 0 S in, then we can translate S up/down such that it still contains p1, p2, p3 and p4 on its boundary.

Theorem 7. For a given point set P = R ∪ B, a concentric square annulus S of minimum width that separates R and B can be constructed in O(n log2 n) time.

Proof. We start by sorting the blue points and red points by their x and y coordinates. We have seen that four input points are enough to define S . If there are more than two fixed points on the boundary of S then we can find S in O(n log n) time by correctly guessing the defining points in O(n) time and checking the validity of each of these in O(log n) time. Therefore assume S contains a fixed point each on two opposite sides. If 8 X W p3

p1 p2

Y Z

(b)

S in p3 p1 p2 Bout w w

S out

Figure 3: The green lines indicate the square annulus (a) after moving through dotted lines (b) . Figure 4: not, there exist two adjacent sides that do not contain any fixed point. Then we can move these two sides inwards along the diagonal until S out touches a point in Bout or S in touches a point in Rin (Fig. 3). Without loss of generality assume that p1 and p2 lie respectively on the left and right sides of S . There should be at least one point from Bout. Assume p1 ∈ Bout. Now there are two cases based on the point p2.

1. The point p2 is from Rin: The third defining point p3 is a blue point in S in. We can correctly guess this point in O(n) time. a p3 lies on the left edge of S in: Now we know two defining points p1 and p3, that lie on the same side of the annulus. This will give us the width of S and thus we know the four vertical lines that contain the left and right edges of S out and S in. For a correct guess of defining points p1, p2 and p3, Rin lies between the slabs defined by these lines (Fig. 4(a)). By observation 6, we know that the fourth defining point p4 lies on the top or bottom side of S . If this is a blue point, then it lies on S in and is the nearest blue point vertically from Rin. If this is a red point, then it lies on S out and is the nearest red point vertically from Bout. In both the cases p4 can be found in O(log n) time. b p3 lies on the top edge of S in: By p2 and p3 we know the top right corner of S in and hence the line containing one diagonal of S in. The point where this line intersects the vertical line containing p1 is the bottom left corner of S out (Fig. 4(b)). By observation 6, if p4 is a red point, then it lies on the top side or the right side of S out. In the former case, it is the red point with minimum y-coordinate in the region bounded by the lines XY and YW and in the latter case, it is the red point with minimum x-coordinate in the region bounded by the lines YW and YZ. If it is a blue point in S in, then it is the blue point with the highest y-coordinate in the closed polygonal region formed by YW, YZ and the vertical line contain p2.

The argument is symmetric if the third defining point that we guess lies on the bottom edge. 2. The point p2 is from Bout : The case where there are two blue defining points on S in and one of them lies on the left or right edge is similar to 1(a). Otherwise, we construct the rest 9 of the annulus using a slightly different approach. Instead of guessing a defining point we use a technique to find the center c of S and the defining point p that lies on the top or bottom edge of S in. Let r be the radius of S out which is given by half the difference of x-coordinates of the left and right edges of S out. Let l be the vertical line at distance r from left and right edges of S out. The center of the annulus, c, should lie on l on a segment L of length at most 2r. We define a function fp(c) for all p ∈ B, c ∈ l as follows.

 ∞ i f y(t(R )) < y(p) < y(b(R ))  in in  ∞ i f y(p) > y(t(R )) and y(c) >  in  (y(p) + (y(b(R ))))/2 f (c) =  in (3) p  ∞ i f y(p) < y(b(R )) and y(c) <  in  (y(t(R )) + y(p))/2  in  |y(p) − y(c)| otherwise

Intuitively, fp(c) gives the radius of the square centered at c and contains p on the top or bottom edge and contains all red points in Rin inside it. For a fixed c, a square centered at c that contains Rin inside and all the blue points outside has radius at most minp∈B fp(c). Moreover, a square S in that minimizes the width has radius maxc∈L(minp∈B fp(c)). It is easy to see that, for a given p the graph of fp(c) is a straight line segment Lp of slope +1 or −1. Hence maxc∈L(minp∈B fp(c)) is the maximum value of the lower envelope in the arrangement of Lp, for all p ∈ B. Computing the lower envelope of an arrangement of n line segments can be done in O(n log n) time [1]. Thus, S should have the defining points in one of a constant number of configurations. In the configuration as in case (1) above, we can correctly guess the defining points in O(n log n) time and each guess can be validated in O(log n) time. Then the total running time for this case is O(n log2 n). A configuration as in case (2) can be solved in O(n log n) time. Thus a separating square annulus of minimum width can be computed in O(n log2 n) time.

Degenerate cases in Annulus separability

The algorithms given in sections 2, 3 and 4 may need slight changes for some degenerate cases. The case where Bout does not contain any red point becomes equivalent to the minimum enclosing rectangle/square annulus problem in monochromatic setting and can be solved by the algorithms given in [15, 1]. Also, there are cases where one or more sides of the minimum width annulus are at infinity. Such cases can be solved by algorithms that compute separating unbounded L-shapes, separating strips, etc. These can be computed using the same ideas as given above without decreasing the overall efficiency of the algorithm.

5. Separability using Annulus of Maximum Width

We can use the algorithms described above with slight modifications to find the separating annulus of maximum width. For the sake of completeness, we now describe the algorithm to construct the separating concentric square annulus of maximum possible width. Other algorithms in sections 2 and 3 can be modified in a similar way for the corresponding maximum width annulus separability problem. 10 Theorem 8. A separating concentric square annulus of maximum width can be constructed in O(n log2 n) time.

Proof. Let S max be a separating concentric square annulus of maximum width. S max contains four input points on its boundary as specified in observation 6. Let S be a separating concentric square annulus of maximum possible width. Let S out and S in represent the outer and inner square of S max respectively. If there are more than two fixed points on the boundary of S max then we can find S max in O(n log n) time by correctly guessing the defining points in O(n) time and checking the valid- ity of each of these in O(log n) time. Therefore assume S max contains a fixed point each on two opposite sides. If not, there exist two adjacent sides that do not contain any fixed point. Then we can move these two sides outwards along the diagonal until S out touches a point in Bout or S in touches a point in Rin. Without loss of generality assume that p1 and p2 lie respectively on the left and right sides of S max. There should be at least one point from Rin. Assume p1 ∈ Rin. Now there are two cases based on the point p2.

1. The point p2 is from Bout : A third defining point p3 is a red point in S out. We can correctly guess this point in O(n) time. There are two cases,

a p3 lies on the left edge of S out: Now we know two defining points p1 and p3 that lie on the same side of the annulus. This will give us the width of S max and thus we know the four vertical lines that contain the left and right edges of S out and S in. For a correct guess of defining points p1, p2 and p3, Rin lies between the slabs defined by these lines. By observation 6, we know that the fourth defining point p4 lies on the top or bottom side of S max. If this is a blue point, then it lies on S in and it is the nearest blue point vertically from Rin. If this is a red point, then it lies on S out and it is the nearest red point vertically from Bout. In both the cases p4 can be found in O(log n) time. b p3 lies on the top edge of S out: Now by p2 and p3 we know the top right corner of S out and hence the line containing one diagonal of S out. The point where this line intersects the vertical line containing p1 is the bottom left corner of S in . By observation 6, if p4 is a red point then it lies on the top side or right side of S in . The argument is symmetric if the third defining point that we guess lies on the bottom edge.

2. The point p2 is from Rin : The case where there are two red defining points on S in and one of them lies on the left or right edge is similar to 1(a). Otherwise, we construct the rest of the annulus using similar function in concentric square annulus with minimum width. Instead of guessing a defining point we use a technique to find the center c of S max and the defining point p that lies on the top or bottom edge of S in . Let r be the radius of S out which is given by half the difference of x-coordinates of the left and right edges of S out. Let l be the vertical line at distance r from left and right edges of S out. The center of the annulus, c, should lie on l on a segment L of length at most 2r. We define a function fp(c) for all p ∈ B, c ∈ l as follows.

11  ∞ i f y(t(B )) < y(p) <  out  y(b(B ))  out  ∞ i f y(p) > y(t(B )) and  out f (c) =  y(c) > (y(p) + (y(b(B ))))/2 (4) p  out  ∞ i f y(p) < y(b(B )) and  out  y(c) < (y(t(B )) + y(p))/2  out  |y(p) − y(c)| otherwise

intuitively, fp(c) gives the radius of the square centered at c and contains p on the top or bottom edge and contains all red points in Rin inside it. For a fixed c, a square centered at c that contains Rin inside and all the blue points outside has radius at most minp∈B fp(c). Moreover, a square S in that minimizes the width has radius maxc∈L(minp∈B fp(c)). It is easy to see that, for a given p the graph of fp(c) is a straight line segment Lp of slope +1 or −1. Hence maxc∈L(minp∈B fp(c)) is the maximum value of the lower envelope in the arrangement of Lp, for all p ∈ B. Computing the lower envelope of an arrangement of n line segments can be done in O(n log n) time [1]. Thus, S should have the defining points in one of a constant number of configurations. In the configuration as in case(1) above, we can correctly guess the defining points in O(n log n) time and each guess can be validated in O(log n) time. Then the total running time for this case is O(n log2 n). All other cases can be solved in less time. Thus a separating square annulus of minimum width can be computed in O(n log2 n) time.

6. Orthogonal Convex Separability

In this section, we give an algorithm to compute the separating orthogonal convex polygon that minimizes the number of edges. Construct the orthogonal convex hull, H, of B in O(n log n) time [13]. The orthogonal convex hull of a point set P is defined as the smallest area orthogonal convex polygon that contains P. The convex vertices of the orthogonal convex hull of P are points from P. If H contains red points inside then a separating orthogonal convex polygon does not exist. For a given point p, we can check whether p lies inside H in O(n log n) time. Thus the existence of a separating orthogonal convex polygon can be decided in O(n log n) time. We now discuss how to construct a separating orthogonal convex polygon, C, that minimizes the number of edges. Theorem 9. For a given bichromatic point set with n points, a separating orthogonal convex polygon with minimum number of edges can be computed in O(n log n) time.

Proof. Let H be the set of vertices of H. Let pl, pb, pr and pt respectively be the leftmost, bottommost, rightmost and topmost points in H. Let Plb be the left-bottom chain in H i.e., the orthogonal path in H from pl to pb. We show how to minimize the number of edges in the left-bottom chain of a separating orthogonal convex polygon. The algorithm is as follows: Let {p1, p2,..., pk} be the convex vertices in Plb taken in counter-clockwise direction. Note that p1 = pl and pk = pb. For the purpose of our algorithm, we are only considering the convex vertices of Plb. Note that p1 and pk are considered to be convex and the convex vertices can uniquely determine the chain Plb. Let pi be a vertex in this chain. pi and pi+1 are connected in H by two axis-parallel line segments such that the horizontal line segment passes through the point 12 p1 p1

Rp1 p2

p2 p0 0 1 p1 p2

p3 0 p2 p3

Figure 6: Inward and outward edges of or- Figure 5: Orthogonal Convex hull of blue points thogonal convex hull

pi and the vertical segment passes through the point pi+1. Let us denote this as the inward edge between pi and pi+1. Similarly, let the outward edge denote the path comprising of two axis- parallel edges such that the horizontal line segment passes through the point pi+1 and the vertical 0 segment passes through the point pi. Here, let pi denote the point of intersection of the two axis- parallel lines. Let Rpi,pi+1 be the rectangle with pi and pi+1 as the diagonal points (see Fig. 6). Starting with p1, we iteratively check every vertex of Plb and see if it can be deleted by replacing the inward edge by the outward edge. Specifically, for all i, 1 ≤ i < k, we check if the rectangle

Rpi,pi+1 contains red points inside. If not, we replace the inward edge between pi and pi+1 by the 0 outward edge. In this process, we delete the vertices pi and pi+1 and add the vertex pi to the chain. i = 1, q1 = p1. while( i < k ) q2 = pi+1.

if Rq1,q2 has a red point, then q1 = q2. else 0 0 delete pi, qi+1 from C and add pi to C, q1 = pi i = i + 1. end while.

This algorithm returns the left-bottom chain of C. To show the correctness, we prove that the left bottom chain of any separating orthogonal convex polygon has at least as many inward edges as returned by our algorithm. Consider a configuration of points b1, b2, r such that b1, b2 ∈ B, r ∈ R and r is contained in a rectangle with b1 and b2 as diagonal vertices. For an orthogonal convex polygon to include b1 and b2 and exclude r, it should have at least one inward edge. Let {q1, q2,..., qk0 } be the set of vertices returned by the algorithm. By the description of the algorithm, every vertex qi is a blue point or the vertical edge that contains qi has a blue point above qi. By this property, for an inward edge between qi and qi+1, there is a rectangle Ri such that Ri has two blue points as diagonal points and contains a red point inside. Moreover, for all 0 i, j, 1 ≤ i, j < k , Ri and R j do not intersect in the interior. This shows that the algorithm returns a chain with the minimum possible number of inward edges possible. We run similar algorithms for all other chains of H- Pbr, Prt and Ptl. C is given by the union of these four chains. Constructing the orthogonal convex hull takes O(n log n) time [13]. At every step in the

13 algorithm, we check a rectangle Rp,q for red points where p and q are consecutive vertices in the separating polygon constructed so far. After every check, one of these points is deleted from the set of vertices to be considered. Therefore, the number of iterations is linear in the number of points in the orthogonal convex hull. Each check takes O(log n) time. Therefore, the algorithm runs in O(n log n) time.

The following lemma proves that the above algorithm is also optimal. Lemma 10. Computing a separating orthogonal convex polygon with minimum number of edges needs Ω(n log n) time.

Proof. We give a reduction from the sorting problem. Let S = {x1, x2, ..xn} be an instance of sorting. We create an instance of separating orthogonal convex polygon problem C corresponding to S as described below.

2 • For every xi in S, we add a blue point pi = (xi, xi) in IR to C.

2 • For every xi in S, we add a red point ri = (xi+ , xi+ ) in IR , where 0 <  < 1. It is easy to see that the separating orthogonal convex polygon of C is given by a sorted order of S. Since a sorting problem needs Ω(n log n) time, the result follows.

References

[1] Sang Won Bae. Computing a minimum-width square annulus in arbitrary orientation. Theoretical Computer Science, 718:2 – 13, 2018. [2] Sang Won Bae, Arpita Baral, and Priya Ranjan Sinha Mahapatra. Maximum-width empty square and rectangular annulus. Springer International Publishing. pages 69–81, Cham, 2019. [3] Thijs van Lankveld, M.J. Kreveld, and Remco Veltkamp. Identifying well-covered minimal bounding rectangles in 2d point data. Abstracts 25th Europ. Workshop Comput. Geom., 01 2009. [4] Thijs van Lankveld, Marc van Kreveld, and Remco Veltkamp. Identifying rectangles in laser range data for ur- ban scene reconstruction. Computers & Graphics, 35(3):719 – 725, 2011. Shape Modeling International (SMI) Conference 2011. [5] Marc van Kreveld, Thijs van Lankveld, and Maarten de Rie. (α, δ)-Sleeves for Reconstruction of Rectilinear Building Facets, pages 231–247. Springer Berlin Heidelberg, Berlin, Heidelberg, 2013. [6] Mark de Berg, Prosenjit Bose, David Bremner, Suneeta Ramaswami, and Gordon Wilfong. Computing constrained minimum-width annuli of point sets. Computer-Aided Design, 30(4):267 – 275, 1998. [7] Mark de Berg, Otfried Cheong, Marc J. van Kreveld, and Mark H. Overmars. Computational : algorithms and applications, 3rd Edition. 1997. [8] H. Edelsbrunner and F.P. Preparata. Minimum polygonal separation. Information and Computation, 77(3):218 – 232, 1988. [9] S. Fisk. Separating point sets by circles, and the recognition of digital disks. IEEE Transactions on Pattern Analysis and Machine Intelligence, PAMI-8(4):554–556, 1986. [10] Burkay Genc¸, Cem Evrendilek, and Brahim Hnich. Covering points with orthogonally convex polygons. Compu- tational Geometry, 44(5):249 – 264, 2011. [11] Olga N Gluchshenko, Horst W Hamacher, and Arie Tamir. An optimal o (nlogn) algorithm for finding an enclosing planar rectilinear annulus of minimum width. Operations Research Letters, 37(3):168–170, 2009. [12] Ferran Hurtado, Marc Noy, Pedro A. Ramos, and Carlos Seara. Separating objects in the plane by wedges and strips. 14th European Workshop on Computational Geometry. Discrete Applied Mathematics, 109(1):109 – 138, 2001. [13] Rolf G. Karlsson and Mark H. Overmars. Scanline algorithms on a grid. BIT Numerical Mathematics, 28(2):227– 241, Jun 1988. [14] Nimrod Megiddo. On the complexity of polyhedral separability. In Discrete and computational geometry, pages 325–337, 1988.

14 [15] Joydeep Mukherjee, Priya Ranjan Sinha Mahapatra, Arindam Karmakar, and Sandip Das. Minimum-width rectan- gular annulus. Theoretical Computer Science, 508:74–80, 2013. [16] Joseph O’rourke, S Rao Kosaraju, and Nimrod Megiddo. Computing circular separability. Discrete & Computa- tional Geometry, 1(2):105–113, 1986. [17] Farnaz Sheikhi, Ali Mohades, Mark de Berg, and Mansoor Davoodi. Separating bichromatic point sets by L-shapes. Computational Geometry, 48:673–687, 2015. [18] G Toussaint. Applications of the rotating calipers to geometric problems in two and three dimensions. International Journal of Digital Information and Wireless Communications (IJDIWC), 4(3):372–386, 2014. [19] Marc van Kreveld, Thijs van Lankveld, and Remco Veltkamp. Identifying well-covered minimal bounding rectan- gles in 2d point data. In 25th European Workshop on Computational Geometry, pages 277–280, 1999.

15