Maximum-Area Rectangles in a Simple Polygon

Yujin Choi, Seungjun Lee, Hee-Kap Ahn

Maximum-Area Rectangles in a Simple Polygon

Introduction

Computing the largest shape that can fit inside a given container is a fundamental optimization problem in computational geometry, computer vision, and pattern recognition. While finding axis-aligned rectangles or rectangles within strictly convex polygons has been well-studied, the generalized problem—finding the maximum-area rectangle of arbitrary orientation within a simple polygon—remains challenging. This paper presents a novel, exact algorithm to solve this problem for simple polygons, including those with reflex vertices and internal holes, achieving a near-optimal running time of $O(n^3 \log n)$.

Problem Definition

The objective is to find the largest rectangle $R$ (by area) such that $R \subset P$, where $P$ is a simple polygon with $n$ vertices. Unlike previous approaches that restrict the rectangle's orientation to be axis-aligned or require $P$ to be convex, this work allows $R$ to be oriented at any angle $\theta \in [0, \pi/2)$.

Methodology

The search space for an arbitrarily oriented rectangle is continuous and infinite. To handle this, the algorithm discretizes the problem by identifying critical configurations where the rectangle's area reaches a local maximum.

1. Contact Classification

The authors prove that any maximum-area rectangle must be "locked" by specific contact points with the polygon's boundary. These "determining sets of contacts" are classified into six canonical types, labeled A through F. These types describe how corners or edges of the rectangle interact with the polygon's edges and reflex vertices.

Classification of the six canonical contact types (A-F) that define a maximal rectangle.

2. Rotational Sweep and Staircase Data Structure

Instead of rotating the rectangle, the algorithm keeps the polygon stationary and rotates the coordinate system. For a fixed angle $\theta$, the problem reduces to finding the largest axis-aligned rectangle. To do this efficiently across all angles, the algorithm maintains a "double staircase" data structure for each reflex vertex.

The staircase structure $S_\theta(u)$ representing the visible region from a vertex $u$ as the coordinate system rotates.

As the axes rotate, the combinatorial structure of these staircases changes only at discrete "event" angles. The algorithm uses a priority queue to process these events (step, ray, or shift events), updating the local maximum area at each step.

3. Feasibility and Holes

To ensure candidate rectangles remain within the polygon (especially when holes are present), the algorithm employs a fast ray-shooting data structure. This allows for feasibility verification in $O(\log n)$ time. For polygons with holes, a triangular range searching structure ensures the interior of the rectangle is empty.

Key Insights

  • Discretization of Search Space: By identifying that local maxima only occur at specific contact configurations, the infinite search space of orientations is reduced to a finite set of combinatorial events.
  • Efficiency of Staircase Tracking: Tracking the evolution of visibility staircases allows the algorithm to predict when valid rectangle configurations appear or disappear without exhaustive re-computation.
  • Complexity Bounds: Given that a simple polygon can contain $\Omega(n^3)$ combinatorially distinct inscribed rectangles, the $O(n^3 \log n)$ complexity is remarkably close to the theoretical lower bound of $\Omega(n^3)$.

Results and Complexity

The algorithm achieves the following performance metrics:

  • Simple Polygons: $O(n^3 \log n)$ time and $O(kn^2)$ space, where $k$ is the number of reflex vertices.
  • Polygons with Holes: The $O(n^3 \log n)$ time complexity is maintained by using advanced range searching techniques.
  • Convex Polygons: A specialized version runs in $O(n^3)$ time and $O(n)$ space.

Conclusion

The presented algorithm provides a robust solution for finding the maximum-area rectangle in a simple polygon. While $O(n^3 \log n)$ may be computationally intensive for very large $n$, it is near-optimal. Future work may focus on eliminating the logarithmic factor to reach the $O(n^3)$ theoretical limit for non-convex polygons.

Summary updated

BibTeX
@inproceedings{choi2019maximum,
  author = {Yujin Choi and Seungjun Lee and Hee-Kap Ahn},
  title = {{Maximum-Area Rectangles in a Simple Polygon}},
  booktitle = {FSTTCS},
  year = {2019},
  doi = {10.4230/lipics.fsttcs.2019.12},
}
Figure