20th Canadian Conference on Computational Geometry, 2008RtlFtrRtlp jFtrFblp jp i Rbr Fblp iRbr(a)Figure 1: <strong>Orthoconvex</strong> polygons(b)comb<strong>in</strong>atorial explosion holds for MEOP also. We nowpresent a polynomial time algorithm for comput<strong>in</strong>g themaximum-area MEOP.3 AlgorithmWe shall consider all possible pairs <strong>of</strong> po<strong>in</strong>ts p i , p j ∈ P,and identify the maximum area MEOP with p i ∈ F blas the closest po<strong>in</strong>t <strong>of</strong> the bottom boundary <strong>of</strong> R, andp j ∈ F tr as the closest po<strong>in</strong>t <strong>of</strong> the top boundary <strong>of</strong> R.The po<strong>in</strong>ts p i and p j are said to be the bottom-pivot andtop-pivot respectively, and the correspond<strong>in</strong>g MEOP isdenoted by MEOP(p i , p j ). We will use S to denote thevertical slab bounded by V i and V j . The projections <strong>of</strong>a po<strong>in</strong>t p k ∈ S on V i , V j , H i and H j are denoted by q k ,qk ′ , r k and rk ′ respectively. We now separately considertwo cases: (i) x(p i ) < x(p j ), and (ii) x(p i ) > x(p j ).In Case (i), the l<strong>in</strong>es V i and V j split the po<strong>in</strong>t set P<strong>in</strong>to three parts, P 1 , P 2 and P 3 , where P 1 and P 3 arethe set <strong>of</strong> po<strong>in</strong>ts to the left <strong>of</strong> V i and to the right <strong>of</strong> V jrespectively, and the po<strong>in</strong>ts <strong>in</strong> P 2 lie <strong>in</strong>side the verticalslab S. If V i hits the top and bottom boundaries <strong>of</strong>R at t 1 and b 1 respectively, and V j hits the top andbottom boundaries <strong>of</strong> R at t 2 and b 2 respectively. Now,the portion <strong>of</strong> the MEOP <strong>in</strong>side the vertical slab S,denoted by M 2 (b 1 , t 2 ), is an empty staircase polygonwith diagonally opposite corners b 1 and t 2 among thepo<strong>in</strong>ts <strong>in</strong> P 2 . The two stairs <strong>of</strong> M 2 (b 1 , t 2 ) are parts <strong>of</strong>the ris<strong>in</strong>g stairs R br and R tl respectively. If R tl hitsV i at q α , then the portion <strong>of</strong> the MEOP to the left <strong>of</strong>V i , denoted by M 1 (q α ), is an empty edge-visible polygonwith base [p i , q α ] among the po<strong>in</strong>ts <strong>in</strong> P 1 such that everypo<strong>in</strong>t <strong>in</strong>side the polygon is visible from its base [p i , q α ].Similarly, if R br hits V j at q β ′ then M 3(q β ′ ) is an emptyedge-visible polygon with base [p j , q β ′ ] among the po<strong>in</strong>ts<strong>in</strong> P 3 .In Case (ii), V j is to the left <strong>of</strong> V i . Here M 2 is an emptystaircase polygon from p i to p j , and these are the parts<strong>of</strong> F bl and F tr <strong>of</strong> the MEOP respectively. If F bl (resp.F tr ) hits V j (resp. V i ) at q ′ α (resp. q β), then M 1 (q ′ α )(portion to the left <strong>of</strong> V j ) is an edge-visible polygon withbase [q ′ α , p j], and M 3 (q β ) (portion to the right <strong>of</strong> V i ) isan edge-visible polygon with base [q β , p i ]. After fix<strong>in</strong>g p iand p j as the bottom-pivot and top-pivot respectively,we need to choose M 1 , M 2 and M 3 such that the sum<strong>of</strong> areas <strong>of</strong> these three polygons is maximum among allsuch polygons. We shall describe our algorithm for Case(i) only. Case (ii) can easily be handled us<strong>in</strong>g a similarmethod. For Case (i), we expla<strong>in</strong> the method <strong>of</strong> comput<strong>in</strong>gthe desired M 1 and M 2 . The computation <strong>of</strong> M 3is the same as that <strong>of</strong> M 1 .3.1 Computation <strong>of</strong> M 1Let us consider a po<strong>in</strong>t p i ∈ P. Let P 1 = {p k |x(p k ) x(p i ) and y(p k ) > y(p i )}.Q <strong>in</strong>cludes the top-right corner <strong>of</strong> R, and |Q| = m +1. Let q 0 , q 1 , q 2 , . . . , q m denote the projections <strong>of</strong> thepo<strong>in</strong>ts <strong>in</strong> Q on the vertical l<strong>in</strong>e V i <strong>in</strong> decreas<strong>in</strong>g order<strong>of</strong> their y-coord<strong>in</strong>ates. We create an array EV L(p i )whose elements are the maximum area empty edgevisiblepolygon M 1 (q k ) with [p i , q k ] as the base for allk = 0, 1, 2, . . ., m.We use vertical l<strong>in</strong>e sweep among the po<strong>in</strong>ts <strong>in</strong> P 1 start<strong>in</strong>gfrom the position <strong>of</strong> V i to create a height-balancedb<strong>in</strong>ary tree T . Its each node v is represented as a 5-tuple(I, x val, y val, ∆, δ). I is the base <strong>of</strong> the edge-visiblepolygons attached to node v. (x val, y val) is the po<strong>in</strong>twhere the node v is generated, and ∆ conta<strong>in</strong>s the area<strong>of</strong> the largest edge visible polygon rooted at that node.The ∆ parameters are computed <strong>in</strong> two passes. In theforward pass dur<strong>in</strong>g the sweep, the ∆ parameter <strong>of</strong> anode conta<strong>in</strong>s the area <strong>of</strong> the edge visible polygon thatis computed so far at that node. At the end <strong>of</strong> thesweep, a backward pass is executed from the leaf level<strong>of</strong> T up to its root, and ∆ value <strong>of</strong> each node is properlyset. The δ value <strong>of</strong> all nodes are 0 at the time <strong>of</strong> creation<strong>of</strong> T ; it will be set and used dur<strong>in</strong>g the computation <strong>of</strong>M 1 (q k ) for different q k .Creation <strong>of</strong> TThe root r <strong>of</strong> T corresponds to the entire <strong>in</strong>tervalI = [p i , q 0 ]; its x val and ∆ parameters are set tox(p i ) and 0 respectively. A vertical l<strong>in</strong>e sweep is performedfrom x = x(p i ) towards left. When a po<strong>in</strong>tp = (x(p), y(p)) ∈ P 1 is faced by the sweep l<strong>in</strong>e, theleaf nodes <strong>in</strong> T are searched. If y(p) lies <strong>in</strong> the <strong>in</strong>ter-
CCCG 2008, Montréal, Québec, August 13–15, 2008val [α, β] <strong>of</strong> a node v = ([α, β], µ, ν, ∆, δ), we compute∆ ∗ = ∆+(µ−x(p))×(β −α). Next, we create two children<strong>of</strong> v, namely v a = ([α, y(p)], x(p), y(p), ∆ ∗ , 0) andv b = ([y(p), β], x(p), y(p), ∆ ∗ , 0). F<strong>in</strong>ally, the backwardpass is executed from leaves towards the root <strong>in</strong> postordermanner to set the ∆ values as described above.Computation <strong>of</strong> M 1 (q k )M 1 (q 0 ) = ∆ attached to the root node r. While process<strong>in</strong>gq k , we assume that q k−1 is already processed. Westart scan<strong>in</strong>g from the root <strong>of</strong> T . At a particular nodev = ([α, β], µ, ν, ∆(v), δ(v)) on the search path, one <strong>of</strong>the follow<strong>in</strong>g two situations may happen: (i) ν ≥ y(q k )and (ii) ν < y(q k ).In Case (i), we compute A = (x(p i ) − µ) × (y(q k ) −y(q k−1 )). The area A is to be subtracted from all theedge-visible polygons stored <strong>in</strong> the the right-child v b <strong>of</strong>the node v. We subtract A from ∆(v b ). Without entirelytravers<strong>in</strong>g the subtree rooted at v b , we add A <strong>in</strong>δ(v b ). The motivation is that, while process<strong>in</strong>g someother q l , if the subtree rooted at v b is traversed, δ(v b )will be subtracted from the ∆ value <strong>of</strong> those nodes. Thesearch proceeds towards the left child <strong>of</strong> the node v. Ateach move from a node v to its children v ′ , δ(v) is subtractedfrom ∆(v ′ ), and added to δ(v ′ ), and then δ(v)is set to 0.In Case (ii), the edge visible polygon <strong>in</strong> the left child v a<strong>of</strong> the node v does not exist; so we delete the subtreerooted at v a and the node v also; the search proceedstowards the right child <strong>of</strong> v. The propagation <strong>of</strong> δ isto be performed at each step, but the computation <strong>of</strong>excess area A is to be performed when Case (i) arises.Next, a backward pass is needed to set the ∆ field <strong>of</strong> allthe nodes <strong>in</strong> the updated T . F<strong>in</strong>ally, M 1 (q k ) is set withthe ∆ value <strong>of</strong> the root <strong>of</strong> the updated T .Lemma 1 The computation <strong>of</strong> M 1 (q k ) for all k =0, 1, . . .,m needs O(n 2 ) time.Pro<strong>of</strong>. The creation <strong>of</strong> T needs O(n log n) time. Thelemma follows from the fact that the comb<strong>in</strong>atorial complexity<strong>of</strong> M 1 (q k ) is O(n) for all k = 0, 1, . . .,m. ✷Similarly, with each po<strong>in</strong>t p i ∈ P, an array EV R(p i ) isattached. If the projections <strong>of</strong> the po<strong>in</strong>ts {p k |x(p k )