<<

CCCG 2011, Toronto ON, August 10–12, 2011

Finding the Maximum in a Convex

Kai Jin⇤ Kevin Matulef⇤

Abstract simplest that are “centrally-symmetric” (i.e. for which there exists a “center” such that every We consider the problem of finding the maximum area on the figure, when reflected about the center, pro- parallelogram (MAP) inside a given . duces another point on the figure). It is natural to Our main result is an algorithm for computing the MAP ask whether we can, in general, compute the Maximum in an n-sided polygon in O(n2) time. Achieving this Area Centrally-symmetric convex body (MAC) inside running time requires proving several new structural a given convex polygon or convex curve. Although it properties of the MAP, and combining them with a ro- seems dicult to compute the area of the MAC exactly, tating technique of Toussaint [10]. it is known that the MAP serves as an approximation:1 We also discuss applications of our result to the problem of computing the maximum area centrally- Theorem 2 [5, 8] For a convex curve Q,theareaof symmetric convex body (MAC) inside a given convex the MAP inside it is always at least 2 0.6366 times ⇡ ⇡ polygon, and to a “fault tolerant area maximization” the area of Q, Moreover, this bound is tight; the worst problem which we define. case is realized when the given convex curve is an .

Theorem 2 follows from two results.2 The first result 1 Introduction of Dowker [5] says that for any centrally-symmetric con- vex body K in the plane, and any even n 4, among A common problem in computational is that of finding the largest figure of one type contained in a the inscribed (or contained) convex n-gons of maximal given figure of another type. Over the last 30 years re- area in K, there is one which is centrally-symmetric. searchers have looked at several instances of this prob- The second result of Sas [8] says that for convex bodies d lem, such as finding the largest convex polygon con- in R , the hardest to approximate with inscribed n-gons tained in an arbitrary polygon [2], the largest axis- are exactly the ellipsoids. in an arbitrary polygon [3] , the largest By combining Theorem 2 with our Theorem 1, we get inscribed in a convex polygon [4], the largest k- the following corollary. gon in a convex polygon [1], or the largest in a Corollary 3 There is a 2 -approximation algorithm for convex polygon [7]. ⇡ computing the area of the MAC in O(n2) time. In this work, we consider the problem of finding the maximum area parallelogram (MAP) inside a convex polygon. Our main result is the following: Fault Tolerant Area Maximization. Consider the following general problem: you are allowed to place k Theorem 1 There is an algorithm for computing the points inside a polygon P , then an adversary removes MAP in a convex polygon with n sides in O(n2) time. j of them (where j

non-trivial case is FTA(4, 1). In this case, we show problem on and is to find the largest polygon from that computing FTA(4, 1) reduces to the problem of inside a givenP polygonQ from (here “largest” can computing both the maximum area triangle (which can beQ with respect to area, perimeter,P or other measures). be done using Boyce et. al.’s algorithm) and the MAP. Chang and Yap surveyed several results on the inclu- Thus, we get the following corollary to our main theo- sion problem for specific and , although to date no rem (due to space limitations, we present the proof of unified solution exists. ForP di↵erentQ and ,itseems this corollary in the Appendix). di↵erent techniques must be employed.P TheQ problem we solve in this work is the specific case where is the set Corollary 4 (Reduction) Computing FTA(4, 1) in a of convex polygons, and is the set of parallelograms.P convex polygon P can be done in O(n2) time. For the case where Qis the set of convex polygons, the inclusion problemP has been studied for several dif- 1.2 Techniques ferent . For example, given a convex polygon P with n vertices,Q Shamos [9] gave an algorithm for finding the di- We start by proving the relatively simple fact that the ameter of P in linear time (this corresponds to being MAP inside a convex polygon P must have all of its cor- the set of “one-” polygons). Dobkin and SnyderQ [4] ners on the perimeter of P . This suggests the possibility gave a linear time algorithm for finding the maximum of an algorithm that works by enumerating all 4-tuples area triangle; Boyce, Dobkin, Drysdale and Guibas [1] of edges of P , and for each 4-tuple finding the largest gave an algorithm for finding maximum area/perimeter parallelogram with one corner on each edge. Such an k-gons in time O(knlgn + nlg2n). De Pano Ke and algorithm would, at best, run in O(n4)time. O’Rourke [7] gave an algorithm for finding the largest To reduce the search space, we further prove that the inscribed square in time O(n2); Fekete [6] gave an al- MAP must be anchored on P . In other words, it must gorithm for finding all anchored squaresin O(n log2 n) have at least one corner on a of P .Weprovethis time; For the case where is the set of all simple poly- via a lemma we call the “hyperbola lemma” which may gons, Daniels, MilenkovicP and Roth [3] gave an algo- be of independent interest (see Section 2.2). We then rithm for finding the maximum area axis-parallel rect- divide the computation of the MAP into two cases: one in time O(n log2 n). where the MAP has two opposite, non-anchored corners, and one where it has two adjacent, anchored corners. 2Preliminaries For the first case, we prove that for every pair of edges of P , finding the MAP with opposite non-anchored cor- 2.1 Basic notations and lemmas ners on those edges involves checking only O(n) possi- bilities for the placement of the other corners. As there We will use symbols A, B, A0,B0 to denote the four cor- are O(n2) pairs of edges, in total this yields an O(n3) ners of a parallelogram Q = ABA0B0 (the pairs A, A0 algorithm. In order to speed it up further, we employ a and B,B0 denote opposite corners). We will use the rotating technique of Toussaint [Tou83]. The main idea symbol E to denote the center of Q. is to show that if the pairs of edges are processed in the right order, the amortized cost of computing the best Definition 5 (Inscribed) We say a parallelogram Q placement for the other corners is only O(1). Proving is inscribed on a polygon P if and only if all four cor- this requires proving additional structural properties of ners of Q are on the boundary of P . the MAP (see Section 3.1). Definition 6 (Anchored) We say a parallelogram Q For the second case, when the MAP has two adjacent is anchored on a polygon P if it is inscribed on P and corners anchored on P , the algorithm is slightly more at least one of its corners lies on a vertex of P . complicated, but uses similar ideas and still has running 2 time O(n ) (see Section 3.2). Definition 7 (Narrow side & Broad side) Suppose b, b0 are two nonparallel edges of P . They 1.3 Related Work divide the other edges of P into two sets, the edges in the Narrow side (where the extended lines of b and In [2], Chang and Yap gave an algorithm for the “potato b0 intersect) and the edges in the Broad side (where b peeling” problem, or the problem of finding the largest and b0 are further apart), illustrated in Figure 1. convex polygon Q inside a given P with n sides. They showed that this problem is computable in polynomial time, by giving algorithms computing the Lemma 8 The parallelogram inside P with the maxi- maximum area Q in O(n7), and the maximum perime- mum area must be inscribed on P . ter Q in O(n6). Their investigation led them to define the general notion of “inclusion” problems for arbitrary Proof. We prove this by contradiction. Suppose Q = classes of polygons and . The goal of the inclusion ABA0B0 is a parallelogram which has maximal area in P Q CCCG 2011, Toronto ON, August 10–12, 2011

Lemma 10 (Two Segments Lemma) There is a segment connecting b and b0 with E,ifand only if E is inside of P (b, b0).

The proof of Lemma 10 is also simple; due to space constraints we omit it.

Figure 1: Broad side and Narrow side

P but is not inscribed in P (See Figure 2). Without loss of generality, assume A is a vertex which is not on the boundary of P . First, we slide segment AB along direction BA~ for a suciently small distance to ~ create A1B1. Next we slide it along direction B0A1 Figure 3: Two lines lemma and two segments lemma for a suciently small distance to create A2B2 where A2 and B2 are still inside P . It’s easy to see that Note that for a parallelogram Q with center E and Area(ABA0B0) < Area(A2B2A0B0). ⇤ opposite corners B and B0 located on b and b0 respec- tively, we know E P (b, b0) because E is the midpoint 2 of the BB0.

2.2 The Hyperbola Lemma

Definition 11 For two nonparallel lines b1,b2 inter- secting at O,andapointA strictly in-between them, there is a unique hyperbola asymptotic to b1 and b2 and b1,b2 intersecting A, denoted as hA (or hA for short). Let b1,b2 CA (or CA for short) denote the distance from O to the nearest point on hA. Figure 2: Illustration of Theorem 8 Lemma 12 (Hyperbola Lemma) Suppose b, b0 are two nonparallel lines which intersect at origin O. Let h1 and h be two hyperbolas which are both asymptotic to Lemma 8 says if a parallelogram Q = ABA0B0 is the 2 MAP of a polygon P , then all its corner must lie on the b and b0. Then all parallelograms Q = ABA0B0, where A, B, A ,B lie on h ,b,h ,b respectively, have the same boundary of P . For points A, B, A0, B0 that do not lie 0 0 1 2 0 on vertices of P , we will use the lowercase letters a, b, area. a0, b0 respectively to denote the edges of P they lie on.

Lemma 9 (Two Lines Lemma) Given two nonpar- allel lines b, b0 and one point E not on them, there is exactly one segment connecting b and b0 with midpoint E. Moreover, the endpoints of this segment, denoted as B and B0, can be computed in constant time.

This lemma is simple; we omit its proof. Next we introduce the segment version of Lemma 9, it will be used many times in our algorithm. Suppose there are two segments b = B1B2 and b0 = B3B4 which, when extended, intersect at point O. For 1 i 4, let Mi be the midpoint of OBi (see Figure 3). Figure 4: Hyperbola Lemma (orthogonal case)   We draw a parallelogram P (b, b0) such that one pair of sides is parallel to b and crossing M3 and M4, and the other pair of sides is parallel to b0 and crossing M1 and Proof. We will prove the lemma in the case when b and M2. b0 are orthogonal. The general case follows from a linear transformation. 23rd Canadian Conference on Computational Geometry, 2011

Build a Cartesian coordinate system with origin O the position of A0 so that CA0 doesn’t change. After- and let b0,b be the x-axis and y-axis (see Figure 4). ward we replace the new center E by the midpoint of Suppose the coordinates of A and A0 are (x1,y1) and segment AA0. Then according to Lemma 9, B and B0 (x2,y2)respectively.ThecenterE is the midpoint can be computed since b0,b0, and E are all fixed. We can x1+x2 y1+y2 of AA0, and thus has coordinates ( 2 , 2 ). By make sure that B,B0 will still be inside segments b, b0 re- Lemma 9, the coordinates of B and B0 are uniquely spectively by only moving A for a suciently small dis- determined, and are easily verified to have coordinates tance. We know that the area of this new parallelogram (0,y1 + y2) and (x1 + x2, 0). Thus, we can compute is larger than the area of Q according to Lemma 12. area(Q)=x2y2 x1y1.Sinceh1 and h2 are hyperbolas Hence Q is not the MAP in P . ⇤ 2 asymptotic to b and b0, this means x1y1 = CA/2 and 2 2 2 x2y2 = C /2. Hence, area(Q)=C /2 C /2, which Theorem 15 leads one to wonder whether the MAP A0 A0 A is invariant. ⇤ must always be double-anchored on P (that is, whether the MAP must have two of its corners on vertices of We will apply the hyperbola lemma with b and b0 P ). Unfortunately, this is not the case. Figure 9 in equal to extensions of edges of the original polygon P . the Appendix illustrates an example where the double- Note that to find the maximum area parallelogram in anchored MAP is smaller than the actual MAP. P with one vertex on b and another on b0, we should To design our algorithm for finding the MAP, we di- choose A and A0 so as to maximize CA0 and minimize vide anchored parallelograms into two cases, described CA. However, this is trickier than it seems, since if we by the following definitions: are allowed to choose A and A0 arbitrarily, the resulting B and B0 may not actually lie on the original edges of Definition 16 We say that a parallelogram Q is the polygon (which are just segments, not lines). We adjacent-double-anchored on a polygon P if it is in- discuss this complication further in Section 3.1. scribed on P and two adjacent corners lie on the vertices of P . Definition 13 Let b, b0 be two nonparallel edges, and let c be an edge in the broad side. Then we use Xc to Definition 17 We say that a parallelogram Q is denote the intersection point of b and the extended opposite-free-anchored on a polygon P if it is an- of c, Yc to denote the intersection point of b0 and the chored on P but has two opposite corners which are not extended line of c,andZc to denote the midpoint of anchored. XcYc. Note that for a parallelogram Q anchored on P ,it Lemma 14 Suppose D is a point on segment XcYc. must either be adjacent-double-anchored, or opposite- Then CD increases while D goes from Xc to Zc,and free-anchored; it cannot be both. while D goes from Yc to Zc.

Proof. We only need to prove it in the case when b and 3 The Algorithm b0 are orthogonal, for the same reason used in Lemma 12. In this section we describe our algorithm for finding the Without loss of generality, assume b, b0 are on the x, y- MAP in a convex polygon. Our general algorithm will axis respectively, Xc =(x0, 0),Yc =(0,y0). Assume actually consist of two algorithms, one to handle the D =(x, y0 x(y0/x0)). It’s not hard to show that case when the MAP is opposite-free-anchored, and the CD = 2 x [y0 x(y0/x0)]. Note x [y0 x(y0/x0)] ⇤ ⇤ ⇤ x0 other to handle the case when the MAP is adjacent- is a quadratic equation maximized when x = . ⇤ p 2 double-anchored. Both algorithms use similar ideas, and have running time O(n2). 2.3 The Anchor Theorem

Theorem 15 (Anchor Theorem) The MAP in P 3.1 The Opposite-Free-Anchored Case must be anchored on P . First we give an algorithm for finding the MAP when

Proof. Suppose Q = ABA0B0 is a parallelogram in- the MAP is opposite-free-anchored. Without loss of scribed but not anchored on P . We will show that Q generality, assume that B,B0 are not anchored, and is not the MAP in P . First, assume neither pair a, a0 are inscribed on b, b0 respectively. Let A be the ver- nor b, b0 is parallel to each other, otherwise the theorem tex in the narrow side and A0 in the broad side. Let is trivial to prove. Assume a is in the narrow side. We Mb1,b2 (M for short) be the point in P such that b1,b2 b1,b2 can construct a new parallelogram as follows. Since A CM = max CV V P . For fixed b and b0,the is not on an endpoint of a, we can move A alittlebit following corollary{ of| Lemma2 } 14 helps us compute the along a so that CA decreases (see Lemma 14). We keep optimal placement of M. CCCG 2011, Toronto ON, August 10–12, 2011

1 foreach edge b P ,b0 P do 2 2 2 foreach vertex V P , V not on b or b0 do 2 3 A0 V if C >C . V A0 4 end 5 foreach edge c P, c = b, c = b0 do 2 6 6 6 A0 Z if C >C and Z P . c Zc A0 c 2 7 end 8 foreach vertex A P , A not on b or b0 do Figure 5: Either M = Zc (pictured at left), or M is on 2 9 E the midpoint of AA0. a vertex of P (pictured at right) 10 Compute B,B0 by Lemma 9. 11 Q ABA0B0 if Area(ABA0B0) > Area(Q)

Corollary 18 There is at most one edge c in the broad and ABA0B0 is inside P . side such that Zc actually lies on c. When there is such 12 end an edge, then M = Zc. When there is not such an edge, 13 end then M is on a vertex formed by two edges denoted c Algorithm 1: opposite-free-anchored and d.ThepointZc lies to the right of M,andthe point Zd lies to the left of M (see Figure 5). We are now ready to prove one of the main theorems Suppose we fix an edge b, and consider the sequence of behind our algorithm in the opposite-free-anchored case. pairs (b, b10 ), (b, b20 ), (b, b30 ),..., where the edge sequence b0 ,b0 ,b0 ,... is formed by walking counter-clockwise Suppose B and B0 are non-anchored vertices on fixed 1 2 3 along the boundary of P . Let Ai and A0 be the edges b and b0. The following theorem reduces the com- i optimal values computed for the pair (b, b0 ). Then it is putation of the optimal placement of A and A0 to a finite i set of possibilities: possible to show that the sequences A1,A2,A3,...,and A10 ,A20 ,A30 ,..., also move counter-clockwise along the Theorem 19 Suppose Q is the opposite-free-anchored boundary of P . Thus, for a fixed b, we only spend O(n) MAP on P , where B and B0 are located on (non- time calculating all values of Ai and Ai0 . Repeating 2 endpoints) of b and b0, A is in the narrow side and A0 with all other edges in place of b yields an O(n )time is in the broad side. Then A0 = M,andA is anchored algorithm. on P . To prove this, there are two stages in Algorithm 1 Proof. From Corollary 18, we know that if a dynamic that need to be analyzed carefully. For every pair (b, b0), point D goes from one end in the broad side to another, the first stage (lines 2-7) takes O(n)timetofindA0, CD will increase before D reaches M, and decrease after the second stage (lines 8-12) also takes O(n)timeto D reaches M.SoifA0 = M, there exists an A⇤ P enumerate all the vertices in the narrow side to find A. near A such that C >C6 . Then, as in the proof2 of 0 A⇤ A0 To show that the first stage can be made to have small Theorem 15, we should be able to slightly adjust B and amortized cost, we cite the following lemma: B0 (still on b and b0) to construct a new parallelogram with vertices A⇤,A, and two vertices on b, b0, which has Lemma 20 (A monotone property of A0) area bigger than that of Q. This is a contradiction. Suppose b is fixed, and b0 moves counter-clockwise Similarly, suppose A is not anchored on P .Thereex- along P . Then the distances between A0 and b are ists a point A⇤ near A such that CA

that the best choice of A0 is not equal to M, or that the best choice of A is not on a vertex of P . Nevertheless, when we assume the MAP has two ad- jacent anchored vertices, we can still prove some con- straints on the placement of the other vertices. This al- lows us to develop an algorithm similar to Algorithm 1 that enumerates over all choices of anchored vertex B and opposite edge b0. If implemented correctly, this al- gorithm can be made to run in O(n2) by showing an amortized analysis similar to the one we used before. Figure 6: P (b, b ) is the region where A might lie. A0 0 Due to space limitations, we present the full details of our algorithm in the adjacent-double-anchored case Proof. First, P (b, b ) are parallelograms, two sides of in the Appendix. Ai0 i0 which are parallel to b.Whileb0 is shifting, the dis- tances between P (b, bi0 ) and line b is decreasing, and the Acknowledgments distances between A and line b is non-decreasing, so the i0 The authors are grateful to the anonymous reviewers distances between PA (b, b0 ) and b is decreasing. Thus, i0 i of an earlier version of this paper for pointing out the they do not overlap with each other. ⇤ references [5, 8] and for other helpful comments. In line 8 of Algorithm 1, if we replace “A P ”with The authors would also like to thank Xiaoming Sun, 2 Tiancheng Lou, and Zhiyi Huang for taking part in “A PA0 (b, b0)”, then for a fixed b each vertex A will be enumerated2 at most once. Hence the this stage can fruitful discussions. be reduced to O(1) time on average, and therefore Al- gorithm 1 can be implemented in O(n2) time total. References [1] J. E. Boyce, D. P. Dobkin, R. L. Drysdale, III, and L. J. Guibas. Finding extremal polygons. In Proc. of the 14th annu. ACM symp. on Theory of comp.,STOC ’82, pages 282–289, New York, NY, USA, 1982. ACM. [2] J. Chang and C. Yap. A polynomial solution for the potato-peeling problem. Discrete and Computational Geometry,1:155–182,1986.10.1007/BF02187692. [3] M. Daniels and Roth. Finding the largest area axis- parallel rectangle in a polygon. CGTA: Computational Geometry: Theory and Applications,7,1997. [4] D. Dobkin and L. Snyder. On a general method for maximizing and minimizing among certain geometric problems. In Proceedings of the 20th Annual Symposium on FOCS,pages9–17.IEEEComputerSociety,1979. [5] C. Dowker. On minimum circumscribed polygons. Bull. Amer. Math. Soc,50:120–122,1944. [6] S. P. Fekete. Finding all anchored squares in a con- vex polygon in subquadratic time. In Proc. 4th Canad. Figure 7: Illustration of Algorithm 1 Conf. Comput. Geom.,pages71–76,1992. [7] J. O. N. Adlai De Pano, Yan Ke. Finding largest in- scribed equilateral and squares. In Proc. Aller- ton Conf.,pages869–878,1987. 3.2 The Adjacent-Double-Anchored Case [8] E. Sas. ¨uber ein extremumeigenschaft der ellipsen. Next we give an algorithm for finding the MAP when Compositio Math,6:468–470,1939. the MAP is double-adjacent-anchored. [9] M. Shamos. Computational geometry. 1978. While it is tempting to just run Algorithm 1 and hope [10] G. Toussaint. Solving geometric problems with the ro- that it works in this case too, unfortunately it does not. tating calipers. In Proc. IEEE Melecon,volume83, The reason is that Theorem 19 crucially assumes that pages 1–4. Citeseer, 1983. B and B0 are flexible on b and b0, in order to reduce the space of possible values for A and A0. Without the guarantee that B and B0 are not anchored, it is possible