Largest triangles in a polygon
LLargest triangles in a polygon ∗ Seungjun Lee † Taekang Eom ‡ Hee-Kap Ahn § Abstract
We study the problem of finding maximum-area triangles that can be inscribed in apolygon in the plane. We consider eight versions of the problem: we use either convexpolygons or simple polygons as the container; we require the triangles to have either onecorner with a fixed angle or all three corners with fixed angles; we either allow reorienting thetriangle or require its orientation to be fixed. We present exact algorithms for all versions ofthe problem. In the case with reorientations for convex polygons with n vertices, we alsopresent (1 − ε ) -approximation algorithms. We study the problem of finding maximum-area triangles that are inscribed in a polygon in theplane. When the shape of the triangle is fully prescribed, this problem is related to the polygoncontainment problem , which for given two polygons P and Q , asks for the largest copy of Q thatcan be contained in P using rotations, translations, and scaling. The problem is related to theproblem of inscribing polygons if the shape is partially prescribed. In inscribing polygons, we aregiven a polygon P and seek to find a best polygon with some specified number of vertices thatcan be inscribed in P with respect to some measures.Problems of this flavor have a rich history and are partly motivated by the attempt toreduce the complexity of various geometric problems, including the shape recognition andmatching problems, arising in various applications in pattern recognition, computer vision andcomputational geometry [7, 13, 21]. Chapter 30.5 in the Handbook of Discrete and ComputationalGeometry [20] provides a survey on the related works.There has been a fair amount of work on inscribing a maximum-area convex k -gon in a polygon.A maximum-area convex k -gon inscribed in a convex n -gon can be computed in O ( kn + n log n ) time [2, 15]. The best algorithm for computing a maximum-area convex polygon inside a simple n -gon takes O ( n ) time and O ( n ) space [9]. Hall-Holt et al. [18] gave an O ( n log n ) -time O (1) -approximation algorithm for finding a maximum-area convex polygon inscribed in a simple n -gon. Melissaratos et al. [17] gave an algorithm for finding a maximum-area triangle inscribedin a simple n -gon in O ( n ) time. When the maximum-area triangle is restricted to have all itscorners on the polygon boundary, and it takes O ( n ) time. ∗ This research was supported by the Institute of Information & communications Technology Planning &Evaluation(IITP) grant funded by the Korea government(MSIT) (No. 2017-0-00905, Software Star Lab (OptimalData Structure and Algorithmic Applications in Dynamic Geometric Environment)) † Department of Computer Science and Engineering, Pohang University of Science and Technology, Pohang,Korea. [email protected] ‡ Department of Mathematics, Pohang University of Science and Technology, Pohang, Korea. [email protected] § Department of Computer Science and Engineering, Graduate School of Artificial Intelligence, Pohang Universityof Science and Technology, Pohang, Korea. [email protected] a r X i v : . [ c s . C G ] J u l onvex polygons Simple polygonsFixed angles All One All OneAxis-aligned O (log n ) [16] O (log n ) O ( n log n ) O ( n log n ) (homothet) (homothet)Reorientations O ( n ) O ( n ) O ( n log n ) O ( n ) O ( ε − log n + ε − ) O ( ε − log n + ε − log ε − ) Table 1: Time complexities of the algorithms. All algorithms use O ( n ) space.For finding a maximum-area copy of a given polygon Q that can be inscribed in a polygon P , there are results known for cases of convex, orthogonal, and simple polygons, possibly withholes. A maximum-area copy of a convex k -gon that can be inscribed in a convex n -gon canbe computed in O ( n + k log k ) time [19, 14] under translation and scaling, and in O ( nk log k ) time [1] under translation, scaling, and rotation. For a maximum-area homothet of a giventriangle inscribed in a convex polygon P with n vertices, Kirkpatrick and Snoeyink gave an O (log n ) -time algorithm to find one [16], given the vertices are stored in order along the boundaryin an array or balanced binary search tree. The maximum-area equilateral triangles of arbitraryorientation inscribed in a simple n -gon can be computed in O ( n ) time [11].There also have been works on finding a maximum-area partially prescribed shape that can beinscribed in a polygon. Amenta showed that a maximum-area axis-aligned rectangle inscribed ina convex n -gon can be found in linear time by phrasing it as a convex programming problem [6].When the vertices are already stored in order along the boundary in an array or balancedbinary search tree, the running time was improved to O (log n ) [12], and then to O (log n ) [4].Cabello et al. [8] considered the maximum-area and maximum-perimeter rectangle of arbitraryorientation inscribed in a convex n -gon, and presented an O ( n ) -time algorithm. Very recently,Choi et al. [10] gave O ( n log n ) -time algorithm for finding maximum-area rectangles of arbitraryorientation inscribed in a simple n -gon, possibly with holes. However, little is known for thecase of partially prescribed triangles inscribed in convex and simple polygons, except a PTASresult by Hall-Holt et al. [18] for finding a maximum-area fat triangle that can be inscribed in asimple n -gon. We study the problem of finding maximum-area triangles that can be inscribed in a polygon inthe plane. We consider eight versions of the problem: we use either convex polygons or simplepolygons as the container; we require the triangles to have either one corner with a fixed interiorangle or all three corners with fixed interior angles; we either allow reorienting the triangle orrequire its orientation to be fixed. We study all versions of the problem in this paper and presentefficient algorithms for them. Table 1 summarizes our results.We assume that the vertices of the input polygon are stored in order along its boundary inan array or a balanced binary search tree. We say a triangle is axis-aligned if one of its sides isparallel to the x -axis, and we call the side the base of the triangle. We say a triangle has onefixed angle if one of the two interior angles at corners incident to the base of the triangle is fixed.For a convex polygon P with n vertices, a maximum-area homothet of a given triangle thatcan be inscribed in P can be computed in O (log n ) time [16]. For axis-aligned triangles with onefixed angle, we present an algorithm that computes a maximum-area such triangle that can be Two shape are homothetic if one can be obtained from the other by scaling and translation. A triangle is δ -fat if all three of its angles are at least some specific constant δ . P in O (log n ) time using O ( n ) space.When reorientations are allowed, we present an algorithm that computes a maximum-areatriangle with fixed interior angles that can be inscribed in P in O ( n ) time using O ( n ) space.We also present an (1 − ε ) -approximation algorithm that takes O ( ε − log n + ε − ) time. Fortriangles with one fixed angle, we present an algorithm to compute a maximum-area triangle thatcan be inscribed in P in O ( n ) time using O ( n ) space. We also present an (1 − ε ) -approximationalgorithm that takes O ( ε − log n + ε − log ε − ) time.For a simple polygon P with n vertices, we present an algorithm that computes a maximum-area homothet of a given triangle that can be inscribed in P in O ( n log n ) time using O ( n ) space.We also present an algorithm to compute a maximum-area axis-aligned triangle with one fixedangle that can be inscribed in P in O ( n log n ) time using O ( n ) space.When reorientations are allowed, we present an algorithm to compute a maximum-areatriangle with fixed interior angles that can be inscribed in P in O ( n log n ) time using O ( n ) space. For triangles with one fixed angle, we present an algorithm to compute a maximum-areatriangle that can be inscribed in P in O ( n ) time using O ( n ) space.Whenever we say a largest triangle , it refers to a maximum-area triangle inscribed in P . Wedenote the triangle with three corners p, q, r (counterclockwise order) by (cid:52) pqr , where pq is base.For two fixed angles α, β > , we call the triangle with ∠ rpq = α an α -triangle and the trianglewith ∠ rpq = α and ∠ pqr = β an ( α, β ) -triangle . Let area ( T ) denote the area of a triangle T . Consider a convex polygon P with n vertices in the plane. We show for fixed angles α and β how to find largest ( α, β ) -triangles and largest α -triangles, aligned to the x -axis or of arbitraryorientation, that can be inscribed in P . ( α, β ) -triangles Since all interior angles of an ( α, β ) -triangle are fixed, this problem is to find a largest copy of agiven triangle that can be inscribed in P using rotations, translations, and scaling. When theorientation of triangles is fixed, the problem reduces to finding a largest homothet of a giventriangle that can be inscribed in P . A homothet of a figure is a scaled and translated copy of thefigure.A largest homothet of a given triangle that can be inscribed in P can be computed in O (log n ) time [16]. Thus, we focus on the case in which arbitrary orientations are allowed. This problem issimilar to finding a largest equilateral triangle in a convex polygon [11]. A largest ( α, β ) -trianglein a convex polygon P must have at least one corner lying on a vertex of P by the same argumentfor largest equilateral triangles in Theorem 1 of [11].Consider an ( α, β ) -triangle (cid:52) t t t . Let Φ v ( s, ϑ ) denote the affine transformation that scales s and rotates ϑ in counterclockwise direction around a vertex v of P . Let ϕ ,v = Φ v ( sin β sin( α + β ) , α ) , ϕ ,v = Φ v ( sin( α + β )sin α , β ) , ϕ ,v = Φ v ( sin α sin β , π − α − β ) . For t i lying on a vertex v of P , we observe that t i +1 , t i +2 ∈ P if and only if t i +2 ∈ P ∩ ϕ i,v ( P ) with indices under modulo 3. See Figure 1(a) for an illustration. Thus, for a fixed vertex v of P , we can compute a largest triangle (cid:52) t t t with t at v in O ( n ) time by finding the longestsegment vt i +2 contained in P ∩ ϕ i,v ( P ) . By repeating this for every vertex v of P such thatcorner t i lies on v for i = 0 , , , a largest ( α, β ) -triangle can be computed in O ( n ) time.3 heorem 1. Given a convex polygon P with n vertices in the plane and two angles α, β , we cancompute a maximum-area ( α, β ) -triangle of arbitrary orientations that can be inscribed in P in O ( n ) time. We give an example of a convex polygon with Ω( n ) combinatorially distinct candidates ofan optimal triangle with α = β = 60 ◦ . Let P be a convex polygon with n vertices such that n vertices of P are placed uniformly on a circular arc of interior angle ◦ , and the remaining n vertices are placed densely in the neighborhood of the center of the arc as shown Figure 1(b).If v is one of the n vertices near the center, P ∩ ϕ ,v ( P ) has n − vertices along by the arc,and thus there are Θ( n ) candidates of t for each such vertex v to consider for the longest vt in P ∩ ϕ ,v ( P ) . This gives Θ( n ) candidates for the longest vt of similar lengths, and thus Θ( n ) combinatorially distinct ( α, β ) -triangles with side vt . Any algorithm iterating over all suchtriangles takes Ω( n ) time. ϕ ,v ( P ) Pv (a) ab c m a m c P (c) t t βα t Pt = v α βϕ ,v ( P ) t (b) Figure 1: (a) A largest ( α, β ) -triangle (cid:52) t t t with t lying on a vertex v of P is determined by thelongest segment vt contained in P ∩ ϕ ,v ( P ) . (b) An example of Θ( n ) combinatorially distinct ( α, β ) -triangles with side vt to consider for an optimal triangle. (c) The largest axis-alignedright triangle with m a < and m c < . α -triangles This problem is to find a largest triangle with one corner angle fixed to a constant α that canbe inscribed in a convex polygon P . We consider α -triangles that are either axis-aligned or ofarbitrary orientations. α -triangles We start with an algorithm to compute a largest axis-aligned α -triangle for α = 90 ◦ . Alt etal. [5] presented an algorithm of computing a largest axis-aligned rectangle that can be inscribedin a convex polygon. We follow their approach with some modification. If two corners of thetriangle are on the polygon boundary, the algorithm by Alt et al., works to compute a largestaxis-aligned right triangle that can be inscribed in P .So in the following, we focus on the case that a largest axis-aligned right triangle has allits corners on the boundary of P . Consider a largest axis-aligned right triangle (cid:52) bac with allthree corners on the boundary of P . See Figure 1(c) for an illustration. Let m a and m c denotethe slopes of the polygon edges where a and c lie, respectively, and let m ac denote the slope of ac . Then, either (1) m a < or m c < , or (2) m a > and m c > . Observe that no rectanglecontaining a largest axis-aligned right triangle belonging to case (1) is contained in P , and thusthe algorithm by Alt et al. fails to find a largest axis-aligned right triangle belonging to the case.4 m c > m b m b m a < c(cid:46) (cid:47)a T FF TT m a < − m ac a(cid:46) − m ac < m c (cid:47)c F TT ≤ m a < m c FT a y ≥ b y (cid:47)a ∨ (cid:47)b a (cid:46) ∨ b(cid:46) (cid:47)a ∨ b (cid:46) ∨ (cid:47) c − m ≤ m a m c − m b m a − m b a (cid:46) ∨ (cid:47) b ∨ c(cid:46) TF Test associated withfunction f . Test associated withfunction h . Figure 2: Modified tests associated with functions f and h .We compute a largest axis-aligned right triangle in O (log n ) time using the tentative prune-search algorithm [5] by replacing the tests associated with functions f and h by the ones inFigure 2. Using the tests, we can determine a half of the candidate triples of polygon edgesin which a largest axis-aligned right triangle cannot have their corners, and continue to find alargest axis-aligned right triangle on the remaining half of the candidate triples of polygon edges.The algorithm to compute a largest axis-aligned right triangle can compute the axis-aligned α -triangle using linear transformation L α = (cid:0) α (cid:1) − for α . Then, L α ( T ) is an axis-alignedright triangle for an α -triangle T . Observe that T is a largest axis-aligned α -triangle inscribedin P if and only if L α ( T ) is a largest axis-aligned right triangle inscribed in L α ( P ) , a convexpolygon. However, it takes O ( n ) time for computing entire description of L α ( P ) . To reduce thetime complexity, we compute L α ( p ) only when we need the slope of the polygon edge containing p or the right side of an α -triangle with corner at p on the polygon boundary. Since there are O (log n ) decision steps in the algorithm and each decision step uses only a constant number ofpoints on the polygon boundary, we have following theorem. Theorem 2.
Given a convex polygon P of n vertices in the plane and an angle α , we can find amaximum-area axis-aligned α -triangle that can be inscribed in P in O (log n ) time. α -triangles of arbitrary orientations We can compute a largest α -triangle of arbitrary orientations by simply iterating over all triplesof edges of P . For each triple of edges of P , we can find a largest α -triangle T with corners onthe edges of the triple in O (1) time. Theorem 3.
Given a convex polygon P of n vertices in the plane and an angle α , we can find amaximum-area α -triangle of arbitrary orientation that can be inscribed in P in O ( n ) time using O ( n ) space. One may wonder if the running time can be improved. Cabello et al. showed a constructionof a convex polygon with n vertices that has Θ( n ) combinatorially distinct rectangles that canbe inscribed in the polygon. By using a similar construction, we can show that there are Θ( n ) combinatorially distinct α -triangles that can be inscribed in a convex polygon with n vertices.Thus, any algorithm iterating over all those combinatorially distinct triangles takes Ω( n ) time.5 .3 FPTAS in arbitrary orientations Let T opt be a largest ( α, β ) -triangle that can be inscribed in P . We can compute an ( α, β ) -triangleinscribed in P whose area is at least (1 − ε ) times area ( T opt ) in O ( ε − log n + ε − ) time using ε -kernel [8]. For any ε ∈ (0 , , an ε -kernel for a convex polygon P is a convex polygon P ε suchthat for all unit vectors u in the plane, (1 − ε ) w ( P, u ) ≤ w ( P ε , u ) , where w ( P, u ) is the length ofthe orthogonal projection of P onto any line parallel to u . Theorem 4.
Given a convex polygon P with n vertices in the plane, two angles α, β , and ε > ,we can find an ( α, β ) -triangle that can be inscribed in P and whose area is at least (1 − ε ) timesthe area of a maximum-area ( α, β ) -triangle inscribed in P in O ( ε − log n + ε − ) time.Proof. By Lemma 1 in [8], an ε -kernel P ε of P has O ( ε − ) vertices and it can be computed in O ( ε − log n ) time. A largest ( α, β ) -triangle inscribed in P ε has area at least (1 − ε ) times thearea of the largest ( α, β ) -triangle inscribed in P by Lemma 8 in [8], and it can be computed in O ( ε − ) time. α -triangles of arbitrary orientations Let T opt denote a largest α -triangle that can be inscribed in P . We can compute an α -triangleinscribed in P whose area is at least (1 − ε ) times area ( T opt ) in O ( ε − log n + ε − ) timeusing the algorithm by Cabello et al. [8]. We can improve the time complexity further to O ( ε − log n + ε − log ε − ) using the approximation method by Ahn et al. [3].We use d to denote the diameter of a convex polygon P which is the maximum distance betweenany two points in P , and w to denote the width of P which is the minimum distance betweentwo parallel lines enclosing P . Let c = min { , cot ( α/ , | tan α | } and c = 2 min { − cos αα , απ − α } be the constants defined by α . Lemma 5. area ( T opt ) ≥ c dw .Proof. Let pq be a diameter of P , and let R be a rectangle circumscribed to P with two sidesparallel to pq such that P touches all four sides of R . Let w (cid:48) be the side of R orthogonal to pq .See Figure 3(a).Consider two interior-disjoint triangles with pq as the base and total height w (cid:48) that areinscribed in P . Let (cid:52) pqr be one of the triangles whose height is at least w (cid:48) . Without lossof generality, assume that the bisecting line of pq intersects the boundary of qr at s and let ∠ pqs = γ .If α < γ or α > π − γ , then either (cid:52) qtp (with area ( (cid:52) qtp ) = tan α d ) or (cid:52) tpq (with area ( (cid:52) tpq ) = cot( α/ d ) is an α -triangle, where t is the point on the bisecting line of pq achieving ∠ pqt = α or ∠ qtp = α . See Figure 3(b). If γ ≤ α ≤ π − γ , (cid:52) tqs (with area ( (cid:52) tqs ) ≥ dw ) isan α -triangle inscribed in P , where t is the point on pq achieving ∠ stq = α or ∠ qst = α , whilesatisfying ∠ stq ≤ π − γ . See Figure 3(c). Since w ≤ d , the lemma holds.Let −→ u be one of the directions of the lines defining the width of P . Let ϑ be the angle from −→ u to the ray from p bisecting ∠ rpq for a largest α -triangle (cid:52) pqr inscribed in P in counterclockwisedirection, where − π ≤ ϑ ≤ π . Then we have the following technical lemma. Lemma 6. min { (cid:12)(cid:12) | ϑ | − α (cid:12)(cid:12) , (cid:12)(cid:12) π − α − | ϑ | (cid:12)(cid:12) } ≤ wc c d .Proof. Clearly, T opt is contained in the strip of w . Then area ( (cid:52) pqr ) ≤ w | sin( | ϑ |− ( α/ | · w | sin( | ϑ | +( α/ | = w | cos α − cos | ϑ || . See Figure 4. 6 dp q rp qsrp qs (b)( w (cid:48) ≥ w ) tr γs (a) (c) tRw (cid:48) Figure 3: (a) Proof of Lemma 5. (b) α < γ or α > π − γ . (c) γ ≤ α ≤ π − γ .For θ ∈ [0 , π ] , | cos α − cos 2 θ | ≥ { − cos αα , απ − α }| θ − α | . Observe also that the graph of | cos α − cos 2 θ | is symmetric with respect to θ = π . Therefore, c dw ≤ area ( T opt ) ≤ w | cos α − cos | ϑ || ,and d α min { (cid:12)(cid:12) | ϑ | − α (cid:12)(cid:12) , (cid:12)(cid:12) π − α − | ϑ | (cid:12)(cid:12) } ≤ | cos α − cos | ϑ || ≤ wc d . r qϑαw p w αr qϑp (a) (b) −→ u −→ u Figure 4: area ( T opt ) ≤ area ( (cid:52) pqr ) if (a) α < | ϑ | < π − α , or (b) | ϑ | < α or π − α < | ϑ | .Let T opt ( θ )( − π ≤ θ ≤ π ) denote a largest α -triangle (cid:52) pqr such that the angle from −→ u tothe ray from p bisecting ∠ rpq in counterclockwise direction is θ . Lemma 7.
Given ε > , area ( T opt ( ϑ + δ )) > (1 − ε ) area ( T opt ( ϑ )) for | δ | ≤ min { α , π − α , c w d ε } .Proof. Let (cid:52) pqr be T opt ( ϑ ) . Without loss of generality, assume | pq | ≤ | pr | . Let p (cid:48) and q (cid:48) bepoints on pq and qr , respectively, and let ∠ p (cid:48) rp = ∠ q (cid:48) pq = | δ | . Also, let t be the intersectionpoint of pq (cid:48) and rp (cid:48) . See Figure 5 for an illustration.If | δ | ≤ min { α , π − α } , then area ( T opt ( ϑ )) − area ( T opt ( ϑ + δ )) ≤ area ( (cid:52) pqr ) − area ( (cid:52) tq (cid:48) r ) ≤ area ( (cid:52) rpp (cid:48) ) + area ( (cid:52) pqq (cid:48) ) ≤ (cid:0) sin α sin( α + | δ | ) | pr | + | pq | (cid:1) sin | δ |≤ ( | pq | + | pr | ) sin | δ | ≤ | pq | , | pr | ) sin | δ | . By Lemma 5, − area ( T opt ( ϑ + δ )) area ( T opt ( ϑ )) ≤ | pq | , | pr | ) area ( T opt ( ϑ )) sin | δ | ≤ d c wd sin | δ | ≤ dc w | δ | ≤ ε , and thelemma follows. 7 r qp p (cid:48) q (cid:48) Ptδδ ϑ
Figure 5: area ( (cid:52) pqr ) − area ( (cid:52) tq (cid:48) r ) ≤ area ( (cid:52) rpp (cid:48) )+ area ( (cid:52) pqq (cid:48) ) and area ( T ( ϑ + δ )) ≥ area ( (cid:52) tq (cid:48) r ) in proof of Lemma 7. Lemma 8.
Given a convex polygon P with n vertices in the plane, an angle α , and ε > , wecan find an α -triangle that can be inscribed in P and whose area is at least (1 − ε ) area ( T opt ) in O ( ε − log n ) time.Proof. We sample all orientations θ in − π ≤ θ ≤ π at interval min { α , π − α c w d ε } that satisfy min { (cid:12)(cid:12) | θ | − α (cid:12)(cid:12) , (cid:12)(cid:12) π − α − | θ | (cid:12)(cid:12) } ≤ wc c d .For each sampled orientation θ , L α,θ ( T opt ( θ )) is a largest axis-aligned right triangle in L α,θ ( P ) for the linear transformation L α,θ = (cid:0) α (cid:1) − R (cid:0) α − θ (cid:1) , where R ( φ ) = (cid:0) cos φ − sin φ sin φ cos φ (cid:1) . So,we can compute T opt ( θ ) in O (log n ) time using the same technique used for the axis-aligned α -triangles.We can obtain an orientation θ such that area ( T opt ( θ )) ≥ (1 − ε ) area ( T opt ) for at leastone of the sampled orientations by Lemmas 6 and 7. The running time of the algorithm is O ( ε − log n ) .After applying the inner approximation using an ε - kernel , we can obtain the followingtheorem. Theorem 9.
Given a convex polygon P with n vertices in the plane, an angle α , and ε > , wecan find an α -triangle that can be inscribed in P and whose area is at least (1 − ε ) times the areaof a maximum-area α -triangle inscribed in P in O ( ε − log n + ε − log ε − ) time.Proof. By Lemma 1 in [8], an ε -kernel P ε of P has O ( ε − ) vertices and it can be computed in O ( ε − log n ) time. A largest α -triangle in P ε has area at least (1 − ε ) area ( T opt ) by Lemma 8 in[8]. Then, an (1 − ε ) -approximation to the largest α -triangle in P ε is an (1 − ε ) -approximationof the largest α -triangle in P . We can compute an (1 − ε ) -approximation to the largest α -triangleinscribed in P ε in O ( ε − log ε − ) time by Lemma 8. ( α, β ) -triangles in a Simple Polygon In this section, we show how to find a largest ( α, β ) -triangle that can be inscribed in a simplepolygon P with n vertices in the plane. Without loss of generality, we assume no three verticesof P are collinear.A triangle T inscribed in P may touch some boundary elements (vertices and edges) of P .We call an edge of P that a corner of T touches a corner contact of T , and a vertex of P that aside of T touches in its interior a side contact of T . We call the set of all corner and side contactsof T the contact set of T . We say a triangle T satisfies a contact set C if C is the contact set of T . 8e use η θ ( p ) to denote the ray emanating from p that makes angle θ from the positive x -axisin counterclockwise direction. The inclination of line (or segment) is the angle that the linemakes from the positive x -axis in counterclockwise direction. ( α, β ) -triangles Finding a largest axis-aligned ( α, β ) -triangle is equivalent to finding a largest homothet inscribedin P . For an axis-aligned ( α, β ) -triangle T inscribed in P , we use r ( T ) to denote the left endpointof the base of T , and call it the anchor of T . For an axis-aligned ( α, β ) -triangle T inscribed in P and satisfying a contact set C , we say T is maximal if there is no axis-aligned ( α, β ) -triangleof larger area inscribed in P and satisfying a contact set C (cid:48) with C ⊆ C (cid:48) . For a point r in theinterior of P , consider the largest axis-aligned ( α, β ) -triangle, denoted by T ( r ) , with r at itsanchor. For ease of description, we say C is the contact set of r and r satisfies C , for the contactset C of T ( r ) . We use C ( r ) to denote the contact set of r . We also say r is maximal if T ( r ) ismaximal.To compute a largest axis-aligned ( α, β ) -triangle that can be inscribed in P , we consider allmaximal axis-aligned ( α, β ) -triangles and find a largest triangle among them. To find all maximal ( α, β ) -triangles, we construct a subdivision of P by ( α, β ) such that a maximal ( α, β ) -triangle T has r ( T ) at a vertex of the subdivision. P by angles ( α, β ) (a) (b) A B CE F G
ABC FG AA (cid:48) A (cid:48) BA (cid:48) A E er r (cid:48) D A (cid:48) A (cid:48) D A
Figure 6: (a) Contact sets of type 3. Symmetric cases are omitted. (b) Subdivision of a polygonfor α = π and β = π . Each vertex of the subdivision is labeled by its corresponding contact setin (a). A’ is the symmetric case of A . Point r has a contact set of type 1 and it is in a cell of thesubdivision. Point r (cid:48) has a contact set of type 4 and it is in an edge of the subdivision.For a point r in the interior of P , consider the contact set C of r , which may consist ofpolygon edges that a corner of T ( r ) touches and polygon vertices that a side of T ( r ) touches inits interior. We classify the contact set C of r into four types as follows.1. C consists of exactly one edge of P .2. C consists of one or two reflex vertices of P that the side of T ( r ) opposite to r touches inits interior.3. C belongs to one of the configurations shown in Figure 6(a) or their symmetric configurationswith respect to the anchor of T ( r ) . A superset of C also belongs to this type.9. Other than types 1, 2, and 3.Observe that each interior point r of P has a contact set, which belongs to one of the fourtypes defined above. For a contact set C , consider the set R ( C ) of the points r in the interior of P such that C remains to be the contact set of T ( r ) under translations and scaling. Then theclassification of contact sets above induces a subdivision of P into cells, edges, and vertices. Avertex of the subdivision has degree 1 (endpoint of a subdivision edge on the boundary of P ) orlarger. Lemma 10.
Let S be the subdivision of P by ( α, β ) , and let C be the contact set of a point inthe interior of P . Then R ( C ) is a cell of S if C is of type 1 or 2, a vertex of S if C is of type 3,and an edge of S if C is of type 4.Proof. Observe that R ( C ) is a cell of S if C is of type 1 or 2, a vertex of S if C is of type 3. Acontact set C of type 4 is (1) a proper subset of a configuration in 6(a), (2) the set consists ofa contact set C (cid:48) belongs in (1) and additional side contacts on the side which contains a sidecontact in C (cid:48) , and (3) the set consists of corner contacts on one corner c , except the anchor, andside contacts on both sides incident to c . Since type 1 and 2 contains all the contact set whichcontains exactly one element, C contains at least two elements. Then R ( C ) for C belongs in (1)is line segment. The additional side contacts on the side which contains a side contact does notrestrict R ( C ) . Thus, R ( C ) for C belongs in (2) is also line segment. It is obvious that R ( C ) for C belongs in (3) is line segment. Therefore, R ( C ) is an edge of S if C is of type 4.See Figure 6(b) that illustrates the subdivision of P for α = π and β = π into cells, edgesand vertices. Any point r in a cell has the same contact set of type 1 or 2. (The gray cell has acontact set of type 1.) Any point on an edge of the subdivision has the same contact set of type 4.(The edge labeled with e corresponds to a contact set of type 4.) Each vertex of the subdivisionhas a contact set of type 3 and is labeled by its corresponding contact set in Figure 6(a).Observe that an axis-aligned ( α, β ) -triangle is not maximal if its anchor lies in a cell or edgeof S . Thus, we have the following lemma. Lemma 11.
Every maximal axis-aligned ( α, β ) -triangle has its anchor at a vertex of the subdivi-sion of P . Now we explain how to construct the subdivision S for P . We use a plane sweep algorithmwith a sweep line L which has inclination π − β and moves downwards. The status of L is theset of rays and edges of P intersecting it, which is maintained in a balanced binary search tree T along L . While L moves downwards, the status in T changes when L meets particular points.We call each such particular point an event point of the algorithm. To find and handle theseevent points, we construct a priority queue Q as the event queue which stores the vertices of P in the beginning of algorithm as event points. As L moves downwards from a position above P ,some event points are newly found and inserted to Q and some event points are removed from Q .The invariant we maintain is that at any time during the plane sweep, the subdivision abovethe sweep line L has been computed correctly. Consider the moment at which L reaches a vertex v of P . If v is convex vertex, we add a ray η γ ( v ) to S and update T and Q if it is contained in P locally around v . Since every point in η γ ( v ) near v has the same contact set of type 4 consistingof the two edges, γ is determined uniquely by the two edges. If v is a reflex vertex, we add atmost two rays, η π + α ( v ) and η π ( v ) from v , to S and update T and Q accordingly if the ray iscontained in P locally around v and every point in the ray near v has the same contact set oftype 4. Consider the moment at which L reaches the intersection of a ray with the boundary of P .Then the ray simply stops there. Consider now the moment at which L reaches the intersection10oint x of two rays η and η . Then the two rays stop at x . We add one ray η emanating from x to S and update T and Q accordingly. Observe that the contact set of points on η near x isof type 4 consisting of contact elements of the points in η and η . Thus, the orientation of η is uniquely determined in O (1) time. If η or η emanates from a reflex vertex of P , η makescounterclockwise angle π + α or π from the positive x -axis. Imagine we move a point p from x along η . Then the contact set of p may change at some point q ∈ η to another contact setconsisting of contact elements of the points in η and η . We call such a point q a bend point of η . Again a bend point of a ray can be found in O (1) time. We add q to Q as an event point.Finally, consider the moment at which L reaches a bend point q of a ray η which emanates fromthe intersection of two rays. Then η stops at q . We add a new ray η (cid:48) emanating from q to S and update T and Q accordingly. The orientation of η (cid:48) is uniquely determined by the contactelements of the points in η in O (1) time. Observe that η (cid:48) makes a counterclockwise angle otherthan π + α and π from the positive x -axis.At each of these event points, we update T and Q as follows. At an event point where aray η is added to S , we insert η to T , compute the event points at which η intersects with itsneighboring rays along L and with the boundary of P , and add the event points to Q . At anevent where a ray η stops, we remove it from T and remove the events induced by η from Q . Wealso compute the event at which the two neighboring rays of η along L intersect and add themto Q .After we have treated the last event, we have computed the subdivision of P . Lemma 12.
We can construct the subdivision S of P in O ( n log n ) time using O ( n ) space.Proof. First we show that the number of event points in the plane sweep algorithm is O ( n ) . Apolygon vertex induces at most two rays and generates at most three events at the vertex and twopoints where the rays intersect the boundary of P for the first time. Thus, there are O ( n ) raysinduced by polygon vertices and they generate O ( n ) event points. At an event, either (a) twoneighboring rays merge into one at their intersection point or (b) a ray making counterclockwiseangle π + α or π with the positive x -axis has at most one bend point, and every ray emanatingfrom a bend point makes a counterclockwise angle other than π + α, π from the positive x -axis.An event of case (a) generates O (1) new event points and the number of rays decreases by 1.Thus, the total number of event points of case (a) is O ( n ) . An event point of case (b) generates O (1) new events, but only once for a ray making counterclockwise angle π + α or π with thepositive x -axis. Again, the total number of event points of case (b) is O ( n ) .For each event in the plane sweep algorithm, we stop at most two rays and add at most tworays to S in O (1) time. Then we update T and Q accordingly in O (log n ) time since there are O ( n ) elements in T and O ( n ) events in Q . Thus, we can handle an event in O (log n ) time, andwe can construct S in O ( n log n ) time. The data structures S , T and Q all use O ( n ) space. ( α, β ) -triangle By Lemma 11, it suffices to check all vertices of S to find all maximal axis-aligned ( α, β ) -triangles.For each vertex w of S , the triangle T ( w ) is a maximal axis-aligned ( α, β ) -triangle satisfying C ( w ) by definition. We can compute the area of T ( w ) in O (1) time by storing C ( w ) to w whenit is added into S . Then, we can find a largest axis-aligned ( α, β ) triangle by choosing a largestone among all maximal axis-aligned ( α, β ) -triangles. By Lemmas 11 and 12, we have followingtheorem. Theorem 13.
Given a simple polygon P with n vertices in the plane and two angles α, β , wecan find a maximum-area ( α, β ) -triangle that can be inscribed in P in O ( n log n ) time using O ( n ) space. .2 Largest ( α, β ) -triangles of arbitrary orientations We describe how to find a largest ( α, β ) -triangle of arbitrary orientations that can be inscribedin a simple polygon P with n vertices. We use C θ to denote the coordinate axes obtained byrotating the standard xy -Cartesian coordinate system by θ degree counterclockwise around theorigin. We say a triangle T with base b is θ -aligned if b is parallel to the x -axis in C θ .We use S ( θ ) to denote the subdivision of P in C θ . We construct the subdivision S ( θ ) of P at C using the algorithm in Section 3.1, and maintain it while rotating the standard xy -Cartesiancoordinate axes from angle 0 to π . During the rotation, we maintain the combinatorial structureof S ( θ ) (not the embedded structure S ( θ ) ) and update the combinatorial structure for eachchange so that the changes of S ( θ ) are handled efficiently. We abuse the notation S ( θ ) to referthe combinatorial structure of S ( θ ) if understood in the context. For each vertex of S ( θ ) , westore the function which returns the actual coordinate of the vertex in the embedded structure S ( θ ) . Thus, an edge of S ( θ ) is determined by the functions stored at its two endpoints. For eachedge of S ( θ ) , we store the contact set of the points in the edge.We say a contact set C is feasible at an angle θ if there exists a θ -aligned ( α, β ) -triangleinscribed in P and satisfying C (cid:48) ⊇ C . For a contact set C , consider all angles at which C isfeasible. Then these angles form connected components in [0 , π ) which are disjoint intervals.We call each such interval a feasible interval of C .For a fixed angle θ , consider a θ -aligned ( α, β ) -triangle satisfying a contact set C . Let I = [ θ , θ ] be a feasible interval of C containing θ . For θ ∈ I , we say a θ -aligned ( α, β ) -triangle T satisfying a contact set C ⊇ C is maximal for I if there is no θ (cid:48) ∈ I such that a θ (cid:48) -aligned ( α, β ) -triangle satisfying a contact set C ⊇ C has larger area. (a) u vv (cid:48) u (cid:48) v v (cid:48) (b) v v (cid:48) v v (cid:48) (c) (d) vvwwθ θ θ vvwwe v v Figure 7: Changes of the subdivision S ( θ ) during the rotation with θ at θ , θ , θ with θ < θ < θ .(a) An edge event at which edge uv of S ( θ ) becomes a vertex of S ( θ ) and then it splits into twowith edge u (cid:48) v (cid:48) in between them in S ( θ ) . (b) A vertex event at which an edge of S ( θ ) incident toa reflex vertex v (cid:48) suddenly appears in S ( θ ) and an edge of incident to a reflex vertex v suddenlydisappears from S ( θ ) . (c) An align event at which a subdivision edge e splits into two edgeswith vertex w in between. (d) A boundary event at which w meets the boundary of P in S ( θ ) .12he combinatorial structure of S ( θ ) changes during the rotation. Each change is of one ofthe following types: • Edge event: an edge of S ( θ ) degenerates to a vertex of S ( θ ) . Right after the event, thevertex splits into two with an edge connecting them in S ( θ ) . See Figure 7(a). • Vertex event: an edge of S ( θ ) incident to a reflex vertex v suddenly appears or disappearson S ( θ ) . This event may occur only when an edge e of P incident to v has inclination , α ,or π − β . See Figure 7(b). • Align event: an edge e of S ( θ ) with inclination or α splits into two edges with a vertex w of S ( θ ) in between or two such edges merge into one. This event may occur only for vertex w of S ( θ ) such that the maximal θ -aligned ( α, β ) -triangle T ( w ) = (cid:52) wpq (or its symmetricone) has a reflex vertex of P on q , a reflex vertex of P on its base wp , and an edge on p , or T ( w ) has a vertex of P on p and q , with one of them being reflex. See Figure 7(c). • Boundary event: a vertex of S ( θ ) with degree 2 or larger meets the boundary of P or avertex of S ( θ ) with degree 1 meets a vertex of P on the boundary of P . See Figure 7(d). X X X X X Figure 8: Classification of contact sets of ( α, β ) -triangles with anchor at the vertex at which anedge, align, boundary event occurs.Recall that the set C ( p ) for a point p on an edge of S ( θ ) has at least two elements and C ( v ) for a vertex v of S ( θ ) has at least three elements. We classify all the contact sets of the verticesof S ( θ ) at which an event (except a vertex event) occurs. For a vertex w of S ( θ ) , C ( w ) belongsto one of the following types. See Figure 8 for an illustration. • Type X : C ( w ) contains a corner contact at a corner c and side contacts on both sidesincident to c . • Type X : C ( w ) contains no side contact on a side s and a corner contact on each cornerincident to s . • Type X : C ( w ) contains two side contacts on a side s and a corner contact on a cornerincident to s . • Type X : C ( w ) contains two corner contacts on a corner, i.e. a corner is on a vertex of P ,except the case that it contains a corner contact on each corner. • Type X : C ( w ) contains two side contacts on a side, one side contact on another side, andno corner contact on the corner shared by the sides.Since there are no two vertices of S ( θ ) such that the contact sets of them are same, a vertex wherean event (except a vertex event) occurs has contact set containing more than three elements.Observe that an ( α, β ) -triangle T is not maximal if there is a side s of T such that no contactsare on both s and corners incident to s . Thus, for a vertex w of S ( θ ) at which an event (except a13ertex event) occurs, T ( w ) has no side s such that no contacts on both s and corners incidentto s . Observe that C ( w ) belongs to a type defined above. Thus, the number of events otherthan vertex events is at most the number of maximal ( α, β ) -triangles which have a contact set ofone of the types above. We need the following two technical lemmas to bound the number of ( α, β ) -triangles satisfying types X and X . Lemma 14.
Let F = { f i | ≤ i ≤ n } be a finite family of real value functions such that every f i is of single variable and continuous, any two functions f i and f i (cid:48) intersect in their graphs at mostonce, every function f i has domain D i of size d . If there is a constant c such that | (cid:83) D i | = cd ,then the complexity of the lower envelope of F is O ( n ) .Proof. Let D F = (cid:83) D i . Since there is a constant c , we can construct a finite partition A of D F such that each element of A has size d , except one element of size smaller than or equal to d . Then every D i intersects at most two elements of A . Let l j be the left endpoint of t j ∈ A and assume l j < l j (cid:48) for all j < j (cid:48) . Let L ( l j ) and R ( l j ) be the sets of functions f (cid:48) i which arefunctions f i restricted to D i ∩ [ l j − , l j ] and D i ∩ [ l j , l j +1 ] , respectively. Since any two functions f (cid:48) i , f (cid:48) k ∈ L ( l j ) (or two in R ( l j ) ) intersect in their graphs at most once and their domains havethe same start point or end point, the sequence of the lower envelope of L ( l j ) (or R ( l j ) ) is aDavenport-Schinzel sequence of order 2. Then the lower envelope of set L ( l j ) (and of set R ( l j ) )has complexity O ( k ) , where k = | L ( l j ) | (or k = | R ( l j ) | ). Since | (cid:83) L ( l j ) | = | (cid:83) R ( l j ) | = O ( n ) , thelower envelope of (cid:83) L ( l j ) and (cid:83) R ( l j ) has complexity O ( n ) .Now, consider a new partition of D F obtained by slicing it at every point at which the lowerenvelopes of (cid:83) L ( l j ) and (cid:83) R ( l j ) change combinatorially. Since there are O ( n ) such points andthe lower envelope of F restricted to a component of the new partition has constant complexity,the complexity of the lower envelope of F is O ( n ) . c ue vu v v θ (a) (b) Figure 9: (a) For a fixed angle θ , T ⊆ T or T ⊆ T for any two θ -aligned triangles T and T with u at a corner c and a vertex v and v on the side opposite to c , respectively. (b) An ( α, β ) -triangle T satisfying a contact set C = { u, v, e } of type X contains an ( α, β ) -triangle T (cid:48) which shares a corner c with T lying on e , has a corner at u , and has v on the side opposite to c . Lemma 15.
For a fixed vertex u of P , there are O ( n ) maximal ( α, β ) -triangles T with a cornerat u such that T has a corner on the interior of an edge of P and has a vertex of P on the sideopposite to u .Proof. For a fixed u , consider a maximal ( α, β ) -triangle T with a corner at u such that T has acorner on the interior of an edge e of P and has a vertex v of P on the side opposite to u . Let θ T denote the angle of rotation such that the base of T is parallel to the x -axis of C θ T .To count such triangles, let T v denote all nontrivial ( α, β ) -triangles with a corner at u , withanother vertex of P on the side opposite to u . Observe that for a fixed angle θ , T ⊆ T or14 ⊆ T for any two θ -aligned triangles T , T ∈ T v . Moreover, no θ -aligned triangle of T v , exceptthe smallest one, is inscribed in P . See Figure 9(a). Let F v ( θ ) be the function that returns thearea of the smallest θ -aligned triangle of T v at angle θ . Let T e denote all nontrivial ( α, β ) -triangleswith a corner at u , and another corner on the interior of an edge of P which can be inscribed in P . Observe that for a fixed angle θ , there is at most one θ -aligned triangle in T e as it is requiredto satisfy the constraint to be inscribed in P . Let F e ( θ ) be the function that returns the areaof the θ -aligned triangle of T e at angle θ . Then T occurs at the angle of an intersection of thegraphs of F v and F e .Now we count the intersections of the graphs of F v and F e . For any vertex v of P , the domainof area ( T v ( θ )) has size π − α − β , where T v ( θ ) is the θ -aligned ( α, β ) -triangle with u at a cornerand v on its side opposite to u . For any pair of vertices v, v (cid:48) of P , ( area ( T v ( θ )) , area ( T v ( θ )) have at most one intersection. The union of all domains of area ( T v ( θ )) ’s is [0 , π ) . Thus, byLemma 14, the complexity of F v is O ( n ) .For any two edges e , e of P , the portions of the graph of F e corresponding to area ( T e ( θ )) and area ( T e ( θ )) are disjoint since η π + α ( u ) hits only one edge at an angle θ , where T e ( θ ) denotesthe θ -aligned ( α, β ) -triangle with u at a corner and e on its anchor.For any pair of a vertex v and an edge e of P , the graphs of area ( T v ( θ )) and area ( T e ( θ )) intersect at most twice since the trajectory of point c such that ∠ acv = β forms a circular arc,and a circular arc intersects a line segment at most twice. Thus, the graphs of F v and F e intersect O ( n ) times for a fixed vertex u .In the following lemma, we bound the number of ( α, β ) -triangles satisfying one of the types X i for i = 1 , . . . , . Lemma 16.
There are O ( n ) events that occur to S ( θ ) during the rotation.Proof. Observe that there are O ( n ) align events. Consider an ( α, β ) -triangle T satisfying acontact set C belonging to type X . Then T contains an ( α, β ) -triangle T (cid:48) which shares a corner c with T lying on an edge, has a corner at a vertex u ∈ C , and has a vertex of P on the sideopposite to c . See the gray triangle in Figure 9(b). Thus, we find all such triangles T (cid:48) for everyvertex u . By Lemma 15, there are O ( n ) such triangles for a vertex u of P , and in total O ( n )( α, β ) -triangles satisfying the contact sets of type X .Consider an ( α, β ) -triangle T satisfying a contact set C belonging to type X . Then there isat least one vertex v of P such that the boundary of P contains v . It is obvious that the numberof ( α, β ) -triangles with corner at v and satisfies a contact set of type X . Thus, assume v is sidecontact of T . Let e and e be two edges that C contains and x be the vertex or edge of P whichis contained in C and distinct to v , e , and e . We can consider two θ -aligned ( α, β ) -triangles T ( θ ) and T ( θ ) which satisfies the contact set consists of { v, x, e } and { v, x, e } respectively.Similar to Lemma 15, we consider the number of intersection of the graphs of area ( T ( θ )) and area ( T ( θ )) . Then we can prove that the number of such intersection is O ( n ) . Thus, the numberof ( α, β ) -triangles satisfying a contact set of X is O ( n ) .Observe that there are constant number contact set C of type X if two vertices of P whichlies on a same side is given. And each C has constant number of feasible orientations. Thenumber of contact sets of type X , except the case of contact set contain two side contacts v and v on the side opposite to the corner which is on a vertex u of P , is also O ( n ) because ofthe same reason. The number of contact set of excepted case can be considered in a similar wayto Lemma 15, by considering two triangles T v and T v such that both T v and T v has a cornerat u and v i is on the side opposite to u of T v i . Thus, the number of ( α, β ) -triangles satisfying acontact set of X is O ( n ) . 15n ( α, β ) -triangle T satisfying a contact set of type X contains an ( α, β -triangle T (cid:48) whichhas a corner at v , where v is a side contact of T similar to type X . Since the contact set of T (cid:48) isof type X , the number of contact set of X is O ( n ) .Therefore, the number of events that occurs to S ( θ ) during the rotation is also O ( n ) .To capture the combinatorial changes and maintain S ( θ ) during the rotation, we constructand maintain the following data structures: (1) An event queue Q which is a priority queuethat stores events indexed by their angles. (2) A planar graph representing the combinatorialstructure of S ( θ ) . (3) For each edge e of P , a balanced binary search trees T ( e ) . The tree storedegree-1 vertices of S ( θ ) in order along e .In the initialization, we construct S (0) , and then T ( e ) for each edge of P . Then we initialize Q with the events defined by the vertices of S (0) and the vertex events and boundary eventsdefined by the polygon vertices. For each vertex v of S (0) , we compute the angle at which v and a neighboring vertex of v meet (edge event), an edge incident to v splits into two (alignevent), or v meets a polygon vertex (boundary event). These angles can be computed in O (1) time for each v using the contacts corresponding to v . Then the size of Q is O ( n ) which can beconstructed in O ( n log n ) time.We update each data structure whenever an event occurs. Note that each event changes aconstant number of elements of S ( θ ) , creates a constant number of events to Q , and removes aconstant number of events from Q . Thus we can update the subdivision in O (1) time, and thetree T ( e ) in O (log n ) time for edge e where a boundary event occurs. Lemma 17.
We can construct the subdivision of P and maintain it in O ( n log n ) time using O ( n ) space during rotation.Proof. By Lemma 12, we can construct S (0) in O ( n log n ) time using O ( n ) space. We canconstruct all the data structures for maintaining S ( θ ) in O ( n log n ) time using O ( n ) space. ByLemma 16, there are O ( n ) events during the rotation. Each event, except vertex events, can behandled in O (log n ) time. For each vertex event, we reconstruct S ( θ ) , Q and T ( e ) for each edge e of P . Since there are O ( n ) vertex events and it takes O ( n log n ) time for the reconstruction,it takes O ( n log n ) time to handle all vertex events. The space complexity remains to be O ( n ) since the complexity of the data structures is O ( n ) . ( α, β ) -triangle Whenever a vertex w appears on the subdivision or C ( w ) changes at θ by an event occurringat angle θ , we store θ at w . Whenever C ( w ) changes or w disappears from the subdivision atangle θ , we compute the largest θ -aligned ( α, β ) -triangle satisfying C ( w ) for θ ∈ [ θ , θ ] , where θ is the angle closest from θ at which w appears or C ( w ) changes with θ < θ . We do this onevery vertex w of the subdivision, and then return the largest triangle among the triangles onthe vertices. We can compute the largest one among all θ -aligned ( α, β ) -triangles satisfying C ( w ) for θ ∈ [ θ , θ ] in O (1) time using the area function of the θ -aligned ( α, β ) -triangle satisfying C ( w ) . Thus, from Lemma 17, we have the following theorem. Theorem 18.
Given a simple polygon P with n vertices in the plane and two angles α, β , wecan find a maximum-area ( α, β ) -triangle that can be inscribed in P in O ( n log n ) time using O ( n ) space. α -triangles in a Simple Polygon In this section, we compute a largest α -triangle that can be inscribed in a simple polygon P with n vertices in the plane. Without loss of generality, we assume no three vertices of P are collinear.16 .1 Largest axis-aligned α -triangles We consider a largest axis-aligned α -triangle that can be inscribed in P . We use S ( θ ) to denotethe subdivision of P defined for two angles α and θ . We say a contact set C is feasible at anangle θ if there exists an axis-aligned ( α, θ ) -triangle inscribed in P satisfying C (cid:48) ⊇ C . Fora feasible interval I of a contact set C and θ ∈ I , we say an axis-aligned ( α, θ ) -triangle T satisfying a contact set C ⊇ C is maximal in I if there is no θ (cid:48) ∈ I such that an axis-aligned ( α, θ (cid:48) ) -triangle satisfying a contact set C ⊇ C has larger area. The point at which η θ ( p ) meetsthe boundary of a simple polygon Q ⊆ P for the first time other than its source point is calledthe foot of η θ ( p ) on Q and denoted by δ θ ( Q, p ) . In an α -triangle, we say the side opposite to theanchor is the diagonal of the triangle. For a point p ∈ P , we define the visibility region of p as Vis ( p ) = { x ∈ P | px ⊂ P } . For a ray η and an angle θ , we define the θ -visibility region Vis θ ( η ) of η as the set of points x in the segment yδ θ ( P, y ) contained in P for every y ∈ η .First, we find the largest axis-aligned ( α, π − α ) -triangle T using the algorithm in Section 3.1.Let d be the diameter of P . Since every side of a triangle inscribed in P has length less than orequal to d , any ( α, θ ) -triangle that can be inscribed in P has area less than or equal to d sin α sin θ α + θ ) .Thus it suffices to consider ( α, θ ) -triangles for θ > θ T to find a largest axis-aligned α -triangle,where θ T satisfies d sin α sin θ T α + θ T ) = area ( T ) . To find a largest axis-aligned α -triangle, we choosean angle θ ≤ θ T , construct S ( θ ) and maintain it while increasing θ from θ to π − α . Notethat we can compute T in O ( n log n ) time by Theorem 13 and we can find θ in O (1) time.The combinatorial structure of S ( θ ) changes while increasing θ . We use the definitions for the (a) θ θ θ v v (cid:48) (b) v v (cid:48) v v (cid:48) (c) (d) vwvvvw wvu v vvweu Figure 10: Changes of the subdivision S ( θ ) while increasing θ at θ , θ , θ with θ < θ < θ . (a)An edge event. (b) A vertex event. (c) An align event. (d) A boundary event.combinatorial changes of S ( θ ) in Section 3.2: edge, vertex, align and boundary events. SeeFigure 10. Note that a vertex event occurs at θ = π − γ , where γ is the inclination of an edge of P . We count all α -triangles satisfying a contact set of a vertex at which an event occurs. Figure 11shows a classification of all contact sets of vertices of S ( θ ) at which an event (except vertex events)17 Y Y v v v v Y Y Y Figure 11: Classification of contact sets. Symmetric cases are omitted.occurs. No contact set of types Y or Y contains a diagonal contact, while contact sets of othertypes contain a diagonal contact. We first show that the number of α -triangles satisfying contactssets of types Y and Y is O ( n ) . Then we show that the number of α -triangles satisfying contactsets of other types is also O ( n ) . Lemma 19.
There are O ( n ) axis-aligned α -triangles satisfying a contact set of type Y or Y .Proof. Any contact set of type Y or Y contains vertices of P . For a vertex v of P , there isat most one axis-aligned α -triangle which satisfies a contact set of type Y containing v . Forany two polygon vertices v and v , there is at most one axis-aligned α -triangle which satisfiesa contact set of type Y containing v and v . Thus, there are O ( n ) axis-aligned α -trianglessatisfying a contact set of type Y or Y .To count all axis-aligned α -triangles satisfying a contact set of a type Y i for i = 3 , . . . , , weconsider such triangles whose diagonal contains a reflex vertex of P . For a reflex vertex v of P ,let P (cid:48) ( v ) = (cid:0) Vis ( v ) ∩ Vis α ( η π ( v )) (cid:1) ∪ (cid:0) Vis ( v ) ∩ Vis ( η π + α ( v )) (cid:1) ∪ (cid:0) Vis π + α ( η π ( v )) ∩ Vis π ( η π + α ( v )) (cid:1) .See Figure 12(a). Then, every axis-aligned α -triangle with v on its diagonal is inscribed in P (cid:48) ( v ) .The gray triangles and their contacts in Figure 11 show axis-aligned α -triangles T satisfying acontact set of a type Y i for i = 3 , . . . , with their diagonals containing v and their contact setswith respect to P (cid:48) ( v ) . Lemma 20.
For a reflex vertex v of P , the number of axis-aligned α -triangles satisfying a contactset of type Y i for i = 3 , . . . , and containing v on their diagonals is O ( n ) . is α + π ( η π ( v )) ∩ Vis π ( η π + α ( v )) η π ( v ) η π + α ( v ) Vis ( v ) ∩ Vis ( η π + α ( v )) Vis ( v ) ∩ Vis α ( η π ( v ))(a) (b) vrpp (cid:48) q (cid:48) q θ vD ( v ) T ( v ) δ π + α ( P, v ) δ π ( P, v ) R ( v ) η π + α ( t ) η π − θ ( v ) η π − θ ( v ) e e e t Figure 12: (a) Preprocessing for computing α -triangles satisfying a contact set of type Y i for i = 3 , . . . , . (b) A quadruplet ( v, e , e , e ) that can be a contact set of type Y . Let t = δ π − θ ( P (cid:48) ( v ) , v ) . Proof.
Let T ( v ) , R ( v ) , and D ( v ) be the polygonal chains of P (cid:48) ( v ) from δ π ( P, v ) to v , from v to δ π + α ( P, v ) , and from δ π + α ( P, v ) to δ π ( P, v ) in clockwise, respectively. See Figure 12(b).For a vertex r of T ( v ) , there is at most one axis-aligned α -triangle which satisfies a contactset of type Y , contains v on its diagonal, and contains a corner at r . Thus, there are O ( n ) axis-aligned α -triangles satisfying a contact set of type Y .By the same reason, there are a constant number of α -triangles satisfying a contact set oftype Y for each vertex of T ( v ) , and a constant number of α -triangles satisfying a contact set oftype Y for each vertex of D ( v ) .Now we count the number of quadruplets of elements including v that can form a contact set oftype Y . This quadruplet changes only if η π − θ ( v ) , η π − θ ( v ) , η π + α ( δ π − θ ( P (cid:48) ( v ) , v )) meets anothervertex of P (cid:48) ( v ) . Since η π − θ ( v ) and η π − θ ( v ) rotate clockwise around v , and η π + α ( δ π − θ ( P (cid:48) ( v ) , v )) moves rightwards while increasing θ , each of the rays meets a vertex of P (cid:48) ( v ) at most once.See Figure 12(b). Thus, there are O ( n ) contact sets of type Y containing v as a diagonalcontact. For a contact set C = { v, e , e , e } of type Y containing v as a diagonal contact, wecan find the number of axis-aligned α -triangles satisfying C in a way similar to the proof ontype X of Lemma 16. If there is an axis-aligned ( α, θ T ) -triangle T satisfying C , then there aretwo axis-aligned ( α, θ ) -triangles T (cid:48) ( θ ) and T (cid:48)(cid:48) ( θ ) such that T (cid:48) ( θ ) satisfies { v, e , e } and T (cid:48)(cid:48) ( θ ) satisfies { v, e , e } and area ( T ) = area ( T (cid:48) ( θ T )) = area ( T (cid:48)(cid:48) ( θ T )) . Since each area function consistsof a constant number of trigonometric functions with period π , there are O (1) distinct angles atwhich { v, e , e , e } is feasible.Therefore, the number of axis-aligned α -triangles satisfying a contact set of each type inFigure 11, except types Y and Y , and containing v on their diagonals is O ( n ) for each v .By Lemmas 19 and 20, we can conclude with the following lemma. Lemma 21.
There are O ( n ) events, except vertex events, that occur to S ( θ ) while increasing θ from θ to π − α . .1.2 Maintaining the subdivision while increasing θ To capture the combinatorial changes and maintain S ( θ ) while increasing θ , we maintain thesame data structures defined in Section 3.2.1, but with different equations for computing anglesat which an event occurs. By following the same initialization and update steps in Section 3.2.1,we can construct and maintain subdivision S ( θ ) while increasing θ . By Lemmas 12 and 21, wehave following lemma. Lemma 22.
We can construct the subdivision S ( θ ) of P and maintain it in O ( n log n ) timeusing O ( n ) space while increasing θ from θ to π − α . α -triangles If an event occurs at a vertex w of the subdivision and an angle θ , C ( w ) changes. We find allfeasible intervals of contact sets while maintaining the subdivision. We can compute the maximalaxis-aligned α -triangle satisfying a contact set in O (1) time if a feasible interval is given. Thus,we have the following theorem by Lemma 22. Theorem 23.
Given a simple polygon P with n vertices in the plane and an angle α , we cancompute a maximum-area axis-aligned α -triangle that can be inscribed in P in O ( n log n ) timeusing O ( n ) space. α -triangles of arbitrary orientations To find a largest α -triangle of arbitrary orientations, we follow the approach by Melissaratoset al. [17] in computing a largest triangle with no restrictions in a simple polygon, with somemodification. Their algorithm considers all triangles but we consider α -triangles only. Theydivide the cases by the number of corners of the triangle lying on the boundary of P . Theydenote by m -case the case that m corners of a triangle lie on the boundary of P , for m = 0 , , , .Consider a contact set C consisting of at most three elements. Then any α -triangle satisfying C can be enlarged into another α -triangle while satisfying C . So, the contact set of a largest α -triangle consists of at least four elements. Also, for triangles of the 0-case, their contact setsconsists of five elements and the side opposite to the fixed angle corner contains two side contacts.See Figure 13(i). This can be proved in a way similar to Lemma 6.3 in [17].Figure 13 illustrates the classification of contact sets of the largest α -triangles for each case.For cases (i) and (ii) of Figure 13, we fix two reflex vertices C and D lying on the sameside and find the points G, H where the line containing CD intersects the boundary of P with GH ⊂ P . See Figure 14(a) and (b). Then by walking on the shortest-path maps of G and H along the boundary of P in a way similar to [17], we can compute a largest α -triangle for eachcase using O ( n ) time.For cases (iv), (vii), (x) of Figure 13, we find the largest α -triangle satisfying a contact set C without any restriction on the boundary of P . If the largest α -triangle satisfying C is notinscribed in P , then the maximum area is achieved at the boundary angles of the feasible intervalsof C , which are handled for other cases.A contact set C of the remaining cases contains at most one side contact for each side of the α -triangle satisfying C . For each of these cases, we find a largest α -triangle that can be inscribedin P using the method in [17]. We decompose the problem into O ( n ) simple optimizationproblems and add a constraint such that one interior angle of triangles must be α to eachoptimization problem. Since the original optimization problem can be solved in constant time,our problem can also be solved in O (1) time. 20 v)0-case αα α α α α α (viii) α (vi) αα (x) α (vii) α Figure 13: Classification of the largest α -triangles α (a) α DCx (b)BA DC F zy x A EG H yG HF z
Figure 14: (a) Configuration (i) in Figure 13. (b) Configuration (ii) in Figure 13.
Theorem 24.
Given a simple polygon P with n vertices in the plane and an angle α , we cancompute a maximum-area α -triangle inscribed in P in O ( n ) time using O ( n ) space. References [1] P. K. Agarwal, N. Amenta, and M. Sharir. Largest placement of one convex polygoninside another.
Discrete & Computational Geometry , 19(1):95–104, 1998. doi:10.1007/PL00009337 .[2] Alok Aggarwal, Maria M. Klawe, Shlomo Moran, Peter Shor, and Robert Wilber. Geometricapplications of a matrix-searching algorithm.
Algorithmica , 2(1):195–208, 1987. doi:10.1007/BF01840359 .[3] Hee-Kap Ahn, Otfried Cheong, Chong-Dae Park, Chan-Su Shin, and Antoine Vigneron.Maximizing the overlap of two planar convex sets under rigid motions.
ComputationalGeometry , 37(1):3–15, 2007. 214] Helmut Alt, David Hsu, and Jack Snoeyink. Computing the largest inscribed isotheticrectangle. In
Proceedings of 7th Canadian Conference on Computational Geometry (CCCG1995) , pages 67–72. University of British Columbia, 1995.[5] Helmut Alt, David Hsu, and Jack Snoeyink. Computing the largest inscribed isotheticrectangle. In
Proceedings of 7th Canadian Conference on Computational Geometry , pages67–72, 1995.[6] Nina Amenta. Bounded boxes, Hausdorff distance, and a new proof of an interestingHelly-type theorem. In
Proceedings of 10th Annual Symposium on Computational Geometry(SoCG 1994) , pages 340–347, 1994.[7] Wilhelm Blaschke. Über affine Geometrie III: Eine Minimumeigenschaft der Ellipse.
Ber.Verh. Sächs. Ges. Wiss. Leipzig, Math.-Phys. , 69:3–12, 1917.[8] Sergio Cabello, Otfried Cheong, Christian Knauer, and Lena Schlipf. Finding largestrectangles in convex polygons.
Computational Geometry , 51:67–74, 2016.[9] J. S. Chang and C. K. Yap. A polynomial solution for the potato-peeling problem.
Discrete& Computational Geometry , 1(2):155–182, 1986.[10] Yujin Choi, Seungjun Lee, and Hee-Kap Ahn. Maximum-area rectangles in a simple polygon.In
Proceedings of 39th IARCS Annual Conference on Foundations of Software Technologyand Theoretical Computer Science(FSTTCS 2019) , pages 12:1–12:14, 2019.[11] A DePano, Yan Ke, and J O’Rourke. Finding largest inscribed equilateral triangles andsquares. In
Proc. 25th Allerton Conference on Communication, Control, and Computing ,pages 869–878, 1987.[12] Paul Fischer and Klaus-Uwe Höffgen. Computing a maximum axis-aligned rectangle in aconvex polygon.
Information Processing Letters , 51(4):189–193, 1994.[13] Rudolf Fleischer, Kurt Mehlhorn, Günter Rote, Emo Welzl, and Chee Yap. Simultaneousinner and outer approximation of shapes.
Algorithmica , 8(1):365, 1992. doi:10.1007/BF01758852 .[14] Michael T. Goodrich and Paweł Pszona. Cole’s parametric search technique made practical,2013. arXiv:1306.3000 .[15] Vahideh Keikha, Maarten Löffler, Ali Mohades, Jérôme Urhausen, and Ivor van der Hoog.Maximum-area triangle in a convex polygon, revisited, 2017. arXiv:1705.11035 .[16] David Kirkpatrick and Jack Snoeyink. Tentative prune-and-search for computing fixed-pointswith applications to geometric computation.
Fundamenta Informaticae , 22(4):353–370, 1995.[17] Elefterios A. Melissaratos and Diane L. Souvaine. Shortest paths help solve geometricoptimization problems in planar regions.
SIAM Journal on Computing , 21(4):601–638, 1992.[18] Hall-Holt Olaf, Matthew J. Katz, Piyush Kumar, Joseph S. B. Mitchell, and Arik Sityon.Finding large sticks and potatoes in polygons. In
Proceedings of 17th Annual ACM-SIAMSymposium on Discrete Algorithm (SODA 2016) , pages 474–483, 2006.[19] Micha Sharir and Sivan Toledo. External polygon containment problems.
ComputationalGeometry , 4(2):99 – 118, 1994. doi:https://doi.org/10.1016/0925-7721(94)90011-6 .2220] Csaba D. Toth, Joseph O’Rourke, and Jacob E. Goodman.
Handbook of Discrete andComputational Geometry . Chapman and Hall/CRC, 2017.[21] Jiann-Shing Wu and Jin-Jang Leou. New polygonal approximation schemes for objectshape representation.
Pattern Recognition , 26(4):471 – 484, 1993. doi:https://doi.org/10.1016/0031-3203(93)90103-4doi:https://doi.org/10.1016/0031-3203(93)90103-4