Finding Largest Rectangles in Convex PolygonsSupported by the Slovenian Research Agency, program P1-0297, projects J1-4106 and L7-5459; by the ESF EuroGIGA project (project GReGAS) of the European Science Foundation; and by NRF grant 2011-0030044 (SRC-GAIA), funded by the government of Korea.

Finding Largest Rectangles in Convex Polygonsthanks: Supported by the Slovenian Research Agency, program P1-0297, projects J1-4106 and L7-5459; by the ESF EuroGIGA project (project GReGAS) of the European Science Foundation; and by NRF grant 2011-0030044 (SRC-GAIA), funded by the government of Korea.

Sergio Cabello Department of Mathematics, IMFM, and Department of Mathematics, FMF, University of Ljubljana, Slovenia. Part of the work was done while visiting KAIST, Korea.    Otfried Cheong Department of Computer Science, KAIST, Daejeon, Korea.    Christian Knauer Institut für Informatik, Universität Bayreuth, Bayreuth, Germany    Lena Schlipf Institute of Computer Science, Freie Universität Berlin, Germany.
Abstract

We consider the following geometric optimization problem: find a maximum-area rectangle and a maximum-perimeter rectangle contained in a given convex polygon with vertices. We give exact algorithms that solve these problems in time . We also give -approximation algorithms that take time .

Keywords: geometric optimization; approximation algorithm; convex polygon; inscribed rectangle.

1 Introduction

Computing a largest rectangle contained in a polygon (with respect to some appropriate measure) is a well studied problem. Previous results include computing largest axis-aligned rectangles, either in convex polygons [2] or simple polygons (possibly with holes) [5], and computing largest fat rectangles in simple polygons [6].

Here we study the problem of finding a maximum-area rectangle and a maximum-perimeter rectangle contained in a given convex polygon with vertices. We give exact -time algorithms and -approximation algorithms that take time . (For maximizing the perimeter we allow the degenerate solution consisting of a single segment whose perimeter is twice its length.) To the best of our knowledge, apart from a straightforward -time algorithm, there is no other exact algorithm known so far.

Our approximation algorithm to maximize the area improves the previous results by Knauer et al. [7], who give a deterministic -approximation algorithm with running time and a Monte Carlo -approximation algorithm with running time . We are not aware of previous -approximation algorithms to maximize the perimeter.

2 Preliminaries

Notation.

We use for arbitrary convex bodies and for convex polygons.

Let be the set of unit vectors in the plane. For each and each convex body , the directional width of in direction , denoted by , is the length of the orthogonal projection of onto any line parallel to . Thus

where denotes the scalar product.

For a convex body and a parameter , an -kernel for is a convex body such that

The diameter of is the distance between the two furthest points of . It is easy to see that it equals

Ahn et al. [1] show how to compute an -kernel. Their algorithm uses the following type of primitive operations for :

  • given a direction , find an extremal point of in the direction ;

  • given a line , find .

Let be the time needed to perform each of those primitive operations. We will use as a parameter in some of our running times. When is a convex -gon whose boundary is given as a sorted array of vertices or as a binary search tree, we have  [4, 10]. Ahn et al. show the following result.

Lemma 1 (Ahn et al. [1]).

Given a convex body and a parameter , we can compute in time an -kernel of with vertices.

Lemma 2.

Let be an -kernel for . If is an invertible affine mapping, then is an -kernel for .

Proof.

The ratio of directional widths for convex bodies is invariant under invertible affine transformations. This means that

and thus is an -kernel for . ∎

Figure 1: Proof of Lemma 3.
Lemma 3.

Assume that contains the rectangle , that has diameter , and that is an -kernel for . Then contains the axis-parallel rectangle .

Proof.

The statement is empty if or , so assume that . For the sake of contradiction, assume that is not contained in . This means that one vertex of is not contained in . Because of symmetry, we can assume that is not contained in . Since is convex and , there exists a closed halfplane that contains but does not contain . Let be the boundary of .

We next argue that has some vertex at distance at least from (and thus ); see Figure 1 for a couple of cases. If has negative slope and is its lower halfplane, then the distance from to is at least . If has negative slope and is its upper halfplane, then the distance from to is at least . If has positive slope, then or are at distance at least from .

Since , for the direction orthogonal to  we have

where we have used the assumption that . This means that

which contradicts that is an -kernel for . ∎

3 Exact algorithms

Let be the edges of the convex polygon . For each edge of , let be the closed halfplane defined by the line supporting that contains . Since is convex, we have .

We parameterize the set of parallelograms in the plane by points in , as follows. We identify each -dimensional point with the triple , where , , and . The triple corresponds to the parallelogram with vertices

Thus, describes a vertex of the parallelogram , while and are vectors describing the edges of . This correspondence is not bijective because, for example,

Nevertheless, each parallelogram is for some : the parallelogram given by the vertices in clockwise (or counterclockwise) order is .

We are interested in the parallelograms contained in . To this end we define

Since is convex, a parallelogram is contained in if and only if each vertex of the parallelogram is in . Therefore

Since is trivially bounded, it follows that is a convex polytope in defined by linear constraints. The Upper Bound Theorem [9] implies that has combinatorial complexity at most . Chazelle’s algorithm [3] gives a triangulation of the boundary of in time; Seidel [11] calls this the boundary description of a polytope. From the triangulation of the boundary we can construct a triangulation of : chose an arbitrary vertex of and add it to each simplex of the triangulation of the boundary of that does not contain . (One can also use a point in the interior of .)

The set of rectangles is obtained by restricting our attention to triples with , where again denotes the scalar product of two vectors. This constraint is non-linear. Because of this, it is more convenient to treat each simplex of a triangulation of separately. When , the area of is .

Consider any simplex of the triangulation of . Finding the maximum area rectangle restricted to corresponds to the problem

s.t.

This is a constant-size problem. It has variables and a constant number of constraints; all constraints but one are linear. The optimization function has degree four. In any case, each such problem can be solved in constant time. When the problem is not feasible, we set .

Taking the best rectangle over all simplices of a triangulation of , we find a maximum area rectangle. Thus, we return . We have shown the following.

Theorem 4.

Let be a convex polygon with vertices. In time we can find a maximum-area rectangle contained in .

To maximize the perimeter, we apply the same approach. For each simplex in a triangulation of we have to solve the following problem:

s.t.

Combining the solutions over all simplices of the triangulation we obtain the following.

Theorem 5.

Let be a convex polygon with vertices. In time we can find a maximum-perimeter rectangle contained in .

4 Combinatorially distinct rectangles

The reader may wonder if the algorithm of the previous section cannot be improved: It constructs the space  of all parallelograms contained in , and then considers the intersection with the manifold corresponding to the rectangles. If the complexity of this intersection was smaller than , then we should avoid constructing the entire parallelogram space  first.

In this section we show that this is not the case: the complexity of the space of rectangles that fit inside , that is, the complexity of the intersection of  with the manifold , is already  in the worst case. Therefore, asymptotically we are not loosing anything by considering all parallelograms, instead of directly concentrating on rectangles.

To this end, let us call two rectangles contained in a convex polygon  combinatorially distinct if their vertices are incident to a different subset of edges of . We are going to show the following: for every sufficiently large there is a polygon with vertices that contains combinatorially distinct rectangles. This shows that any algorithm iterating over all combinatorially distinct rectangles contained in needs at least time. Our algorithm falls in this category.

We provide an informal overview of the construction, see Figure 2.

Figure 2: Outline of the construction.

For simplicity, we are going to use vertices. Consider the circle of unit radius centered at the origin. We are going to select some points on , plus two additional points. The polygon is then described as the convex hull of these points. The points are classified into 4 groups. We have a group of points placed densely on the left side of . We have another group of points placed densely on the right side of . The third group , also with points, is placed on the upper part of . The points of are more spread out and will be chosen carefully. Finally, we construct a group of two points placed below . The construction will have the property that, for any edge defined by , any edge defined by , and any edge defined by , there is a rectangle contained in with vertices on the edges , and . The points are needed only to make sure that the bottom part of the rectangle is contained in ; they do not have any particular role.

Theorem 6.

For any sufficiently large value of there is a polygon with vertices such that contains combinatorially distinct rectangles.

Proof.

Let be the circle of unit radius centered at the origin , and let be the circle of radius centered at , for a small value  to be chosen later on. Let be the horizontal strip defined by , see Figure 3. Select a set of points in with positive -coordinate and select a set of points in with negative -coordinate. For every on a segment connecting consecutive points of and every on a segment connecting consecutive points of , let be the circle with diameter . We now observe that the upper semicircle of with endpoints  and  lies between and . This follows from the fact that has radius at least and the center of is at most apart from .

Figure 3: Detail of the construction of and . Some circles are in dashed blue.

Figure 4 should help with the continuation of the construction. We place a set of points on the upper side of . We want the following additional property: for any two consecutive points ant of , the segment intersects . If we select sufficiently small, then and are close enough that we can select the points needed to construct . Finally, we choose a set of two points below , as shown in Figure 2. The final polygon is the convex hull of . This finishes the description of the polygon .

Consider any edge defined by two consecutive vertices of and chose a point on . Similarly, consider any edge defined by two consecutive vertices of and chose a point on . Let be an edge of defined by two consecutive points of . By construction, the circle with diameter intersects the segment in some point, let’s call it . This means that the triangle has a right angle at . Let  be the point on  such that is a diameter of . Then the quadrilateral formed by , , , and  is a rectangle contained in . Each choice of an edge defined by , an edge defined by , and an edge defined by results in a combinatorially distinct rectangle. Therefore there are combinatorially distinct rectangles contained in . ∎

Figure 4: Detail of the construction of .

5 Approximation algorithm to maximize the area

The algorithm is very simple: we compute an -kernel for the input convex body , compute a maximum-area rectangle contained in and return it. We next show that this algorithm indeed returns a -approximation.

Let be a maximum-area rectangle contained in , and let be an affine transformation such that is the square .

Lemma 7.

The diameter of is at most .

Proof.

We will show that is contained in the disk centered at the origin of radius , which implies the result.

Any convex body contains a rectangle with at least half of its area [8]. Therefore .

Any invertible affine transformation does not change the ratio between areas of objects. Therefore

and thus .

Figure 5: Triangle considered in the proof of Lemma 7. The point is drawn closer to the origin than it is assumed.

Assume, for the sake of reaching a contradiction, that has a point at distance larger than from the origin . See Figure 5. Let be the line segment of length centered at the origin and orthogonal to the segment . Since is contained in the square , it is contained in . Therefore contains the convex hull of , which is a triangle of area larger than , and we get a contradiction. It follows that is contained in a disk centered at the origin of radius . ∎

Lemma 8.

Let be an -kernel for . Then contains a rectangle with area at least .

Proof.

Because of Lemma 2, is an -kernel for . Since contains  and has diameter at most  due to Lemma 7, Lemma 3 with implies that contains the square , where .

Since is obtained by scaling by , its preimage is obtained by scaling by  about its center. It follows that is a rectangle with area

and the lemma follows. ∎

Theorem 9.

Let be a convex body in the plane. For any given , we can find a -approximation to the maximum-area rectangle contained in in time .

Proof.

First, we compute an -kernel to . We then compute a maximum-area rectangle contained in and return it. This finishes the description of the algorithm.

Because of Lemma 8, contains a rectangle of area at least , where is a maximum-area rectangle contained in . Therefore, the algorithm returns a -approximation to the maximum-area rectangle.

Computing takes time because of Lemma 1. Since has vertices, finding a largest rectangle contained in takes time because of Theorem 4. ∎

Corollary 10.

Let be a convex polygon with vertices given as a sorted array or a balanced binary search tree. For any given , we can find a -approximation to the maximum-area rectangle contained in in time .

Proof.

In this case . ∎

6 Approximation algorithm to maximize the perimeter

The approximation algorithm is the following: we compute an -kernel for the input convex body , compute a maximum-perimeter rectangle contained in , and return it. We next show that this indeed computes a -approximation.

Since the algorithm is independent of the coordinate axes, we can assume that the maximum-perimeter rectangle contained in  is an axis-parallel rectangle with . We distinguish two cases depending on the aspect ratio of . When , then the longest segment contained in is a good approximation to . When , then is fat enough that we can use Lemma 3 to obtain a large-perimeter rectangle.

Lemma 11.

We have .

Proof.

We assume first that . This implies . Because contains , the directional width of in the horizontal direction is at least . The diameter of is therefore at least , and so contains a segment of perimeter at least . The lemma then follows from

It remains to consider the case . Let be the disk of radius  centered at the origin. We have , as otherwise contains a segment of perimeter strictly larger than , contradicting the optimality of . It follows that the diameter of is at most .

By Lemma 3, contains the axis-parallel rectangle , where . We have

Theorem 12.

Let be a convex body in the plane. For any given , we can find a -approximation to the maximum-perimeter rectangle contained in in time .

Proof.

First, we compute an -kernel for . We then compute a maximum-perimeter rectangle contained in and return it. This finishes the description of the algorithm.

By Lemma 11 contains a rectangle of perimeter at least , where is a maximum-perimeter rectangle contained in . Therefore, the algorithm returns a -approximation to the maximum-perimeter rectangle.

Computing takes time because of Lemma 1. Finding the maximum-perimeter rectangle contained in takes time because of Theorem 5. ∎

Corollary 13.

Let be a convex polygon with vertices given as a sorted array or a balanced binary search tree. For any given , we can find a -approximation to the maximum-perimeter rectangle contained in in time .

Proof.

In this case . ∎

References

  • [1] H.-K. Ahn, P. Braß, O. Cheong, H.-S. Na, C.-S. Shin, and A. Vigneron. Inscribing an axially symmetric polygon and other approximation algorithms for planar convex sets. Comput. Geom., 33(3):152–164, 2006.
  • [2] H. Alt, D. Hsu, and J. Snoeyink. Computing the largest inscribed isothetic rectangle. In Proc. CCCG’95, pages 67–72, 1995.
  • [3] B. Chazelle. An optimal convex hull algorithm in any fixed dimension. Discrete & Computational Geometry, 10:377–409, 1993.
  • [4] B. Chazelle and D. P. Dobkin. Intersection of convex objects in two and three dimensions. J. ACM, 34(1):1–27, 1987.
  • [5] K. Daniels, V. Milenkovic, and D. Roth. Finding the largest area axis-parallel rectangle in a polygon. Computational Geometry, 7(1–2):125–148, 1997.
  • [6] O. A. Hall-Holt, M. J. Katz, P. Kumar, J. S. B. Mitchell, and A. Sityon. Finding large sticks and potatoes in polygons. In Proc. SODA’06, pages 474–483, 2006.
  • [7] C. Knauer, L. Schlipf, J. M. Schmidt, and H. R. Tiwary. Largest inscribed rectangles in convex polygons. J. Discrete Algorithms, 13:78–85, 2012.
  • [8] M. Lassak. Approximation of convex bodies by rectangles. Geometriae Dedicata, 47(1):111–117, 1993.
  • [9] P. McMullen. The maximum numbers of faces of a convex polytope. Mathematika, 17:179–184, 1971.
  • [10] M. Reichling. On the detection of a common intersection of convex polyhedra. In Computational Geometry and its Applications, volume 333 of LNCS, pages 180–186. Springer Berlin Heidelberg, 1988.
  • [11] R. Seidel. Convex hull computations. In J. E. Goodman and J. O’Rourke, editors, Handbook of Discrete and Computational Geometry, pages 361–375. CRC Press, Inc., Boca Raton, FL, USA, 1997.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
""
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
   
Add comment
Cancel
Loading ...
200427
This is a comment super asjknd jkasnjk adsnkj
Upvote
Downvote
""
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters
Submit
Cancel

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test
Test description