finding the largest area axis-parallel rectangle in a polygon in o(n log 2 n) time mathematical...

26
Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Prof. Karen Daniels Wednesday, October 18, 2000 Wednesday, October 18, 2000

Post on 21-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Finding the Largest Area Axis-Parallel Rectangle

in a Polygon in O(n log2 n) Time

Finding the Largest Area Axis-Parallel Rectangle

in a Polygon in O(n log2 n) Time

MATHEMATICAL SCIENCES COLLOQUIUMMATHEMATICAL SCIENCES COLLOQUIUM

Prof. Karen DanielsProf. Karen DanielsWednesday, October 18, 2000Wednesday, October 18, 2000

Page 2: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Computational Geometryin Context

Computational Geometryin Context

Applied Computer ScienceApplied Computer Science

GeometryGeometry

TheoreticalTheoretical

ComputerComputer

ScienceScience

AppliedApplied

MathMath

ComputationalComputationalGeometryGeometry

Efficient Efficient Geometric AlgorithmsGeometric Algorithms

Design Analyze

Apply

Page 3: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Taxonomy of ProblemsSupporting Apparel Manufacturing

Taxonomy of ProblemsSupporting Apparel Manufacturing

Ordered Ordered ContainmentContainment

Geometric RestrictionGeometric Restriction

Distance-Based Distance-Based SubdivisionSubdivision

Maximum Maximum RectangleRectangle

Limited GapsLimited Gaps

Minimal Minimal EnclosureEnclosure

Column-Based LayoutColumn-Based LayoutTwo-Phase LayoutTwo-Phase Layout

Lattice Lattice PackingPacking

ContainmentContainment

Maximal CoverMaximal Cover

Page 4: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

A Common (sub)Problem

Find a Good (and Convex) ApproximationFind a Good (and Convex) Approximation

Outer Outer InnerInner

Page 5: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Given a 2D polygon that:Given a 2D polygon that: does not intersect itselfdoes not intersect itself may have holesmay have holes has has nn vertices vertices

Find the Find the LLargest-Area Axis-Parallel argest-Area Axis-Parallel RRectangleectangle How “hard” is it?How “hard” is it? How “fast” can we find it?How “fast” can we find it?

What’s the Problem?

nn11 n log(n) n log(n) n logn log22(n) (n) 22nnnn55n n (n) log(n)(n) log(n)n n (n)(n)

Page 6: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Related WorkRelated Work

nn11 n log(n) n log(n) n logn log22(n) (n) 22nnnn55n n (n) log(n)(n) log(n)n n (n)(n)

Page 7: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Related Work

(continued)Related Work

(continued)

nn11 n log(n) n log(n) n logn log22(n) (n) 22nnnn55n n (n) log(n)(n) log(n)n n (n)(n)

Page 8: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Summary of Algorithmic Resultsfor a Variety of Polygon Types

Karen DanielsKaren Daniels

Victor MilenkovicVictor Milenkovic

Dan RothDan Roth

nn11 n log(n) n log(n) n logn log22(n) (n) 22nnnn55n n (n) log(n)(n) log(n)n n (n)(n)

(n log(n))

this this

talktalk

Page 9: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establishing an Upper Bound of O(n log2 n)

Establishing an Upper Bound of O(n log2 n)

Page 10: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establish O(nEstablish O(n55) upper bound) upper bound Characterize the Largest Rectangle (LR)Characterize the Largest Rectangle (LR)

examine cases based on polygon/LR contactsexamine cases based on polygon/LR contacts

Reduce the O(nReduce the O(n55) bound to O(n log) bound to O(n log22 n) n) Develop a general framework for dominant caseDevelop a general framework for dominant case

based on rectangular visibility and matrix total monotonicitybased on rectangular visibility and matrix total monotonicity

Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn)Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn) Apply the framework to obtain O(nlogn) for each levelApply the framework to obtain O(nlogn) for each level

Approach

Page 11: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Characterizing the LRCharacterizing the LRFixed Fixed

ContactContactIndependent Independent Sliding ContactSliding Contact

Dependent Dependent Sliding ContactsSliding Contacts

Reflex Reflex ContactContact

Contacts reduce degrees of freedomContacts reduce degrees of freedom

Page 12: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Characterizing the LR (continued)Characterizing the LR (continued)

# RC# RC

44

33

22

11

00

Determining setsDetermining sets of contacts of contacts

Page 13: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Characterizing the LR (continued)Characterizing the LR (continued)

1-parameter: 1-parameter: Max. quadratic in 1 variable: O(1) Max. quadratic in 1 variable: O(1)

1 Independent Sliding Contact1 Independent Sliding Contact 2 Dependent Sliding Contacts2 Dependent Sliding Contacts 3 Dependent Sliding Contacts3 Dependent Sliding Contacts

Maximization Problems for Sliding ContactsMaximization Problems for Sliding Contacts

2-parameter:2-parameter: Max. quadratic in 2 variables: O(1)Max. quadratic in 2 variables: O(1) At least one rectangle corner is at an At least one rectangle corner is at an

endpoint of polygon edgeendpoint of polygon edge Reduces to 4 1-parameter problemsReduces to 4 1-parameter problems

Page 14: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

O(n5) LR AlgorithmO(n5) LR Algorithm

Find_LR(Polygon P)Find_LR(Polygon P) area0 Find_LR_0_RC(P)area0 Find_LR_0_RC(P) area1 Find_LR_1_RC(P)area1 Find_LR_1_RC(P) area2 Find_LR_2_RC(P)area2 Find_LR_2_RC(P) area3 Find_LR_3_RC(P)area3 Find_LR_3_RC(P) area4 Find_LR_4_RC(P)area4 Find_LR_4_RC(P) return maximum(area0, area1, area2, area3, area4)return maximum(area0, area1, area2, area3, area4)

Find_LR_0_RC(P)Find_LR_0_RC(P)for i 1 to n [for each edge of P]for i 1 to n [for each edge of P]

for j 1 to nfor j 1 to n for k 1 to nfor k 1 to n for l 1 to nfor l 1 to n area area of LR for 0-RC determining set for (i,j,k,l)area area of LR for 0-RC determining set for (i,j,k,l)

if LR is empty, then update maximum areaif LR is empty, then update maximum area return maximum areareturn maximum areaO(n)O(n)

O(nO(n55))

Page 15: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establish O(nEstablish O(n55) upper bound) upper bound Characterize the Largest Rectangle (LR)Characterize the Largest Rectangle (LR)

examine cases based on polygon/LR contactsexamine cases based on polygon/LR contacts

Reduce the O(nReduce the O(n55) bound to O(n log) bound to O(n log22 n) n) Develop a general framework for dominant caseDevelop a general framework for dominant case

based on rectangular visibility and matrix total monotonicitybased on rectangular visibility and matrix total monotonicity

Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn)Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn) Apply the framework to obtain O(nlogn) for each levelApply the framework to obtain O(nlogn) for each level

Approach

Page 16: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

A General Framework for the 2-Contact CaseA General Framework for the 2-Contact Case

DefinitionDefinition: M is : M is totally monotonetotally monotone if, for every if, for every i<i’ and j<j’ corresponding to a legal 2x2 i<i’ and j<j’ corresponding to a legal 2x2 minor, mminor, mij’ij’ > m > mijij implies m implies mi’j’i’j’ > m > mi’ji’j

2424

1515

2727

2424

bb ccaa

11

22

33

1010

1414

66 2020 1515

aabb

cc

1122

33

TheoremTheorem [Aggarwal,Suri87]: If any entry of a totally [Aggarwal,Suri87]: If any entry of a totally monotone matrix of size mxn can be computed in O(1) time, monotone matrix of size mxn can be computed in O(1) time, then the row-maximum problem for this matrix can be then the row-maximum problem for this matrix can be solved in solved in (m+n) time.(m+n) time.

A General Framework for the 2-Contact CaseA General Framework for the 2-Contact Case

Area Matrix M for “empty corner rectangles”Area Matrix M for “empty corner rectangles”

LR is the Largest Empty Corner Rectangle (LECR) LR is the Largest Empty Corner Rectangle (LECR)

Page 17: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

A General Framework for the 2-Contact CaseA General Framework for the 2-Contact Case PP

Property IProperty I Polygonal regions P and P’ satisfy P’ P and each Polygonal regions P and P’ satisfy P’ P and each vertex-edge rectangle for P, V, and E is a vertex-vertex-edge rectangle for P, V, and E is a vertex-edge rectangle for P’, V’, and E’.edge rectangle for P’, V’, and E’.

Property IIProperty II For every vertex v For every vertex v V’ and every edge e V’ and every edge e E’: if E’: if any point q any point q interior(e) is rectangularly visible interior(e) is rectangularly visible from v inside P’, then all of e is rectangularly from v inside P’, then all of e is rectangularly visible from v.visible from v.

Property IIIProperty III If vertex v If vertex v V’ and a point q V’ and a point q E’ are E’ are rectangularly visible with respect to rectangularly visible with respect to vertices(P’), then v and q are rectangularly vertices(P’), then v and q are rectangularly visible with respect to P’.visible with respect to P’.

VV EEP’P’V’V’

E’E’

Given vertically separated, y-monotone Given vertically separated, y-monotone chains V, E of P, “orthogonalize” themchains V, E of P, “orthogonalize” them

U

GoalGoal: reduce to the Largest Empty : reduce to the Largest Empty Corner Rectangle (LECR) problemCorner Rectangle (LECR) problem

Page 18: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Monotonicity and Aggarwal et al.’s matrix Monotonicity and Aggarwal et al.’s matrix searching-based O(nlogn) algorithm for the searching-based O(nlogn) algorithm for the LECR problem lead to the following:LECR problem lead to the following:

LemmaLemma: The LR in an n-vertex : The LR in an n-vertex vertically separated, horizontally vertically separated, horizontally convex polygon can be found in convex polygon can be found in O(n log n) time.O(n log n) time.

GoalGoal: Produce a vertically separated, : Produce a vertically separated, horizontally convex polygon for the horizontally convex polygon for the merge step of divide-and-conquer.merge step of divide-and-conquer.

LR Algorithm for a General PolygonLR Algorithm for a General Polygon

LemmaLemma: If V’ and E’ are y-monotone, then M defined by our : If V’ and E’ are y-monotone, then M defined by our LR-measure (“area”) is totally monotone. LR-measure (“area”) is totally monotone.

Page 19: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

TheoremTheorem: The LR in an n-: The LR in an n-vertex general polygon can vertex general polygon can be found in O(n logbe found in O(n log22 n) time. n) time.

Partitioning the polygon Partitioning the polygon with a vertical line with a vertical line produces a vertically produces a vertically separated, horizontally separated, horizontally convex polygon for the merge convex polygon for the merge step of divide-and-conquer.step of divide-and-conquer.

LR Algorithm for a General PolygonLR Algorithm for a General Polygon

Page 20: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

O(n log2 n) LR AlgorithmO(n log2 n) LR Algorithm

Find_LR(Polygon P)Find_LR(Polygon P) preprocess Ppreprocess P

H, V horizontal, vertical visibility maps of PH, V horizontal, vertical visibility maps of P P P P P UU internal vertex projections internal vertex projections return LR_DivideConquer(P, H, V)return LR_DivideConquer(P, H, V)

LR_DivideConquer(P, H, V)LR_DivideConquer(P, H, V)if P.numVertices is “too small”calculate & return LR areaif P.numVertices is “too small”calculate & return LR area

PPleft , left , PPrightright left, right parts of P L left, right parts of P L [vertical partitioning line][vertical partitioning line]

HHleft , left , HHleft , left , VVleft , left , VVright right H, V updated for LH, V updated for L

areaarealeftleft LR_DivideConquer(P LR_DivideConquer(P left left , H, Hleft left , V, Vleftleft))

areaarearightright LR_DivideConquer(P LR_DivideConquer(Prightright, H, Hright right , V, Vrightright)) Q Q UU1<=i<=k1<=i<=k Q Qii [L may contain k partitions] [L may contain k partitions]

areaareaQQ LR_HV_DivideConquer(Q) LR_HV_DivideConquer(Q)

return maximum(areareturn maximum(area leftleft , area , arearightright, area, areaQQ ) )

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

UU

O(n logO(n log22 n) n)

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

T(n) < 2T( | n/2 |) + O(nlogn)T(n) < 2T( | n/2 |) + O(nlogn)

T( | n/2 |)T( | n/2 |)T( | n/2 |)T( | n/2 |)

Page 21: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establishing a Lower Bound of (n log n)

Establishing a Lower Bound of (n log n)

Page 22: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Lower Bounds in Context Lower Bounds in Context

nn11 n log(n) n log(n) n logn log22(n) (n) 22nnnn55

SmallestOuterRectangle: (n)

SmallestOuterCircle: (n)

LargestInnerRectangle: (n log n)

LargestInnerCircle: (n log n)

point set, polygonpoint set, polygon

point set, polygonpoint set, polygon

point setpoint setpolygonpolygon

LargestInnerRectangle: (n log2(n)) polygonpolygon

Page 23: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establishing a Lower Bound of (n log n)Establishing a Lower Bound of (n log n)

MAX-GAP MAX-GAP instanceinstance: given : given nn real numbers { x real numbers { x11, x, x22, ... x, ... xn n } find the } find the maximum difference between 2 consecutive numbers in the maximum difference between 2 consecutive numbers in the sortedsorted list. list.

O(n) time transformationO(n) time transformation

self-intersecting, self-intersecting, orthogonal polygonorthogonal polygon

xx22xx44 xx33 xx11

LR area is a LR area is a solution to the solution to the MAX-GAP MAX-GAP instanceinstance

LR algorithm must take as least as much time as MAX-GAP.LR algorithm must take as least as much time as MAX-GAP.But, MAX-GAP is already known to be in But, MAX-GAP is already known to be in (n log n).(n log n).

LR algorithm must take LR algorithm must take (n log n) time(n log n) timefor self-intersecting polygons.for self-intersecting polygons.

Page 24: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establishing a Lower Bound of (n log n)Establishing a Lower Bound of (n log n)

EVEN-DISTRIBUTIONEVEN-DISTRIBUTION: given : given nn real numbers { x real numbers { x11, x, x22, ... x, ... xn n } }

check if there exist adjacent xcheck if there exist adjacent xii, x, xjj in the in the sortedsorted list s.t. x list s.t. xjj - x- xi i > 1 > 1

LR must take as least as much time as LR must take as least as much time as EVEN-DISTRIBUTIONEVEN-DISTRIBUTION..But, But, EVEN-DISTRIBUTIONEVEN-DISTRIBUTION is already known to be in is already known to be in (n log n).(n log n).

LR algorithm must take LR algorithm must take (n log n) time(n log n) timefor polygons with degenerate holes.for polygons with degenerate holes. [McKenna et al. (85)][McKenna et al. (85)]

O(n) time transformationO(n) time transformation

orthogonal polygon orthogonal polygon with degenerate with degenerate

holesholesxx22xx44 xx33 xx11

LR area is a LR area is a solution to the solution to the EVEN-EVEN-DISTRIBUTION DISTRIBUTION instanceinstance

Extend to Extend to non-degeneratenon-degenerate holes using symbolic perturbation. holes using symbolic perturbation.

Page 25: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

Establish O(n logEstablish O(n log22 n) upper bound for LR n) upper bound for LR Establish O(nEstablish O(n55) upper bound) upper bound

Characterize the Largest Rectangle (LR)Characterize the Largest Rectangle (LR) examine cases based on polygon/LR contactsexamine cases based on polygon/LR contacts

Reduce the O(nReduce the O(n55) bound to O(n log) bound to O(n log22 n) n) Develop a general framework for dominant caseDevelop a general framework for dominant case

based on rectangular visibility and matrix total monotonicitybased on rectangular visibility and matrix total monotonicity

Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn)Use divide-and-conquer: T(n) < 2T( | n/2 |) + O(nlogn) Apply the framework to obtain O(nlogn) for each levelApply the framework to obtain O(nlogn) for each level

Establish Establish (n log n) lower bound for LR(n log n) lower bound for LR

Summary

Page 26: Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October

For More InformationFor More Information

Computational Geometry:Computational Geometry: Graduate CS course in Computational Geometry Graduate CS course in Computational Geometry to be offered at UMass Lowell in Spring ‘01to be offered at UMass Lowell in Spring ‘01 Introductory texts:Introductory texts:

Computational Geometry in CComputational Geometry in C (O’Rourke)(O’Rourke) Computational Geometry: An IntroductionComputational Geometry: An Introduction (Preparata & Shamos)(Preparata & Shamos)

Bibliography: ftp://ftp.cs.usask.ca/pub/geometry/Bibliography: ftp://ftp.cs.usask.ca/pub/geometry/ Software:http://www.geom.umn.edu/software/cglist/Software:http://www.geom.umn.edu/software/cglist/

My research:My research: http://www.cs.uml.edu/~http://www.cs.uml.edu/~kdanielskdaniels Journal paperJournal paper: “Finding the largest area axis-parallel rectangle in a polygon”: “Finding the largest area axis-parallel rectangle in a polygon”

((Computational Geometry: Theory and ApplicationsComputational Geometry: Theory and Applications)) Prof. Victor Milenkovic: Frequent co-author and former PhD advisorProf. Victor Milenkovic: Frequent co-author and former PhD advisor

http://www.cs.miami.edu/~vjmhttp://www.cs.miami.edu/~vjm