<<

Finding the largest in several classes of

The Harvard community has made this article openly available. Please share how this access benefits you. Your story matters

Citation Daniels, Karen, Victor J. Milenkovic, and Dan Roth. 1995. Finding the largest rectangle in several classes of polygons. Harvard Computer Science Group Technical Report TR-22-95.

Citable link http://nrs.harvard.edu/urn-3:HUL.InstRepos:27030936

Terms of Use This article was downloaded from Harvard University’s DASH repository, and is made available under the terms and conditions applicable to Other Posted Material, as set forth at http:// nrs.harvard.edu/urn-3:HUL.InstRepos:dash.current.terms-of- use#LAA

Finding the Largest Rectangle in

Several Classes of Polygons

Karen Daniels

Victor J Milenkovic

Dan Roth

TR

September

Center for Research in Computing Technology

Harvard University

Cambridge Massachusetts

Finding the Largest Rectangle in



Several Classes of Polygons

y z x

Karen Daniels Victor Milenkovic Dan Roth

September

Abstract

This pap er considers the geometric optimization problem of nding the Largest

area axisparallel Rectangle LR in an n general p olygon We characterize

the LR for general p olygons by considering dierent cases based on the types of con

tacts b etween the rectangle and the p olygon A general framework is presented for

solving a key subproblem of the LR problem which dominates the running time for

a variety of p olygon types This framework p ermits us to transform an algorithm

for orthogonal p olygons into an algorithm for nonorthogonal p olygons Using this

framework we obtain the following LR time results n for xy monotone p olygons

Onn for orthogonally convex p olygons where n is the slowly growing inverse

of Ackermanns function Onn log n for horizontally vertically convex p olygons

On log n for a sp ecial type of horizontally convex p olygon whose b oundary consists of

two y monotone chains on opp osite sides of a vertical and On log n for general

p olygons allowing holes For all these types of nonorthogonal p olygons we match

the running time of the b est known algorithms for their orthogonal counterparts

A lower b ound of time in n log n is established for nding the LR in b oth self

intersecting p olygons and general p olygons with holes The latter result gives us b oth

a lower b ound of n log n and an upp er b ound of On log n for general p olygons

Keywords geometric optimization fast matrix searching

An earlier version of this pap er app eared in the Proceedings of the Fifth Annual Canadian Conference on

Computational Geometry The general p olygon result will app ear in a sp ecial issue of Computational

Geometry Theory and Applications

y

This research was funded by the TextileClothing Technology Corp oration from funds awarded to them

by the Alfred P Sloan Foundation

z

This research was funded by the TextileClothing Technology Corp oration from funds awarded to them

by the Alfred P Sloan Foundation and by NSF grants CCR and CCR

x Supp orted by NSF grants CCR and CCR and by DARPA AFOSRFJ

Introduction

The problem of nding the Largest area axisparallel Rectangle LR inside a general p olygon

of n vertices is a geometric optimization problem in the class of p olygon inclusion problems

Dene I ncP Q Given P P nd the largest Q Q inside P where P and Q

are families of p olygons and is a real function on p olygons such that

0 0 0

Q Q Q Q Q Q Q

Our problem is an inclusion problem where Q is the set of axisparallel rectangles P is the

set of general p olygons and gives the area of a rectangle

This rectangle problem arises naturally in applications where a quick internal approxi

mation to a p olygon is useful It is needed for example in the industrial problem of laying

out apparel pattern pieces on clothing markers with minimal cloth waste see

Section

Related Work

Despite its practical imp ortance work on nding the LR has b een restricted to orthogonal

p olygons and recently convex p olygons see Figure Amenta has shown

that the LR in a convex p olygon can b e found in linear time by phrasing it as a convex

programming problem For a constrained type of orthogonal p olygon Aggarwal and Wein

give a n time algorithm for nding the LR using the monotonicity of an area matrix

asso ciated with the p olygon

McKenna et al use a divideandconquer approach to nd the LR in an orthogonal

p olygon in On log n time For the merge step at the rst level of divideandconquer they

obtain an orthogonal vertically separated horizontally convex p olygon At the second

level their merge step pro duces an orthogonal orthogonally convex p olygon for which

they solve the LR problem in On log n time They also establish a lower b ound of time

A general p olygon is a p olygonal region in the plane with an arbitrary number of comp onents and holes

A rectangle is inside if it is a subset The rectangle can share part of its b oundary with the p olygons

We use ORourkes denition An orthogonal p olygon is one whose edges are all aligned with a pair of

orthogonal co ordinate axes which we take to b e horizontal and vertical without loss of generality In

the context of this pap er this might b e called an axisparallel p olygon

The b oundary of a vertically separated p olygon consists of two chains which extend from the highest

p oint of the p olygon to the lowest p oint and which are on opp osite sides of some vertical line A horizontal ly

convex p olygon contains every horizontal whose endp oints lie inside the p olygon For a vertically

separated horizontal ly convex p olygon the two chains are y monotone

An orthogonally convex p olygon is b oth horizontally and vertically convex This class contains the class

of convex p olygons Constrained Staircase Convex Orthogonal, Orthogonally Convex Orthogonal Largest Empty Rectangle Problem

Θ 3 5 3 Θ (n) (n) O (n log n) O (n log n) O (n log n) Amenta 93 Aggarwal and Wein 88 McKenna, O'Rourke, Suri 85 McKenna, O'Rourke, Suri 85 Chazelle, Drysdale, Lee 86 (convex programming) (fast matrix searching) 2 2 O (n α (n)) O (n log n) O (n log n) (using Klawe and Kleitman 90) (using Aggarwal and Suri 87) Aggarwal and Suri 87

(fast matrix searching) (fast matrix searching) (fast matrix searching)

Figure Related Work

in n log n for nding the LR in orthogonal p olygons with degenerate holes which implies

the same lower b ound for general p olygons with degenerate holes

McKenna et al note without giving details that the LR in an orthogonal p olygon can

also b e found using the more complicated On log n time divideandconquer algorithm of

Chazelle et al for the largest empty rectangle LER problem The LER problem is stated

as follows given a rectangle containing a set S of n p oints nd the largest area rectangular

subset with sides parallel to those of the original rectangle whose interior contains no p oints

from S Chazelle et al observe that the running time of the merge step of their

algorithm is dominated by the largest empty corner rectangle LECR problem given two

subsets S and S of S nd the largest rectangle containing no p oint of S which has

left right

lowerleft corner in S and upp erright corner in S The fastest solution to LECR is

left right

Aggarwal and Suris On log n time algorithm which they present as part of an On log n

time solution to the LER problem Their LECR algorithm relies on fast searching of area

matrices

We observe that a sp eedup in the LECR algorithm automatically improves the running

time for nding the LR in an orthogonal p olygon This sp eedup o ccurs b ecause a fast LECR

algorithm implies a fast algorithm for the Largest Corner Rectangle LCR in an orthogonal

vertically separated horizontally convex p olygon Computing the LCR in turn dominates

the running time of the LR problem for orthogonal vertically separated horizontally convex

p olygons Finally as we have previously stated this sp ecial case is required for the merge

step of a divideandconquer algorithm for general orthogonal p olygons Thus the On log n

time algorithm for LECR yields an On log n time algorithm for nding the LR in an

orthogonal p olygon

The On log n time algorithm of for orthogonal orthogonally convex p olygons can

The LCR of an orthogonal p olygon is the largest area rectangle with diagonally opp osite corners on the

b oundary of the p olygon Our denition of LCR for nonorthogonal p olygons is somewhat more sp ecic see

Section

also b e improved by applying recent results in fast matrix searching Aggarwal and Suri

note that for the LECR problem which can b e asso ciated with the vertices of this type of

p olygon there is a corresp onding area matrix whose maximum can b e found in On log n

time by decomp osing it into a set of simpler area matrices They note in that Klawe and

Kleitmans results for this simpler type of matrix imply Onn search time for the

more complex matrix where n is the slowly growing inverse of Ackermanns function It

is easy to see that this yields Onn time for nding the LR in an orthogonal orthogonally

convex p olygon

Melissaratos and Souvaine use the visibility techniques of to solve several ge

ometric optimization problems In particular they nd the largest contained in a

p olygon in On time by considering the types of contacts b etween the p olygon and the

triangle A similar approach can b e applied to the LR problem by using the concept of

rectangular visibility but this leads to an On algorithm which is much slower than

the On log n one we prop ose in this pap er

Another p ossible approach to the LR problem involves Voronoi diagrams but it is unlikely

to pro duce an algorithm faster than On log n Chew and Drysdale discuss using a

Voronoi diagram of a p oint set based on a convex distance function to nd the asso ciated

largest empty convex shap e Chazelle et al in their work on the largest empty rectangle

problem cite the use of a Voronoi diagram in the L or L metric to nd the largest

1

empty axisparallel for a p oint set Aurenhammer notes that a transition from

to rectangles is complicated b ecause the distance function dep ends on the asp ect

ratio of the rectangle which is unknown Chazelle et al use a Voronoilike diagram to

solve the LECR problem However this approach is slower than Aggarwal and Suris LECR

algorithm which is based on fast matrix searching In order to use Voronoi diagrams to

solve the problem treated in this pap er one would need a generalized Voronoi diagram often

called the medial axis of a p olygon Since the fastest algorithm for the largest empty

rectangle problem for p oint sets is not based on Voronoi diagrams we doubt that using

such a generalized Voronoi diagram would yield an algorithm faster than the On log n one

we present in this pap er

No published algorithm is known for nding the LR in a general nonorthogonal p olygon

with nondegenerate holes nor has a lower b ound tighter than n b een established

Overmars and Woo d dene rectangular visibility as follows Given a set of p oints S in the plane

a p oint p is said to b e rectangularly visible from a p oint q with resp ect to S if and only if there exists an

orthogonal rectangle R that contains b oth p and q but no other p oint of S We use a slightly less restrictive

version of rectangular visibility see Section

Overview

We present the rst algorithmic results for general p olygons with holes an On log n time

algorithm We also prove a lower b ound for this type of p olygon of time in n log n

The divideandconquer approach used for nding LRs in orthogonal p olygons is applicable

to nonorthogonal p olygons but it is a challenge to deal with the sp ecial cases of the LR

problem that arise during the merge step As is the case for orthogonal p olygons the running

time is dominated by the LCR largest corner rectangle problem for vertically separated

horizontally convex p olygons Unfortunately for nonorthogonal p olygons it is not so easy

to reduce the LCR problem to a LECR problem For this reason we present a general

framework which we use to transform LCR problems for several types of nonorthogonal

p olygons into LCR problems for partially orthogonal p olygons The framework shows

how to mo dify a LECR algorithm to solve these sp ecial LCR problems This framework

allows us to achieve the same LR time b ounds for each nonorthogonal case as has already

b een achieved for the corresp onding orthogonal case

Our pap er is organized as follows In Section we characterize the LR for general

p olygons by considering dierent cases based on the types of contacts b etween the rectangle

and the p olygon In Section we present a general framework for solving the contact case

of the LR problem which dominates the running time for a variety of p olygon types The

framework involves transforming the p olygon via vertex pro jection and inner orthogonal

approximations into a partially orthogonal p olygon for which we can solve the asso ciated

LCR problem by solving a mo died LECR problem The LECR problem is solved eciently

using fast matrix searching techniques from the literature

xy-monotone orthogonally convex horizontally convex vertically separated, general horizontally convex Θ (n) O (n α (n)) O (n α (n) log n) 2

O (n log n) O (n log n)

Figure Algorithmic Results for a Variety of Types

Section presents an On log n time divideandconquer algorithm for nding the LR

in a general p olygon with holes Our contact framework is applied to solve the contact

case for a vertically separated horizontally convex p olygon This type of p olygon arises in

the merge step and nding its LCR and LR dominates the running time of the divideand

conquer algorithm We show that its LR can b e found in On log n time This On log n

The contact case is equivalent to a constant number eight of LCR problems

algorithm uses the results of Aggarwal and Suri for the LECR problem

Section gives algorithms for nding the LR in several other types of p olygons We

show that the LR of an xy monotone p olygon can b e found in n time This algorithm is

based on using the contact framework to solve the contact case in n time We use the

framework to solve the contact case in Onn time for an orthogonally convex p olygon

This leads to an Onn time algorithm for nding the LR of an orthogonally convex p oly

gon The orthogonally convex p olygon result is used as the basis for an Onn log n time

divideandconquer algorithm for horizontally vertically convex p olygons If used in the

divideandconquer algorithm of McKenna et al this immediately gives Onn log n

time for general p olygons However this is not as fast as our On log n time algorithm based

on vertically separated horizontally convex p olygons However these LR algorithms or the

contact framework may b e useful in the development of other fast geometric algorithms

The running time results of Sections and are summarized in Figure

In Section we prove a lower b ound of time in n log n for nding the LR in b oth

selfintersecting p olygons and general p olygons with holes The latter result gives us b oth a

lower b ound of n log n and an upp er b ound of On log n for general p olygons with holes

It uses symbolic p erturbation to extend the n log n lower b ound of McKenna et al for

orthogonal p olygons with degenerate holes The pro of for selfintersecting p olygons involves

a reduction from MAXGAP This n log n lower b ound clearly demonstrates that the LR

inclusion problem is harder than the corresp onding smallest rectangle enclosure problem

which has a trivial linear time algorithm

Section discusses LR applications

Characterizing the LR

In this section we characterize the LR contained in a general p olygon P by considering

dierent cases based on the types of contacts b etween the LR and the b oundary of P We

outline a naive algorithm for nding the LR based on this characterization Others have

used contact classication for algorithmic development see for example

Types of Contacts

Intuitively if an axisparallel rectangle is inside P it has four degrees of freedom parameters

and can grow until each of its four sides is stopp ed by contact with the b oundary of P

A simple p olygon consisting of two xy monotone chains is an xy monotone p olygon A chain is xy

monotone if it is monotone with resp ect to b oth the x and y axes A chain is monotone with resp ect to a

line l if a line orthogonal to l intersects the chain in exactly one p oint

Contacts b etween the rectangle and P are of two types a side of the rectangle with a

vertex of P and a corner of the rectangle with an edge of P In order to discuss the rst

type we require the notion of a reex extreme vertex introduced in

Denition A vertex v of P is a vertical reex extreme vertex if exteriorP has

a local vertical line of support at v for some epsil on the vertical line segment of

length and with v is a subset of P boundary plus interior A horizontal reex

extreme vertex is dened similarly

For type contacts a reex extreme vertex of P touches a side of the rectangle and stops

growth in one direction we call this a reex contact Each reex contact can remove one

degree of freedom Two reex contacts with adjacent sides of the rectangle x a corner of

the rectangle For type contacts a corner of the rectangle touches an edge of P forming

an edge contact

A Determining Set of Contacts

Denition A set of contacts C is a determining set of contacts if the LR R satis

0 0

fying C has nite area and if the LR R satisfying any proper subset C C has greater or

innite area

For example a set of four reex contacts one on each side of the rectangle is a deter

mining set

Note A determining set determines the area of the LR but it do es not necessarily

determine a unique rectangle or LR

(a) Fixed contact (b) Independent (c) Two dependent

sliding contact sliding contacts

Figure Edge Contact Types for a Determining Set

Within a determining set we distinguish b etween two dierent subtypes of edge contacts

An edge contact is xed if the set of constraints uniquely determines the p oint of contact

with the rectangle Otherwise it is a sliding contact Note that we are considering here

the set of al l rectangles which satisfy the determining set of contacts and we are not just

considering rectangles of maximal area

A xed contact can arise when there is no freedom to slide along an edge b ecause a reex

contact xes a co ordinate For example in Figure a the reex contact of the determining

set xes the xco ordinate of the edge contact which completely determines the lo cation of

the edge contact If an edge contact has an adjacent side which has either a reex or xed

contact then the edge contact must also b e a xed contact

Two sliding edge contacts are dependent if the p osition of one determines the p osition

of the other otherwise they are independent An indep endent sliding contact requires that

the two adjacent sides of the rectangle do not have any contact with P see Figure b A

sliding contact adjacent to another sliding contact is dep endent b ecause the two contacts

must share a co ordinate see Figure c

Maximization Problems

Here we examine maximization problems asso ciated with certain determining sets of contacts

Finding the LR asso ciated with a determining set of contacts requires solving a maximization

problem if the set contains a sliding contact For a given set of contacts the number of degrees

of freedom is the number of undetermined parameters of the rectangle Degrees of freedom

within a determining set can arise only from sliding contacts b ecause any other degree of

freedom would result in a rectangle of innite area and therefore the contacts would not

form a determining set It follows that if a determining set consists of only reex or xed

edge contacts no maximization is required For each indep endent sliding contact in the set

we can parameterize the asso ciated edge The maximization problems can then b e classied

based on the number of parameters

Parameter Problems

The set of parameter maximization problems can b e further sub divided according to the

number of dep endent sliding contacts

The Basic Parameter Problem The simplest parameter problem involves no de

p endent sliding contacts just a single indep endent one This is the basic parameter prob

lem and it arises when one corner of the LR has a sliding contact and the diagonally opp osite

corner is xed The basic parameter problem can b e solved by parameterizing the edge

asso ciated with the sliding contact and maximizing a quadratic in one variable This can b e

solved in O time

An alternate constanttime solution to the parameter problem is based on the following

lemma which demonstrates that the slop e of the LR dep ends only on the slop e of

the p olygon edge We assume here that the edge is neither vertical nor horizontal

Lemma Slop e Lemma Given a point p and a line L with slope s the LR with one

pq where the slope corner at p and diagonal ly opposite corner at point q on L has diagonal

pq s of

In other words for a basic parameter problem if one corner of a LR is incident on L

the slop e of the LRs diagonal is the negative of Ls slop e

L: ax + by = d increasing area s = -a/b

(xc , y c ) = q area of MAAPR: xy = c

p

Figure Slop e Lemma

Pro of Assume p is at the origin and that the line L is given by ax by d see Figure

Wlog assume L intersects the x and y axes Note we ignore the degenerate cases of

horizontal and vertical lines for which the LR is undened The family of hyperb olas given

by xy r represents curves corresp onding to rectangles of constant area Moving away from

the origin into the rst quadrant the hyperb ola branch which is tangent to L provides the

area c of the LR asso ciated with L Let x y b e the co ordinates of the p oint at which L

c c

is tangent to the hyperb ola xy c

Now the tangent to xy c at x y is equal to L so the normal to xy c at x y

c c c c

is equal to the normal to L at x y The normal to xy c is F F y x evaluated

c c x y

at x y it is y x The normal to L at x y is a b Therefore

c c c c c c

a y

c

slop eL pq slop e

x b

c

Note that as a consequence of this lemma if p moves downward q moves downward

along its edge

Two Dep endent Sliding Contacts If there are exactly two dep endent sliding contacts

in a determining set then these contacts are at the endp oints of one edge of the rectangle

and there is a reex contact with the opp osite edge of the rectangle Wlog these are the

0

top and b ottom edges with y co ordinates y and y as shown in Figure a To nd the LR

p p by t yielding a quadratic in t to maximize see App endix A for we parameterize edge

details p p 4 4 p p t 2 t 2 (x,y) (x',y) (x,y) (x',y) p p 1 p 1 p p 3 3 5 y' (x, y' ) p 6

(a) Pair of Constrained Sliding Contacts (b) Triple of Constrained Sliding Contacts

Figure Parameter Problems with Two and Three Dep endent Sliding Contacts

Three Dep endent Sliding Contacts The case of three dep endent sliding contacts is

depicted in Figure b It is dealt with in a manner similar to the case of two dep endent

sliding contacts See App endix A for details

The Parameter Problem

There is only one type of parameter problem It has two indep endent sliding contacts

The following lemma allows us to reduce a parameter problem to a set of parameter

problems

Lemma Let e and e be nonintersecting line segments Consider the set of empty axis

parallel rectangles which have diagonal ly opposite corners on e and e There is a largest

area rectangle in this set with at least one corner at an endpoint of e or e

Pro of One way to prove the claim is to parameterize the p ositions of the corners of

the rectangle on e and e The area of the rectangle is a quadratic function of the two

parameters It is easily shown that the graph of the quadratic over the patch is

a saddle surface and therefore the maximum is achieved along the b oundary of the patch

The b oundary corresp onds to the subset of rectangles which have at least one corner at an

endp oint of either e or e

A geometric argument is more intuitive however Let c on e and c on e b e opp osite

corners of a rectangle and let r b e the diagonal connecting c and c Now replace e and e

by the lines l and l containing them Consider the set S of all line segments that connect l

and l and are parallel to r The length of these line segments as a function of their distance

from r is monotone If l and l are parallel the length is constant Otherwise the length

increases moving away from r in one direction and decreases in the opp osite direction Move

away from r in the direction of increasing length either direction if l is parallel to l until

0 0

either c or c is at an endp oint of e or e and let r b e the new diagonal Since jr j jr j

0

the area of the rectangle whose diagonal is r is at least as large as the area of the rectangle

whose diagonal is r Therefore given any rectangle with opp osite corners on e and e there

is one with at least as large an area and with a corner at an endp oint of e and e Thus

there is always an LR with a corner at an endp oint

Having established that there exists a LR with a corner at a vertex in this case we can

nd it by considering in turn each of the four endp oints of e and e solving the asso ciated

parameter problems and then comparing the four resulting parameter LR areas

Characterization Theorem

To characterize the LR we examine the p ossible determining sets of contacts By enumer

ating the reex contacts b etween the LR and P we derive the set of ve cases shown in Figure

# RC

4

3 1 FC

RC = Reflex Contact FC = Fixed Contact 2 2 FC 2 FC 1 ISC 2 FC 2 FC ISC = Independent Sliding Contact DSC = Dependent Sliding Contact

1 FC 1 3 FC 3 FC 2 DSC 1 ISC

0 2 ISC 3 DSC 4 FC

Figure The Determining Sets of Contacts for the LR

Theorem The determining set of the LR of a general polygon P conforms up to sym

metry to one of the ve cases in Figure

Pro of The pro of is a straightforward examination of cases See App endix B for details

Corollary Given a determining set C for a LR of a general polygon it fol lows that

jC j

A Naive Algorithm

Based on the ab ove characterization we can nd the LR in a general p olygon by nding the

LR under the constraints of each of the ve cases and selecting the largest one

Theorem For each determining set of contacts in Figure the LR can be found in

constant time

Pro of A reex contact yields in constant time one of the four parameters of the rectangle

as do es a xed contact In all cases we can pro cess these contacts rst The remaining

situations are all either parameter problems or parameter problems which can b e solved

in constant time b ecause they only require maximizing a constant number of quadratic forms

A naive LR algorithm can use Theorem and supply it in each case all p ossible

determining sets for P These can b e identied using an algorithm with up to four nested

lo ops one for each element of the determining set For each LR candidate we can check if

it is empty ie contains no p oint from the b oundary of P in its interior in On time We

conclude

Theorem The LR of an nvertex general polygon can be found in On time

In the remainder of the pap er we show how to use the LR characterization combined

with fast matrix searching to develop a more sophisticated approach to this problem which

yields an On log n time algorithm

A General Framework for the Contact Case

We compute the LR for a general p olygon with holes using divideandconquer The divide

andconquer algorithm must nd the LR in a p olygon P which is a subset of the general

p olygon and which is of the following type the b oundary of P consists of two y monotone

chains V and E on opp osite sides of a vertical line Recall from Section that we call

this a vertically separated horizontal ly convex p olygon see Figure By Corollary the

algorithm must consider the and contact cases in order to nd the LR in P Of these

the contact case dominates the running time This section gives a framework for creating

algorithms for the contact case for classes of p olygons with y monotone chains including

the class of vertically separated horizontally convex p olygons We call this the contact

framework Section applies the contact framework to create a contact LR algorithm

for vertically separated horizontally convex p olygons and then gives the divideandconquer

LR algorithm for general p olygons Section applies the contact framework to create

contact LR algorithms for other types of p olygons and then gives LR algorithms for these

types For all of these p olygon types the contact framework yields an algorithm which

has the same order running time as the fastest LR algorithm for the orthogonal version of

that type

The contact case for p olygons with y monotone chains V and E involves nding the

largest rectangle which is inside P and which has one corner on V and the diagonally opp osite

corner on E By Lemma one of the corners of the largest contact rectangle is at a

vertex of either V or E Furthermore there are four choices for which corner of the rectangle

has this cornervertex contact We refer to each of eight p ossibilities as a Largest Corner

Rectangle LCR problem In what follows we treat only the LCR problem for which the

lowerleft corner of the rectangle is a a vertex of V and the upp erright corner is on an edge

of E We call such a rectangle a vertexedge rectangle for V and E This denition of LCR

is analogous to Chazelles denition of the LECR

In Section we mentioned that Chazelle et al use a divideandconquer strategy to

solve the LER Largest Empty Rectangle problem for a set of p oints For their algorithm

the most dicult sub case is the LECR Largest Empty Corner Rectangle problem given a

set S of p oints and given two subsets S and S of S nd the largest rectangle containing

left right

no p oint of S in its interior which has lowerleft corner in S and upp erright corner in S

left right

Ideally we would like to solve the LCR problem for P V and E in the following manner

Set S verticesP S verticesV and S verticesE Then nd the LECR of

left right

S S and S Unfortunately there are two ways in which the LECR can fail to b e the

left right

LCR First some edge of P might intersect the interior of the LECR Second the actual

LCR might have its upp erright corner in the middle of an edge of E not at a vertex

Fortunately for a variety of p olygon types it is p ossible to reduce the problem of com

puting the LCR to that of computing the LECR The reduction involves several steps and

these steps constitute our contact framework for solving contact LR problems Section

gives a high level description of the contact framework and Sections through give

sp ecic details

High Level Description of the Contact Framework

This section gives a high level description of the contact framework The user of the

0 0 0

framework must provide a lineartime transformation of P V and E into P V and E

which satises certain prop erties The framework sp ecies the prop erties which amount to

0 0 0

the notion of creating partially orthogonal P V and E The user must also provide

a LECR algorithm with certain prop erties that the framework also sp ecies The framework

0 0 0 0

shows how to create an algorithm for the LCR R of P V and E Because of the prop erties

0 0

R is at least as large as the LCR of P V and E and R P

Notice that the framework do es not necessarily create an algorithm for the LCR of P

0 0 0 0

V and E The rectangle R is an LCR of P V and E but it might b e a contact or

0

contact rectangle inside P Nevertheless an algorithm for R is sucient Recall that the

overall goal is to compute the LR of P When the LR algorithm checks the contact case

it is acceptable for the LCR algorithm to nd a rectangle inside P that is larger than the

largest contact rectangle

Thus the framework takes a transformation and a LECR algorithm as input and cre

ates a LCR algorithm as output To do this the framework denes a second transformation

0

that consists of adding a new vertex at the midp oint of every edge of E This transforms

0 00 0 00

P into P and E into E The framework also denes a measure for the size of cor

0 00

ner rectangles which have diagonally opp osite corners in verticesV and verticesE The

framework mo dies the usersupplied LECR algorithm by substituting a call to whenever

the LECR algorithm computes the area of a corner rectangle

Here in broad detail is the LCR algorithm that the framework creates The algorithm

0 0 0 0

rst transforms P V and E into p olygon P and chains V and E of P using the trans

00

formation provided by the user Next it applies the second transformation yielding P

00 00

and E It calls the mo died LECR algorithm to compute the rectangle R which maxi

0

mizes over all rectangles with one corner in verticesV the diagonally opp osite corner

00 00

in verticesE and which contains no element of verticesP in its interior It applies a

00 0 0 0 0

constanttime transformation to convert R into R the LCR of P V and E

00

The framework deals with b oth of the ways in which the output R of the LECR algorithm

could fail to solve the LCR problem it might not b e inside P and it might not have the

0

largest area First the prop erties which the usersupplied transformation of P to P must

00 0 00

satisfy guarantee that R is inside P and P Second R might not have the correct area

00 0 0 0 0 00

but R is equal to the area of the LCR R of P V and E and R can b e transformed

0

into R

0 0 0

Section denes the three prop erties that P V and E must have in order to apply

00

the contact framework It denes and proves that the LECR R for the vertices of

00 0 00 0 0 0 0

P V E and the measure can b e transformed into the LCR R of P V and E

which in turn is inside P and is at least as large as the LCR of P V and E Section

considers the question of transforming a LECR algorithm into a LECR algorithm for measure

by substituting the function for the area function in the implementation of the LECR

algorithm This section denes a prop erty called total monotonicity and proves that if

b oth V and E are y monotone then b oth the area function and the function are totally

monotone It then observes that if the pro of of correctness of the LECR algorithm only

dep ends on the total monotonicity of the area function then the pro of will still work if

is substituted for area This metatheory is a general scheme for transforming algorithms

and pro ofs However the only way to b e really sure that the pro of only dep ends on

total monotonicity is to substitute for area and recheck the pro of Section observes

0 0 0

that if the number of vertices of P V and E are linear in the number of vertices in P

0 0 0

then the algorithm for the LCR of P V and E has the same order running time as the

corresp onding LECR algorithm

Prop erties and the LR Measure

0 0 0

This section denes three prop erties of P V and E with resp ect to P V and E It also

0 00

denes a size measure for rectangles with opp osite corners at vertices of V and E Recall

00 0

that E has vertices at the midp oints of edges of E We call these added vertices special

0

vertices For a rectangle whose corner is at a vertex of E is the area function but for

a rectangle whose corner is at a sp ecial vertex has a dierent value dened b elow We

00 0 0 00 00

prove that the LECR R for the vertices of P V and E has the prop erty that R is

greater than or equal to the area of the LCR of P V and E We also show how to generate

0

a rectangle R inside P with this area

0 0 0

The following are the three prop erties that P V and E must satisfy with resp ect to

P V and E

0 0

Prop erty I Polygonal regions P and P satisfy P P and each vertexedge rectangle

0 0 0

for P V and E is a vertexedge rectangle for P V and E Even if the upp erright corner

of the rectangle is at a vertex of E we still consider it to b e a vertexedge rectangle

0 0

Prop erty I I For every vertex v V and every edge e E if any p oint q in the

0

interior of e is rectangularly visible from v inside P then the entire edge e is rectangularly

visible from v

0 0

Prop erty I I I If vertex v V and a p oint q E are rectangularly visible with resp ect

0 0

to verticesP then v and q are rectangularly visible with resp ect to P

0

Adding a sp ecial vertex at the midp oint of every edge of E do es not alter the satisfac

0 0 00

tion of Prop erties II I I Therefore P V and E also satisfy Prop erties II I I We introduce

0 00

a new measure on corner rectangles of V and E For rectangles which have a corner at

a sp ecial vertex this measure diers from the area function

Denition LR Measure The LR measure of rectangle rectv w for vertices

0 00

v V and w E is dened as fol lows If w is not a special vertex it is arearectv w

Two p oints p and q are rectangularly visible inside p olygonal region P if rect pq P where rect pq

is dened to b e the axisparallel rectangle with diagonal pq

0

If w is a special vertex rectv w is the area of the LR for vertex v and the edge e E

containing w

For a given v and e the LR can clearly b e computed in constant time see Lemma

0 0 0

Lemma Let polygon P and y monotone chains V and E satisfy Property I with respect

0 0 0

to P V and E Then the LCR for P V and E lies inside P and it is at least as large

as the LCR for P V and E

0 0 0 0

Pro of Let R b e the LCR for P V and E and let R b e the LCR for P V and E By

0

Prop erty I every vertexedge rectangle for P V and E is a vertexedge rectangle for P

0 0 0 0 0

V and E Therefore area R area R Since P P R P

0 0 0

Lemma Let polygon P and y monotone chains V and E satisfy Properties II and III

00 0 0 00

Let E and be as dened above Then the LECR for verticesP verticesV verticesE

0 0 0

and measure can be transformed in constant time into a LCR for P V and E

0 0 0 0 00 0

Pro of Let R b e a LCR for P V and E and let R b e the LECR for verticesP

0 00

verticesV verticesE and measure

00 0

We rst prove the following claim R area R

00 0 0 0

R area R Let v q b e the diagonal of R where q lies on edge e of E If q is an

0 0 00 0 00

endp oint of e then area R R by the denition of Also R R b ecause R

00 0

is the LECR under the measure Thus R area R If q is not an endp oint of e let

w b e the sp ecial vertex of e By Prop erty I I since v can see q v can see w Since rectv w

0

is equal to the area of the largest vertexedge rectangle for v and e rectv w areaR

00 00 00 0

Again since R is the LECR R rectv w and thus R area R

0 00 00

area R R It suces to show that given R we can construct rectv q where

00 0 0

arearectv q R where v is a vertex of V and where q lies on an edge of E Let

00

v w b e the diagonal of R If w is not sp ecial then let q w If w is sp ecial then by

Prop erty I I since v can see w v can see all of edge e containing w and thus v can see q

00

where v q is the diagonal of the LR for v and e Thus arearectv q R Finally we

0 0

observe that areaR arearectv q since R is the LCR and thus is at least as large as any

0 00

other vertexedge rectangle By transitivity area R R Putting this together with

0 00

the inequality from the previous paragraph shows that areaR R which establishes

the claim

The last paragraph of the pro of of the claim implies that we can construct a vertex

00

edge rectangle rectv q in constant time such that arearectv q R The claim itself

00 0 0

establishes R area R and therefore area rectv q areaR This means that

0 0 0 0

rectv q is either the LCR of P V and E or at least an LCR Thus we can construct R

00

from R in constant time

Total Monotonicity of the LR Measure

Lemmas and reduce the LCR problem to a LECR problem with the notion of size

given in Denition A LECR algorithm clearly dep ends on the notion of size the

algorithm of Aggarwal and Suri for largest p erimeter is very dierent from their algorithm

for largest area Furthermore our notion of size do es not p ossess the prop erty required

for the class of inclusion problems dened in Section

0 0 0

Q Q Q Q Q Q Q

Here we assume Q is the set of all corner rectangles with lowerleft corner in S

left

0 00

verticesV and upp erright corner in S verticesE However do es p ossess this

right

0

prop erty if Q is the set of all empty corner rectangles with resp ect to S verticesP

Fortunately for p olygons with y monotone chains which we consider almost any known

algorithm for the LECR can b e used to compute the LECR by merely substituting size for

area in the algorithm

0

Supp ose we number the vertices of V by decreasing y co ordinate Similarly we number

00

the vertices of E It is standard to dene an area matrix M whose entry m contains the

ij

0

size of the rectangle with lowerleft corner at vertex v verticesV and upp erright corner

i

00

at vertex w verticesE The LECR algorithms we use only require that M satises a

j

certain monotonicity prop erty Of course some entries in the area matrix are invalid b ecause

v and w are not rectangularly visible However the only prop erty which the algorithms

i j

really dep end on is the total monotonicity prop erty for legal minors of the matrix

We dene this prop erty and show that M dened using the LR measure of Denition

satises it

0 0

Denition M is totally monotone if for every i i and j j corresponding

0 0 0 0

m m implies m to a legal minor m

ij i j ij i j

Lemma If an increasing index in M corresponds to decreasing y coordinates of the

associated vertices then M dened by the LR measure is total ly monotone

00 00

0

verticesE are sp ecial Pro of It suces to assume that w verticesE and w

j j

vertices since we can consider an ordinary vertex to represent an edge of zero length with a

Size matrix would b e the more general term

A legal minor contains only entries corresp onding to empty rectangles

In the literature the term totally monotone refers to a matrix which has the total monotonicity

prop erty and no illegal entries Matrices which have the prop erty but have some illegal entries are sometimes

referred to as monotone eg monotonesinglestaircase monotonedoublestaircase This is confusing

since monotonicity is also presented in the literature as a weaker condition than total monotonicity a

matrix for which the column of the row maximum moves to the right as i increases is monotone and it is

totally monotone only if all minors also p ossess this prop erty Our terminology removes this confusion

0

b e the edges containing w and sp ecial vertex equal to the ordinary vertex Let e and e

j j j

0 0 0 0 0

b e p e and v e v e resp ectively Let the LR vertices for the pairs v e v w

j i j i j i j i j

p p and p resp ectively Let A B C D E and F b e the areas of rectv p rectv p

i i

0 0 0

rectv p rectv p rectv p and rectv p resp ectively To show monotonicity it

i i i i

suces to show that B A D C To show this we need the intermediate result

B E F C

B E

p v p v p v p v

x ix y iy x ix y iy

p p v p p p p v p p

x y ix y y x y iy x x

0 0

For the next step we need the following v v p p v v and p p

iy i y y y i x ix x x

The y co ordinate inequalities are direct consequences of the y monotonicity of vertex and

edge chains By assumption we are dealing with a valid minor of the matrix Therefore

0

g and there are four distinct empty rectangles which have a lowerleft corner in the set fv v

i i

0

g By Prop erties I I and I I I there are twelve empty an upp erright corner in the set fw w

j j

0

g and an upp erright corner in the rectangles which have a lowerleft corner in the set fv v

i i

0

p g although they are not necessarily distinct since p could equal w set fp w p p w

j j j

for instance The two xco ordinate inequalities must hold in order that rectangles rectv p

i

0

p b e empty and rectv

i

0 0

p p v p p p p v p p

x y i x y y x y i y x x

0 0 0 0

p v p v p v p v

x i x y i y x i x y i y

F C

The denition of a LR implies that A E and D F B A and A E B E

F C D F and F C D C Therefore B A D C

0 0

Corollary If V and E are y monotone then M dened by the LR measure is total ly

monotone

0

Pro of P satises the condition of Lemma

LCR Running Time

Based on Lemmas and and Corollary we make the following claim which is used

in Section and Section to establish running times for solving the contact case in a

variety of types of p olygons

Claim For an nvertex polygon P with y monotone chains V and E if the fol lowing

two conditions hold then the LCR can be found in the same asymptotic running time as the

LECR algorithm

0 0 0

An On vertex polygon P and with y monotone chains V and E satisfying Proper

ties IIII can be produced from P V and E in On time

0 0 00

The LECR algorithm for S verticesP S verticesV and S verticesE

left right

depends only on the total monotonicity of the matrix associated with the size measure

00 0 0

As stated previously E is E with a special vertex added at the midpoint of each edge of E

0 0 0

In general we pro duce P V and E from P V and E by pro jecting vertices of P and

replacing some edges of P by inner orthogonal approximations For this we assume On

prepro cessing time to construct horizontal and vertical visibility maps for P Pro jection and

orthogonalization can b e done in On time and add only a linear number of vertices to P

The LECR algorithms we use dep end only on the total monotonicity of the area matrix

To obtain the desired running time in each case for nding the LCR it therefore suces to

0 0 0

construct P V and E show that they satisfy Prop erties II I I and establish the running

time of the appropriate LECR algorithm

Implementation Note We can avoid the use of sp ecial vertices if we accept a more

complicated denition of the LR measure For entry m let e b e the edge whose upp er

ij

endp oint is w If all of e is rectangularly visible to v rectv w is the area of the LR

j i i j

whose lowerleft corner is at v and upp erright corner is on e Otherwise rectv w

i i j

arearectv w

i j

LR Algorithm for General Polygons

This section develops an On log n time divideandconquer algorithm for nding the LR

in a general p olygon with holes First the contact framework is applied in Section to

solve the contact case for a vertically separated horizontally convex p olygon This type

of p olygon arises in the merge step of the divideandconquer algorithm Next we show in

Section that the LR of a vertically separated horizontally convex p olygon see Page for

the denition can b e found in On log n time This On log n algorithm uses the results of

Aggarwal and Suri for the LECR problem Finally Section gives the full algorithm

for general p olygons with holes

LCR of a Vertically Separated Horizontally Convex Polygon

In this section we apply the contact framework to solve the contact case for a vertically

separated horizontally convex p olygon Supp ose V is the left chain and E is the right chain

Recall that V and E are y monotone Section gives the transformation from P V

0 0 0

and E to P V and E that is required by the framework Section and Section

provides the required LECR algorithm By Claim the transformation and the LECR

algorithm are all we need to create a LCR algorithm for vertically separated horizontally

convex p olygons

0 0 0

Construction of P V and E

V E

(a) upward projection (b) rightward projection (c) upward projection (d) orthogonalization

new vertex

0

Figure P Construction for Two Chains of a Vertically Separated Horizontally Convex

Polygon

0 0 0

We pro duce P V and E using the following set of pro jections followed by orthogonalization

see Figure From each vertex in V pro ject a vertical ray upwards adding vertices where

the rays hit V as shown in Figure a For each vertex in V including new ones pro ject

a horizontal ray rightward as in Figure b Add vertices to E where these rays hit For

each vertex of E including new ones pro ject up adding new vertices as in Figure c

Now replace each edge of mo died V and E which has p ositive slop e by its inner orthogonal

0 0 0

approximation to pro duce P V and E This pro cess adds a linear number of new vertices

The nal result is illustrated in Figure d

Pro of of Prop erty I Edges of P which have negative slop e are not orthogonalized so

0

a vertexedge rectangle of P is also a vertexedge rectangle of P We need only show that

0

if it is empty in P it is empty in P Supp ose vertexedge rectangle rectv q is empty in P

0

but not empty in P Then rectv q must contain a vertex c of the orthogonalized upp erleft

0

wlog b oundary of P but it do es not intersect edge ab of P where acb is the inner

orthogonal approximation of ab Therefore a v c But this cannot b e b ecause v was

x x x

pro jected upwards so there should b e a vertex b etween a and b with xco ordinate v

x

0 0

Pro of of Prop erty I I Let v b e a vertex of V and let q and q b e two vertices on the

0 0

same edge e of E We need to show that if rectv q is empty then rectv q is also We

0 0

consider rst the case in which q is b elow q Assume rectv q is empty but rectv q contains

0

a vertex c of the upp erleft chain As we shift q towards q the top edge of rectv q moves

0

upwards and must hit c b efore q reaches q But c a where acb is the inner orthogonal

y y

approximation of ab and a was pro jected rightwards onto the edge chain Therefore q hits

0

a pro jected vertex b efore it reaches q contradicting the assumption that they were on the

0

same edge Now consider the case in which q is ab ove or at the same height as q Assume

0

rectv q is empty but rectv q contains a vertex c of the lowerright chain As we shift q

0 0

towards q the right edge of rectv q moves rightwards and must hit c b efore q reaches q

But c b where acb is the inner orthogonal approximation of ab and b was pro jected

x x

0 0

upward to E Therefore q hits a pro jected vertex b efore it reaches q contradicting the

assumption that they were on the same edge

Pro of of Prop erty I I I The pro of of Prop erty I guarantees that rectangle rectv w

do es not intersect the inner orthogonal approximation of any p ositive slop e sub edge of P It

remains to show that no edge with negative slop e can cut across rectv w A negative slop e

edge cannot cross the vertical line separating L and R so it must cross either the upp erright

or lowerleft corner contradicting the y monotonicity of one of the chains

LECR Algorithm

Aggarwal and Suri have an On log n algorithm for the LER Largest Empty Rectangle

problem for p oints They use a divideandconquer approach which partitions the set

S of p oints into two subsets S and S ab out a vertical line and recursively nds the

left right

LER in S and S The merge step requires nding the LECR Largest Empty Corner

left right

Rectangle whose lowerleft corner is in S and upp erright corner is in S They solve

left right

the LECR problem in On log n time by forming an area matrix whose legal minors

are monotone and by applying fast searching techniques to this matrix Their pro of of this

LECR algorithm relies only on the monotonicity prop erty We reimplement this LECR

algorithm by substituting our LR measure see Denition instead of the area measure

0 00

We run this mo died algorithm on inputs S verticesV and S verticesE

left right

By Claim the transformation of the previous section and the mo died LECR al

gorithm yield an On log n time algorithm for nding the LCR in a vertically separated

horizontally convex p olygon

LR of a Vertically Separated Horizontally Convex Polygon

Theorem The LR in an nvertex vertically separated horizontal ly convex polygon or

horizontal ly separated vertically convex polygon can be found in On log n time

L

Q

Figure Orthogonally Convex Polygon at Merge Step

Pro of We treat the vertically separated horizontally convex p olygon P wlog The

contact case consists of eight LCR sub cases The results of Section show that each LCR

problem can b e solved in On log n time The remaining cases involve either or contacts

We claim these cases can b e solved by an On log n time divideandconquer algorithm

Lemma The and contact LRs for an nvertex vertically separated horizontal ly con

vex polygon P can be found in On log n time

Pro of We use a divideandconquer algorithm which at each step partitions the vertex

set using a horizontal line L into two sets each of size at most bnc We determine the

endp oints of L in linear time by examining all the edges of the p olygon We construct the

p olygon ab ove L and the p olygon b elow L in linear time by walking around the b oundary of

P Then we recursively nd the and contact LRs ab ove L and the and contact LRs

b elow L The merge step requires that we nd the and contact LRs intersecting L Let

R denote the larger of the two and contact LRs intersecting L Let Q b e the largest

L

p olygon inside P and containing L that is monotone with resp ect to L see Figure

Lemma R Q Furthermore Q is orthogonally convex can be constructed in n

L

time and has On vertices

Pro of of Lemma Any axisparallel rectangle R intersecting L must b e such that each

p oint p R is vertically visible to L hence R Q To construct Q we rst supplement

L

Note that it is also p ossible to solve the and contact case in On time using a sweepline algorithm

but that do es not improve the overall running time

the vertices of P with the extra p oints obtained from the precomputed vertical visibility

map We then claim that two simple traversals of P suce to construct Q Let l b e the left

endp oint of L and r the right endp oint The rst traversal is counterclockwise from l to r to

construct the b ottom p ortion of Q the second is clo ckwise from l to r to build the top part

We b egin the counterclockwise traversal by following the downward pro jection of l until it

hits the b oundary of P Then we follow the b oundary of P unless we encounter either a

reex extreme vertex that is supp orted from the right by a vertical line a vertex which is

the b ottom endp oint of a vertical visibility line emanating from a reex extreme vertex that

is supp orted from the left by a vertical line or the x value of r In case we follow

the visibility line downwards to the b oundary of P In case we follow it upwards to the

asso ciated reex extreme vertex In case we pro ceed to r and terminate the traversal

Constructing the top part of Q is similar

The visibility map introduces at most one new vertex for each vertex of P so Q has On

vertices We visit each vertex at most once during each sweep so the algorithm requires

n time To show Q is orthogonally convex let b and t b e the lowest and highest p oints

resp ectively on P that are visible to L The counterclockwise sweep builds an xy monotone

path from l to b and from b to r Similarly the clo ckwise sweep builds an xy monotone path

from l to t and from t to r Since the result is a p olygon consisting of four xy monotone

chains such that l b r and l t r it is orthogonally convex

x x x x x x

This completes the pro of of Lemma

The and contact LRs in the orthogonally convex p olygon Q can b e found in n

time using a sweepline algorithm The algorithm is essentially the same as that used by

McKenna et al to obtain the same time b ound for orthogonal orthogonally convex

p olygons Details app ear in App endix C

Now we argue that if the LR in P intersects L and is a or contact LR it is also a

or contact LR in Q This is b ecause if a rectangle r has at least three contacts with P it

has at least three contacts in Q

The running time of the algorithm therefore satises the recurrence T n T bnc

n which gives an On log n algorithm for nding the and contact LRs

This completes the pro of of the Lemma

This completes the pro of of Theorem

LR of a General Polygons with Holes

Theorem The LR in an nvertex general polygon can be found in On log n time

Before giving the pro of we discuss a diculty which arises in constructing a partitioning

line for a divideandconquer algorithm for nding the LR in a general p olygon If the p olygon

did not have holes we could apply a corollary of Chazelles p olygoncutting theorem to

nd a single vertical line segment within P which partitions the b oundary of P into two

pieces each containing less than n vertices Because we allow holes we cannot sub divide

the b oundary of P into two pieces using a single vertical line segment we must partition it

using multiple line segments Let L b e a vertical line which partitions the vertices of P into

two sets each of size roughly n and supp ose L is partitioned into k pieces L L L

k

by the interior of the p olygon We want to split P into left and right subp olygons P and

left

P recursively nd the LR in each subp olygon and then p erform a merge step in which

right

we nd the LR intersecting L for i k However in such an approach the fact that

i

the endp oints of L are not vertices of P means we add k vertices each time we recurse

i

McKenna et al observed that if P is an orthogonal p olygon with holes one need

not add k new vertices if the following technique is used Before the start of the divideand

conquer algorithm prepro cess P so that all vertical pro jections internal to P of vertices of

P are vertices At each step of the divideandconquer algorithm construct a trap ezoid Q

i

corresp onding to each L as follows L intersects two edges of P these edges are vertically

i i

visible from each other Because of the prepro cessing the left endp oints of these edges can

b e joined by a vertical line segment l and their right endp oints can b e joined by a vertical

i

line segment r Segments l and r contain only p oints which are internal to or on the

i i i

b oundary of P Let Q b e the empty trap ezoid b ounded on the left by l and on the right by

i i

r see Figure and let Q Q McKenna et al observe that if the LR do es not intersect

i i

L then it do es not contain any p oint in the interior of Q This allows them to redene

i i

P and P to b e completely disjoint by removing Q from consideration Unfortunately

left right

their observation ab out Q do es not hold in the nonorthogonal case We overcome this in

i

the pro of b elow by considering rectangles which cross either l or r and nding the LR in

i i

Q

i

Pro of We prepro cess P to construct horizontal and vertical visibility maps and to add

the internal vertical pro jections of vertices Our divideandconquer algorithm partitions

the vertices of P b oth original and vertical pro jections at each step using a vertical line

L into two sets each of size at most dne Supp ose that L is partitioned into k pieces

L L L by the interior of the p olygon For i k we dene l r and Q as

k i i i

ab ove As b efore let Q Q and construct subp olygons P and P of P n Q to the left

i left right

In a degenerate case when vertices of P lie on L one can treat this as if L l and arbitrarily choose

i i i

Q to b e the trap ezoid to the right of the partitioning line segment L It is easy to show that this implies

i i

that no more than the vertices of P on L end up on the b oundary of P Therefore jP j n

left left l i projected vertex r Li i

Qi

Figure Construction of Q

i

and right of L such that they do not share any vertices and each has no more than dne

vertices We recursively nd the LR in P and P In the merge step for i k we

left right

nd the LR in Q the LR of P which intersects l and the LR of P which intersects r

i i i

To show that this algorithm nds the LR of P we argue as follows If the LR do es not

intersect the interior of Q then it lies either in P or P so at the divide step we can

left right

recursively nd the LR in P and P If the LR intersects the interior of Q we can nd

left right

it during the merge step as follows If the LR lies entirely within Q we can nd it by nding

the LR in each Q If the LR is not entirely within Q it must cross some l or r

i i i

We now show that the algorithm requires On log n time First we note that an

On log n sweep algorithm suces for constructing the visibility maps and pro jecting the

vertices This need only b e done once b efore the start of the divideandconquer algorithm

and the maps can b e up dated in linear time at each step We can determine the endp oints of

L i k in linear time by examining all the edges of the p olygon and using the vertical

i

visibility map Because we have the visibility maps P and P can b e constructed in

left right

On time P and P each have size dne Since Q is a trap ezoid the LR in Q can

left right i i

b e found in O time so the LR in Q can b e found in On time We describ e b elow how

to nd the LR intersecting l i k in a total of On log n time The technique for r

i i

is the same

Lemma For an nvertex polygon P the LR which intersects l for i k can be

i

found in a total of On log n time

Pro of of Lemma Let H b e the largest p olygon in P which is horizontally visible from

i

l Let H have n vertices

i i i

Claim The LR which intersects l is a subset of H Furthermore H is a vertically

i i i

separated horizontal ly convex polygon and can be constructed in On time

i

Pro of of Claim The pro of is similar to the pro of of Lemma We use the horizontal

visibility map and two traversals to construct H H is a vertically separated horizontally

i i

convex p olygon b ecause each traversal builds a chain that is monotone with resp ect to the

vertical line l

i

This establishes Claim

P

k

n On Claim

i

i

Pro of of Claim The horizontal visibility map on P partitions the interior of P into a set

of trap ezoids T Let T T b e the set of trap ezoids that contains a p oint in the interior

i

of l hence O n O jT j Consider i j such that i j and l is to the right of l

i i i j i

wlog The only p oints which the interior of l sees to its right and to the left of L

i

are p oints in Q Since the interior of Q is empty this means that no p oint in the interior

i i

of l is horizontally visible from a p oint in the interior of l Therefore l and l cannot

j i i j

share a trap ezoid Thus each trap ezoid in T is asso ciated with at most one i and therefore

P

k

OjT j OjT j On

i

i

This establishes Claim

By Theorem we can nd the LR in H in On log n time Combining this result

i i i

with Claim implies that we can nd the LR which intersects l for i k in a total

i

of On log n time which establishes Lemma

Lemma implies that the merge step can b e p erformed in On log n time This yields

the following recurrence T n T dne On log n which gives On log n time for

the combined algorithm

This completes the pro of of Theorem

Note In a degenerate case when vertices of P lie on L see fo otnote on Page the

i

recurrence b ecomes T n T n T n On log n where n n n and n n

dne which still has the solution On log n

This completes the presentation of the LR algorithm for general nonorthogonal p olygons

with holes The following section presents LR algorithm for other types of p olygons Readers

not interested in these should skip to Section which gives the lower b ounds on running

time for the LR problem for general p olygons

LR Algorithms for Other Types of Polygons

In this section we derive ecient algorithms for computing the LR in dierent classes of

nvertex p olygons We obtain the following running times see also Figure on Page

XYmonotone p olygon n

Orthogonally convex p olygon Onn

Horizontally convex p olygon or vertically convex Onn log n

For each type we use the characterization results of Section to identify the relevant

determining sets of contacts For the contact case we use the contact framework of

Section to reduce the problem to a LECR problem Then we apply fast matrix searching

techniques from the literature to solve the LECR problem Finally we show how to deal with

cases of three or more contacts These results demonstrate the generality of our contact

framework

XYMonotone Polygon

The rst p olygon we consider is xy monotone and has wlog two decreasing xy monotone

chains V is the lower chain and E is the upp er chain The LR in an xy monotone p olygon

must b e a LCR Sections and apply our contact framework to show that the

LCR can b e found in n time

0 0 0

Construction of P V and E

0 0

Given an xy monotone p olygon P with chains V and E we transform them into P V

0

and E as follows see Figure From each vertex in V pro ject a horizontal ray rightward

and a vertical ray upward Add vertices to E where these two rays hit it Clearly this adds

0

at most n new vertices For this transformation V V

E

V

new vertex

0

Figure P Construction for Two XYMonotone Chains

0

Pro of of Prop erty I see Section Prop erty I is easily veried for P and P since

we have merely sub divided the edges of E

0

Pro of of Prop erty I I Prop erty II is also easily proven Let v b e a vertex on V and

0 0

let q and q b e two p oints on the same edge e on E We need to show that q is visible

0 0 0

if and only if q is Supp ose q is visible and q is not Imagine moving q towards q At

some p oint rectv w must degenerate into either a horizontal or vertical line segment By

0 0

the construction of P there must b e a vertex at this p oint of e Therefore q and q do not

lie on the same edge pro ducing a contradiction

Pro of of Prop erty I I I Prop erty III follows from the xy monotonicity of the chains

If v is any vertex on the lower chain and w is any vertex on the upp er chain such that v is

b elow and to the left of w then the rectangle they form is necessarily empty of b oth vertices

and edges

LECR Algorithm

0

Finally we describ e an algorithm for nding the LECR with vertex v on V and a vertex

00 0

w on E which is E with a sp ecial vertex added at the midp oint of each edge It is well

known that if all p oints v lie b elowleft of all p oints w then the area matrix with entries

i j

m area rectv w is not only total ly monotone but in addition every minor is

ij i j

legal If any v lies either ab oveleft or b elowright of any w v w has negative slop e

i j i j

then we give the area the same magnitude but negative sign

Note that some entries of the resulting area matrix corresp ond to illegal rectangles v

ab ove w but these entries are all negative An algorithm for nding the maximum entry

will return a p ositive entry which will corresp ond to a legal rectangle Because the chains

are xy monotone the matrix is still totally monotone even though some entries are illegal

and negative

We have thus reduced the problem to that of nding the maximum entry in an n n

totally monotone matrix where n and n are the lengths of the two chains We discuss

b elow how this can b e done in On n time yielding a n time algorithm for nding

the LCR for an xy monotone p olygon

Implementation Note The set of illegal entries in the matrix is b ounded by falling

staircases Aggarwal and Klawe show that such a monotone matrix can b e completed

so that its maximum can b e found in linear time Using negative entries is our practical

alternative to using completion here In fact for this particular problem one can drop any

notion of visibility and simply use the vertices of P The pro jection step is unnecessary The

use of signs to represent illegality makes this more natural technique work correctly

Here we discuss an ecient way from the literature to compute the maximal elements in

totally monotone matrices see Denition Naively we can examine all On matrix

entries to nd the maximal element However Aggarwal et al showed that if a matrix is

totally monotone and has no illegal entries the maximum can b e found in linear time

Lemma If any entry of a total ly monotone matrix of size n m can be computed

in constant time then the rowmaximum problem for this matrix can be solved in m time

if m n and m log nm time if n m

Note that this result assumes the existence of an oracle which takes as input i j and

returns the value m in constant time

ij

Corollary If any entry of a total ly monotone matrix M of size n m can be computed

in constant time then the rowmaximum problem for this matrix can be solved in Om n

time

Pro of From Lemma when m n the problem can b e solved in Om time When

n m the fact that Om log nm On immediately yields On time which

establishes the corollary However we present the following alternative pro of for the n m

case which is based on an algorithm that is easy to implement

We can complete M using by mo difying the oracle If j m it returns m but

ij

if j m the oracle returns The oracle still op erates in constant time The total

monotonicity of the matrix is preserved b ecause every minor is monotone To establish

0 0

0 0 0 0

for i i and j j If the minor m this consider the minor given by m m m

i j ij i j ij

contains no entries it is monotone b ecause M is totally monotone If it has all

0 0 0 0

we cannot have the forbidden condition and m m entries then b ecause m m

i j i j ij ij

0 0 0 0

m In the remaining case the forbidden condition cannot o ccur when m m m

ij ij i j i j

0 0 0 0

The completed matrix has dimension n n so we can and m m b ecause m m

i j i j ij ij

nd its maximum in n time by Lemma Combining the two cases yields On m

Theorem The LR in an nvertex xy monotone polygon can be found in n time

Pro of The LR in an xy monotone p olygon must b e a contact LR From the results of

Section and Corollary of Section we can nd the contact LR in n time

Orthogonally Convex Polygon

An orthogonally convex p olygon P is b ounded by four xy monotone chains Let V b e the

0 0

lowerleft chain and E b e the upp erright chain We show b elow how to construct P V

0

and E which satisfy the Prop erties II I I of the contact framework Section

0

To create the p olygon P do the following for each vertex v in V pro ject rightwards and

upwards creating two new vertices see Figure a For each vertex u on the upp erleft

chain including the newly created ones do the following if the rightward pro jection of u

hits E pro ject u rightwards and create a new vertex on E Similarly for each vertex u on

the lowerright chain pro ject it upwards if it lies b elow E E

V

(a) projection (b) orthogonalization

new vertex

0

Figure P construction for an orthogonally convex p olygon

Replace every edge ab a to the left of b of the upp erleft chain by a horizontal edge

ac followed by a vertical edge cb This must b e done after the pro jection step In other

words replace the upp erleft chain by an inner orthogonal approximation Similarly replace

0 0

the lowerright chain by an inner orthogonal approximation The nal result is P V and

0 0

E as depicted in Figure b Note that for this particular transformation V V

Pro of of Prop erty I We do not change the shap e of V and E although we do add a

linear number of new vertices to E Therefore a vertexedge rectangle of P is also a vertex

0

edge rectangle of P We only have to verify that if it is empty in P then it is empty in

0

P This argument is identical to that in the pro of of Prop erty I for the vertically separated

horizontally convex case which app ears in Section

0 0

Pro of of Prop erty I I Let v b e a vertex of V and let q and q b e two vertices on the

0

same edge e of E We know from the pro of of Prop erty II for xy monotone p olygons that

0

v q has p ositive slop e if and only if v q do es We need to show that if rectv q is empty

0 0

then rectv q is also Because the construction of P is symmetric with resp ect to x and y

0

we consider wlog q b elow q This case is dealt with in the pro of of Prop erty II for the

vertically separated horizontally convex p olygon and is omitted here

0

Pro of of Prop erty I I I Supp ose rectv w contains no vertices of P where v is a vertex

0 0

V lying lowerleft from w a vertex of E Rectangle rectv w clearly do es not intersect the

0 0

monotonically decreasing chains V and E Since the upp erleft and lowerright chains of

0

P are xy monotone and orthogonal it do es not intersect them either

LECR Algorithm

If no entries were illegal we would use the same algorithm as describ ed for the xy monotone

chains in Section However we prove that the two additional xy monotone chains in

the current case introduce two sets of illegal entries into the area matrix We show that the

b oundaries of these sets are rising staircases so that the matrix is a double staircase matrix

see denition b elow We again represent entries whose rectangle have negative

slop e by assigning them negative area

legal S1 entry

illegal entry

S2

Figure Totally Monotone Rising Double Staircase Matrix

Denition A matrix M is totally monotone double staircase if it is total ly

monotone and if there exist two sets of il legal entries S and S such that the boundary of

each set forms an xy monotone staircase inside M and S and S lie in diagonal ly opposite

corners of M

Figure shows a totally monotone rising double staircase matrix S and S are in the

upp er left and lower right corners resp ectively Note that the two staircases may intersect

although they do not in the gure

Before giving the LECR algorithm we prove that the area matrix for this case is a totally

monotone rising double staircase matrix

Lemma M is a total ly monotone rising double staircase matrix

Pro of Let rectv w b e a rectangle which do es not intersect the upp erleft chain and let

i j

0 0 0 0

q b e the upp erleft corner of that rectangle Every rectangle rectv w for i i and j j

i j

lies in the lower right quadrant of q and therefore do es not intersect the upp erleft chain

Thus if any entry in the area matrix is legal with resp ect to the upp erleft chain then every

entry to its lowerright in the matrix is also legal Therefore the set of entries which are

illegal with resp ect to the upp erleft chain form the set S b ounded by a rising staircase

It is straightforward to show that the lowerright chain pro duces the set S

The LECR algorithm in this case must nd the staircase b oundaries of M in linear time

and then nd the maximum entry in M We show b elow how to nd the maximum value

in a totally monotone rising double staircase matrix in Onn time We can construct

the left staircase wlog in linear time by traversing the upp erleft chain as follows For

0 0

row i we obtain v on V and pro ject up and to the right to obtain w on E The upward

i j

0

pro jection might hit E directly yielding w It is also p ossible that the rightward pro jection

j

hits the lowerright chain in this case the entire row is illegal Entry i j is the rst legal

entry in row i with resp ect to the upp erleft chain

For the case of two chains of an orthogonally convex p olygon with which we asso ci

ated totally monotone rising double staircase matrices see Denition we also seek a

sub quadratic time search algorithm Eciently searching a totally monotone rising double

staircase matrix involves transforming it into a set of rising single staircase matrices dened

b elow and illustrated in Figure In the gure upper and lower refer to the p osition of

the set of illegal entries

legal entry S

S illegal entry

(a) Upper (b) Lower

Figure Totally Monotone Rising Single Staircase Matrices

Denition A matrix M is totally monotone single staircase if there exists

one special set of entries S such that any minor that does not contain entries from S

is total ly monotone the boundary of S forms an xy monotone staircase inside M

Lemma If any entry of a total ly monotone single staircase matrix of size n m

can be computed in constant time then the rowmaximum problem for this matrix can be

solved in Onm m time

Implementation Note Aggarwal and Suri note that the constants are large here

They recommend in practice a theoretically slower algorithm One such algorithm is the

Om n log log n algorithm of Aggarwal and Klawe

Lemma Given a total ly monotone rising double staircase matrix M for which the

staircase boundaries are known the rowmaximum problem for M can be solved in Onm

m time

The pro of of this is based on the following claim and Lemma App endix D provides

an alternate way of partitioning

Aggarwal and Klawe distinguish b etween rising which we call upp er and reverse rising lower

staircase matrices

Claim An nm total ly monotone rising double staircase matrix can be partitioned

in On m time using an xy monotone chain into a set of at most k single staircase

P P

k k

matrices each of dimension n m such that n n and m m

i i i i

i i

Thus we obtain by Claim an Onn time algorithm for nding the LCR for two

chains of an orthogonally convex p olygon

LR Algorithm

The b oundary of an orthogonally convex p olygon can b e partitioned in linear time into four

xy monotone p olygonal chains We establish the following result for this type of p olygon

Theorem The LR in an nvertex orthogonally convex polygon can be found in Onn

time

Pro of An orthogonally convex p olygon has no reex extreme vertices so there are only

three p ossible congurations for LR determining sets of contacts see Figure

Figure Determining Sets of Contacts for an Orthogonally Convex Polygon

Lemma C of App endix C shows that the and contact cases can b e solved in linear

time

Lemma The contact LR of an nvertex orthogonally convex polygon can be found in

Onn time

Pro of of Lemma The results of Section show that for the contact case we can

reduce the LR problem for each pair of diagonally opp osite xy monotone chains in linear

time to the problem of nding the maximum in a totally monotone rising double staircase

matrix By Lemma we can nd the maximum in this matrix in Onn time

This completes the pro of of Lemma

This completes the pro of of Theorem

Horizontally and Vertically Convex Polygons

Theorem The LR in an nvertex horizontal ly or vertically convex polygon can be

found in Onn log n time

Pro of We treat the horizontally convex case wlog We use a divideandconquer algo

rithm which at each step partitions the vertex set using a horizontal line L into two sets

each of size at most bnc We determine the endp oints of L in linear time by examining

all the edges of the p olygon We construct the p olygon ab ove L and the p olygon b elow

L in linear time by walking around the b oundary of P Then we recursively nd the LR

ab ove L and the LR b elow L The merge step requires that we nd the largest rectangle R

L

intersecting L Let Q b e the largest p olygon inside P and containing L that is monotone

with resp ect to L

Lemma R Q Furthermore Q is orthogonally convex can be constructed in n

L

time and has On vertices

Pro of of Lemma Any axisparallel rectangle R intersecting L must b e such that each

p oint p R is vertically visible to L hence R Q The pro of that Q is orthogonally

L

convex can b e constructed in n time and has On vertices is identical to the argument

in the pro of of Lemma and is omitted here

Now we nd the LR in Q which by Theorem can b e done in Onn time

The running time of the algorithm therefore satises the recurrence

T n T bnc Onn

which gives an Onn log n algorithm for nding the LR

This completes the pro of of Theorem

Lower Bounds

Here we establish lower b ounds of time in n log n for nding the LR in b oth self

intersecting p olygons and general p olygons with holes The latter result gives us b oth a

lower b ound of n log n and an upp er b ound of On log n for general p olygons with

holes

These lower b ounds contrast with the n time result achievable for the corresp onding

enclosure problems

It is interesting to note that the dual problems of largest empty and smallest enclosing circle for

a set of p oints also have dierent lower b ounds The largest empty circle can b e constructed in n log n

time and the smallest enclosing circle can b e found in n time

SelfIntersecting Polygons

We prove a lower b ound of time in n log n for nding the LR in a selfintersecting p olygon

5 10 15 20 25 30

Figure Orthogonal selfintersecting p olygon constructed for input

Theorem Finding the LR in an nvertex selfintersecting polygon requires time in

n log n in both the linear and algebraic decision tree models

Pro of We reduce the MAXGAP problem to the LR problem for selfintersecting

orthogonal p olygons Consider an instance of MAXGAP given a set of n real numbers

x x x we must nd the maximum dierence b etween two consecutive numbers in

n

the sorted list We construct from this set in linear time a selfintersecting orthogo

nal p olygon of unit height as follows each x in the sequence corresp onds to a rectangle

i

r x x x x We start the construction from x complete the de

i i i

generate rectangle r then construct r r as shown in Figure This construction

n

results in a selfintersecting p olygon with the prop erty that the area of the LR included in

it is the solution to the corresp onding MAXGAP problem thus proving the theorem

General Polygons with Holes

McKenna et al have given a lower b ound of time in n log n for nding the LR

in a general p olygon with degenerate zero area holes Aggarwal and Suri have given

the same lower b ound for LER Using symbolic p erturbation b oth of these can

b e extended to lower b ounds on the computation of the LR in a general p olygon For the

degenerate case McKenna et al use a reduction from the even distribution problem given

a set of n real numbers x x x x not sorted determine if there exist adjacent x

n i

and x in the sorted list such that x x Their reduction involves the construction of

j j i

a long horizontal rectangle with vertical slits at each x These slits can b e thought of as

i

degenerate rectangular holes Given a slit x y x y we can expand it to a rectangle

i b i t

with diagonal x y x y where Of course if we choose greater than the value of

i b i t

the minimum gap b etween p oints p ossibly another n log n problem then neighboring

In b oth the linear and algebraic decision tree mo dels if not enhanced to include o or and ceiling

functions MAXGAP has a lower b ound of n log n

slits will overlap and the p olygon will b e selfintersecting in eect we have to know the

minimum gap in order to compute the maximum gap

Symbolic p erturbation rescues us from this chicken and egg problem by allowing to

remain unevaluated until after we have run the LR algorithm Given an algorithm for

computing the LR of a p olygon with nondegenerate holes we mo dify the way the algorithm

evaluates and tests the sign of arithmetic expressions Since some of the inputs involve

the arithmetic expressions of the mo died algorithm are p olynomials in For these the

mo died algorithm computes the sign by taking the sign of the rst lowest degree in

nonzero co ecient We observe that

there exists a value of such that the signs computed by the mo died algorithm equal

the signs computed by the unmo died algorithm on this value of this is the basic

theory of symbolic p erturbation

the running time of the mo died algorithm is a constant times the running time of the

unmo died algorithm on that value of

Hence any algorithm for the LR in a general p olygon can b e used to test even distribution

via a linear time reduction Hence the construction of the LR in a general p olygon has an

n log n lower b ound We could have also reduced the LER problem to the LR problem

by replacing every p oint in the LER instance by a square of size

Applications

When a p olygon is nearly rectangular the LR provides a go o d inner approximation see

Figure

Figure Inner Approximation

Many LR applications have surfaced in our automatic markermaking pro ject for the

apparel industry We briey describ e two of them in this section The goal of our pro ject is

to automate the task of laying out p olygonal apparel pattern pieces on a rectangular sheet

of cloth of xed width and minimal length In the apparel industry this layout is

called a marker

Pants markers consist of large panel pieces and smaller trim pieces We have a heuristic

metho d that do es a go o d job placing the larger panel pieces We use LRs during the

trim placement stage Figure shows a rectangular marker with the large panels already

placed The smaller trim pieces to the left of the marker rectangle must b e placed in the gaps

of unused material b etween adjacent panels We compute the LR of each trim piece and use

that inner approximation as part of our algorithm that decomp oses the gaps into smaller

more manageable regions The decomp osition algorithm is part of software which we

have licensed to a CAD rm in the apparel industry We have also considered computing

the LR of each gap region and then packing the nearly rectangular trim pieces into the LRs

using techniques from the rectangle packing domain We do not currently use this strategy

in our trim placement heuristic

Figure Pants Marker with Placed Panels and Unplaced Trim

Conclusion

We have presented the rst algorithmic result for nding the LR in nonorthogonal general

p olygons with holes an On log n time algorithm We have also established a lower b ound

of time in n log n for this type of p olygon

For a variety of nonorthogonal p olygons we have shown that the LR can b e found in the

same asymptotic running time as the b est algorithms for their orthogonal counterparts Our

running time for xy monotone p olygons is optimal but for orthogonally convex p olygons

horizontally convex p olygons and vertically separated horizontally convex p olygons no

nontrivial lower b ound has b een established

Pursuing more ecient algorithms for nding the exact LR is certainly one direction for

future work Another direction of practical imp ortance is to nd a fast approximate LR

algorithm Such an algorithm would b e very helpful in our applications

This pap er has describ ed a general mechanism for developing LR algorithms for non

orthogonal p olygons The mechanism has three key comp onents the idea of determining

sets of contacts used to characterize the LR for a general p olygon with holes identifying

the determining set of contacts corresp onding to the one subproblem which dominates the

running time for nding LRs in a variety of types of p olygons and a general framework

for solving the dominant subproblem using a new notion of rectangle size The framework

involves creating a partially orthogonal p olygon to which we apply a known algorithm for

solving the LECR problem To develop each LR algorithm we solve the key subproblem

using our framework and then solve the remaining subproblems There may b e other classes

of p olygons in addition to the ve we examined that are amenable to this general metho d

It is interesting that in order to solve the LR problem we need a notion of rectangle size

which do es not p ossess the following imp ortant prop erty held by b oth area and p erimeter

0 0 0

for rectangles Q Q Q Q Q Q Q We think it might b e useful in other

instances to consider such nonstandard size measures

Acknowledgments

The authors gratefully acknowledge the helpful comments made by Pankaj Agarwal Zhenyu

Li Marios Mavronicolas and Binhai Zhu We also acknowledge the background information

provided by David Dobkin and Joseph ORourke and the unpublished manuscript provided

by Alok Aggarwal

References

A Aggarwal and M M Klawe Applications of Generalized Matrix Searching to Geometric Algorithms

Discrete Applied Mathematics

A Aggarwal M M Klawe S Moran P Shor and R Wilb er Geometric applications of a matrix

searching algorithm Algorithmica

A Aggarwal and S Suri Fast Algorithms for Computing the Largest Empty Rectangle In Proceedings

of the rd Annual ACM Symposium on Computational Geometry pages

A Aggarwal and S Suri Fast Algorithms for Computing the Largest Empty Rectangle Personal

communication

A Aggarwal and J Wein Computational Geometry Lecture Notes for MIT

N Amenta Largest Volume Box is Convex Programming Personal communication

F Aurenhammer Voronoi Diagrams A Survey of a Fundamental Geometric Data Structure ACM

Computing Surveys

J S Chang and C K Yap A Polynomial Solution for the Potatop eeling Problem Discrete and

Computational Geometry

B Chazelle A theorem on p olygon cutting with applications In Proceedings of the rd IEEE Sympo

sium on the Foundations of Computer Science pages

B Chazelle R L Drysdale I I I and D T Lee Computing the largest empty rectangle SIAM Journal

on Computing

L P Chew and R L Drysdale I I I Voronoi Diagrams Based on Convex Distance Functions In

Proceedings of the st ACM Symposium on Computational Geometry pages

K Daniels and V J Milenkovic Limited Gaps In Proceedings of the th Canadian Conference on

Computational Geometry pages

N DePano Y Ke and J ORourke Finding Largest Inscrib ed Equilateral and Squares

In Proceedings of the th Al lerton Conference on Communications Control and Computing pages

H Edelsbrunner and E P M ucke Simulation of Simplicity A technique to cop e with degenerate cases

in geometric algorithms ACM Transactions on Graphics

L Guibas J Hershberger D Leven M Sharir and R E Tarjan LinearTime Algorithms for Visibility

and Shortest Path Problems Inside Triangulated Simple Polygons Algorithmica

F Hwang An On log n algorithm for rectilinear minimal spanning trees Journal of the ACM

M M Klawe Sup erlinear Bounds on Matrix Searching In Proceedings of the st ACM Symposium on

Discrete Algorithms pages

M M Klawe and D J Kleitman An Almost Linear Time Algorithm for Generalized Matrix Searching

SIAM Journal of Discrete Mathematics

D Lee Medial axis transformation of a planar shap e IEEE Transactions on PAMI

D Lee and C Wong Voronoi Diagrams in L L Metrics With Dimensional Storage Applications

SIAM Journal on Computing

M McKenna J ORourke and S Suri Finding the largest rectangle in an orthogonal p olygon In

Proceedings of the rd Al lerton Conference on Communication Control and Computing pages

E Melissaratos and D Souvaine On Solving Geometric Optimization Problems Using Shortest Paths

In Proceedings of th Annual ACM Symposium on Computational Geometry pages

V J Milenkovic K Daniels and Z Li Automatic Marker Making In Proceedings of the rd Canadian

Conference on Computational Geometry

V J Milenkovic K Daniels and Z Li Placement and Compaction of Nonconvex Polygons for Clothing

Manufacture In Proceedings of the th Canadian Conference on Computational Geometry pages

A Naamad W L Hsu and D T Lee On the maximum empty rectangle problem Discrete Applied

Mathematics

J ORourke Art Gal lery Theorems and Algorithms Oxford University Press

J ORourke Computational Geometry in C draft Cambridge University Press

M H Overmars and D Woo d On rectangular visibility Journal of Algorithms

F Preparata and M Shamos Computational Geometry An Introduction SpringerVerlag New York

S Schuierer G J E Rawlins and D Woo d A Generalization of Staircase Visibility In Proceedings

of the rd Canadian Conference on Computational Geometry pages

D Woo d and C K Yap The Orthogonal Convex Skull Problem Discrete and Computational Geometry

C K Yap A geometric consistency theorem for a symbolic p erturbation scheme Journal of Computer

and System Sciences

A The Basic Parameter Problem

A Two Dep endent Sliding Contacts

This section supplies details for nding the LR under the assumption that it has two dep en

dent sliding contacts with the p olygon Refer to Figure a To nd the LR we parameterize

edge p p by t yielding the following quadratic in t to maximize

0 0

F t x xy y

A B tC D t

where

y y y b

x B x x A

m m

0

C y y D y y

y y

b y mx m

x x

0

p p Note that x is obtained by solving the line equation asso ciated with edge

A Three Dep endent Sliding Contacts

For the case of three dep endent sliding contacts see Figure b we again parameterize

0 0

edge p p and express x in terms of y for edge p p Similarly we express y in terms of x

p p We again obtain a quadratic in t to maximize The dierence b etween this for edge

and the previous case is in the values of C and D

0 0 0

C y m x b D y y m x x

y y

0 0 0

m b y m x

x x

B Pro of of the Characterization Theorem

This section present the pro of of Theorem of Section The determining set of the LR

of a general polygon P conforms up to symmetry to one of the ve cases in Figure

Pro of A determining set has by denition at most one reex contact with each side of

the LR For each of the p ossible numbers of reex contacts we show that the determining

set of a LR of that type conforms up to symmetry to one of the congurations shown in

Figure In each case we must eliminate degrees of freedom b eyond those of sliding contacts i

We observe that a determining set cannot contain b oth two adjacent reex contacts and the

xed contact b etween them this would b e redundant

Case In this case there is one reex contact with each side of the LR Since each reex contact

removes one degree of freedom from the rectangle this set of contacts is sucient to

determine the LR Removing any one reex contact allows the rectangle to grow so

all four contacts are necessary

Case Three reex contacts are not sucient to determine the LR since the fourth side can

move outward We must add an edge contact which is xed b ecause it is adjacent to

a reex contact There is only one choice of p osition for this contact up to symmetry

It xes the remaining side of the rectangle

Case Two reex contacts can touch either two adjacent sides or two opp osite sides of the

rectangle In b oth cases edge contacts are needed to determine the LR Since two

degrees of freedom remain the determining set contains at most two edge contacts

In the adjacent case we examine the p ossibility of edge contacts at the corners of the

rectangle excluding the corner b etween the two reex contacts There are two ways

that two edge contacts can app ear In b oth cases b oth contacts must b e xed so they

x the remaining sides of the rectangle If only one edge contact app ears it must

b e a sliding contact otherwise a degree of freedom remains The sliding contact is

diagonally opp osite to the corner xed by the reex contacts This contact is sucient

b ecause it represents a basic parameter problem

In the opp osite case any edge contact is xed hence there must b e two of them

There are two p ossible ways they can b e congured In b oth cases all four sides of the

rectangle are xed

Case One reex contact is not sucient to determine the LR We can choose to place edge

contacts at any three of the four corners of the rectangle four would b e redundant

If there are three edge contacts they are all xed and they completely determine

the LR There are two ways to congure three such contacts If there are two edge

contacts they can b e adjacent or diagonally opp osite If they are adjacent they must

b oth b e opp osite the reex contact otherwise a degree of freedom remains These

adjacent contacts are dep endent sliding contacts and they determine the LR b ecause

they represent a parameter problem If they are diagonally opp osite one is xed

and the other is a sliding contact this is also a parameter problem One edge contact

is not sucient together with the one reex contact to determine the LR ii

Case In this case there are no reex contacts One sliding contact is not sucient to deter

mine the LR If there are two sliding contacts they must b e opp osite if they are to

determine the LR This is a parameter problem If there are three edge contacts they

are all dep endent sliding contacts They are sucient to determine the LR b ecause

they represent a parameter problem If there are four edge contacts they yield four

equations in four unknowns for which the LR is completely determined This therefore

forms a set of xed contacts

C Finding the and Contact LRs in an Orthogo

nally Convex Polygon

We show that the and contact cases for the LR in orthogonally convex p olygons can

b e solved in linear time McKenna et al obtain the same time b ound for orthogonal

orthogonally convex p olygons

Lemma C The contact and contact LRs of an nvertex orthogonally convex poly

gon can be found in n time

c c 1 2

e e 1 2

visibility line

Figure BottomUp Sweep for and Contact Cases

Pro of of Lemma The and contact LRs have either b oth b ottom corners on the b ot

tom chains of P or b oth top corners on the top chains A b ottomup sweep solves the b ottom

corners case where events are vertices of the b ottom chains Each event determines a y span

along two edges e and e Let the top chain pieces corresp onding to e and e b e c and

c resp ectively see Figure The natural y ordering of vertices along c and c yields

iii

a set of secondary events on the upp er chains for this e e pair If an edge e for an

upp er event on c has a corresp onding edge e on c then we solve the contact problem

for fe e e e g Otherwise we solve the contact problem for fe e e g if e is b elow

c If e is ab ove c the contact LR is guaranteed to intersect c if it is b elow it will not

intersect Note that as the b ottom sweepline moves up the top sweepline moves down

The topdown sweep is similar

No sorting is required for the sweeps b ecause the xy monotone chains are naturally

ordered in x and y Because the visibility maps can b e precomputed in linear time c and

c are found in constant time For the b ottomup sweep the total number of upp er events

is linear b ecause each edge fragment is visited once for each sweep A constant amount of

work is done at each upp er event since the visibility map is precomputed and solving each

or contact problem requires only constant time by Theorem Thus the LR is found

in n time

This completes the pro of of Lemma C

D Fast Searching of Totally Monotone Matrices

Aggarwal and Klawe provide an alternate partitioning of a totally monotone rising double

staircase matrix to that of Aggarwal and Suri see Lemma Their partitioning holds for

the more general total ly monotone partial matrix which contains two sets of illegal entries

whose b oundaries are unimo dal sequences Klawe extends the denition of a totally

monotone partial matrix to any matrix whose set of legal entries is orthogonally convex

each row and column contains at most one contiguous group of legal entries Without giving

the details she notes that the algorithm leading to Lemma can b e trivially extended to

handle this type of matrix We observe that this type can b e accommo dated via partitioning

without extending the algorithm as follows

Lemma D An n m total ly monotone partial matrix M whose staircase boundaries are

known can be partitioned in On m time into a set of ve matrices One is a total ly

monotone double staircase matrix and the other four are total ly monotone single staircase

matrices

Pro of Let t b l and r b e the top b ottom leftmost and rightmost legal entries of M Let

p b e the downward pro jection of t and q b e the upward pro jection of b We can nd p and

q in On m time The matrix determined by tq bp is a totally monotone double staircase

0 0

matrix M M partitions M leaving triangular submatrices on the left and right If q is on

tr then the triangular submatrix q r b is partitioned into two totally monotone single staircase

matrices by the horizontal line through r and the triangular submatrix tl p is partitioned iv

into two totally monotone single staircase matrices by the horizontal line through l If q is

on tl we partition q l b and tr p into totally monotone single staircase matrices Partitioning

the triangular regions takes On m time

With this partitioning one can nd the maximum in a totally monotone partial matrix

in Onm m time by simply using Lemma and Lemma instead of extending the

algorithm asso ciated with Lemma

Whenever p ossible Section and Section used legal negative entries in the area

matrix in place of illegal entries In the case of orthogonally convex p olygons in Section

the matrix was double staircase If we had used illegal entries in all cases then the matrix

would have b een partial With that approach we still could have solved the problem using

time in Onn by applying Lemma We do not present the argument here but we

could have also solved the xy monotone p olygon problem of Section if we had used illegal

entries in all cases The matrix would have b een a fal ling double staircase matrix whose

maximum can b e found in O n time using a fairly straightforward completion technique

The use of negative entries made the algorithms simpler but was not essential to the running

times v