Largest Fixed-Aspect, Axis-Aligned Rectangle



Similar documents
3.1 Solving Systems Using Tables and Graphs

1.3. DOT PRODUCT If θ is the angle (between 0 and π) between two non-zero vectors u and v,

4. How many integers between 2004 and 4002 are perfect squares?

What is Linear Programming?

Linear Programming I

13.4 THE CROSS PRODUCT

Math 181 Handout 16. Rich Schwartz. March 9, 2010

Solving Geometric Problems with the Rotating Calipers *

Copyright 2011 Casa Software Ltd. Centre of Mass

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

Common Core Unit Summary Grades 6 to 8

. P. 4.3 Basic feasible solutions and vertices of polyhedra. x 1. x 2

Intersection of Convex Objects: The Method of Separating Axes

The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION GEOMETRY. Wednesday, January 28, :15 a.m. to 12:15 p.m.

Reflection and Refraction

Section 9.1 Vectors in Two Dimensions

Solving Simultaneous Equations and Matrices

Math 215 HW #6 Solutions

Solutions to Practice Problems

MAT 1341: REVIEW II SANGHOON BAEK

Arrangements And Duality

Triangulation by Ear Clipping

Algebra Geometry Glossary. 90 angle

Intersection of a Line and a Convex. Hull of Points Cloud

The Graphical Method: An Example

LINEAR INEQUALITIES. less than, < 2x + 5 x 3 less than or equal to, greater than, > 3x 2 x 6 greater than or equal to,

56 questions (multiple choice, check all that apply, and fill in the blank) The exam is worth 224 points.

Shortest Path Algorithms

Least-Squares Intersection of Lines

Computational Geometry. Lecture 1: Introduction and Convex Hulls

of surface, , , of triangle, 548 Associative Property of addition, 12, 331 of multiplication, 18, 433

Solutions to Homework 10

Problem set on Cross Product

1 VECTOR SPACES AND SUBSPACES

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Math 0980 Chapter Objectives. Chapter 1: Introduction to Algebra: The Integers.

Trigonometric Functions and Triangles

Geometry and Measurement

2006 Geometry Form A Page 1

Solutions to old Exam 1 problems

Line and Polygon Clipping. Foley & Van Dam, Chapter 3

Solutions to Math 51 First Exam January 29, 2015

Linear Programming. March 14, 2014

GEOMETRY CONCEPT MAP. Suggested Sequence:

Computer Graphics. Geometric Modeling. Page 1. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science - Technion. An Example.

n 2 + 4n + 3. The answer in decimal form (for the Blitz): 0, 75. Solution. (n + 1)(n + 3) = n lim m 2 1

SAT Subject Math Level 2 Facts & Formulas

Angle - a figure formed by two rays or two line segments with a common endpoint called the vertex of the angle; angles are measured in degrees

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

SAT Subject Math Level 1 Facts & Formulas

LINEAR INEQUALITIES. Mathematics is the art of saying many things in many different ways. MAXWELL

Questions. Strategies August/September Number Theory. What is meant by a number being evenly divisible by another number?

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION GEOMETRY. Student Name:

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Practical Guide to the Simplex Method of Linear Programming

Selected practice exam solutions (part 5, item 2) (MAT 360)

Mathematics. Mathematical Practices

Special Situations in the Simplex Algorithm

D.2. The Cartesian Plane. The Cartesian Plane The Distance and Midpoint Formulas Equations of Circles. D10 APPENDIX D Precalculus Review

Linear Programming. Solving LP Models Using MS Excel, 18

Assessment Anchors and Eligible Content

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS

37 Basic Geometric Shapes and Figures

Double Integrals in Polar Coordinates

CSU Fresno Problem Solving Session. Geometry, 17 March 2012

GEOMETRY. Constructions OBJECTIVE #: G.CO.12

Math. MCC6.RP.1 Understand the concept of a ratio and use

Linear Programming Problems

EdExcel Decision Mathematics 1

Chapter 3: Section 3-3 Solutions of Linear Programming Problems

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

MA107 Precalculus Algebra Exam 2 Review Solutions

Section 1.1. Introduction to R n

EQUATIONS and INEQUALITIES

1. Prove that the empty set is a subset of every set.

Triangle Trigonometry and Circles

Linear Programming. Widget Factory Example. Linear Programming: Standard Form. Widget Factory Example: Continued.

Geometric Transformations

Area and Arc Length in Polar Coordinates

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Section 4.4 Inner Product Spaces

Unified Lecture # 4 Vectors

2.1 Increasing, Decreasing, and Piecewise Functions; Applications

(Basic definitions and properties; Separation theorems; Characterizations) 1.1 Definition, examples, inner description, algebraic properties

CAMI Education linked to CAPS: Mathematics

AP Physics - Vector Algrebra Tutorial

Absolute Value Equations and Inequalities

Teacher Page. 1. Reflect a figure with vertices across the x-axis. Find the coordinates of the new image.

Math 241, Exam 1 Information.

LINES AND PLANES IN R 3

Math Placement Test Practice Problems

What are the place values to the left of the decimal point and their associated powers of ten?

Optimal shift scheduling with a global service level constraint

Shape Dictionary YR to Y6

1. Graphing Linear Inequalities

The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION GEOMETRY. Thursday, January 26, :15 a.m. to 12:15 p.m.

Factoring Patterns in the Gaussian Plane

4.5 Linear Dependence and Linear Independence

Transcription:

Largest Fixed-Aspect, Axis-Aligned Rectangle David Eberly Geometric Tools, LLC http://www.geometrictools.com/ Copyright c 1998-2016. All Rights Reserved. Created: February 21, 2004 Last Modified: February 12, 2008 Contents 1 Formulation as a Linear Programming Problem 2 2 Reduction of Constraints 2 3 Existence of Infinitely Many Solutions 3 4 Geometric Interpretation of the Constraints 3 5 An Algorithm to Construct the Inscribed Rectangle 4 1

1 Formulation as a Linear Programming Problem Let V i = (x i, y i ) for 0 i 3 be the vertices of a convex quadrilateral. The vertices are assumed to be ordered in the counterclockwise direction. For the purposes of indexing, let V 4 = V 0. The edges of the quadrilateral have directions E i = V i+1 V i for 0 i 3. Inner pointing normal vectors are N i = E i / E i where (x, y) = ( y, x). An axis-aligned rectangle is specified by its lower left corner R 0 = (u, v), a width w, and a height h. The vertices in counterclockwise order are R 0 = (u, v), R 1 = (u + w, v), R 2 = (u + w, v + h), and R 3 = (u, v + h). A rectangle has a fixed aspect ratio if w/h = r for a specified aspect ratio r > 0. The problem is to select P = (u, v, w) so that the corresponding axis-aligned rectangle with aspect ratio r is the largest such rectangle contained in the quadrilateral. The vertices of the rectangle must all lie in the quadrilateral, so N i (R j V i ) 0 for all i and j, a total of 16 inequality constraints. The area of a rectangle is A(w) = w 2 /r. We wish to maximize A(w) subject to w 0 and the previous 16 constraints. Notice that maximizing A(w) for w 0 is equivalent to maximizing f(w) = w itself. Thus, we have the linear programming problem: Maximize f(w) = w subject to the constraints w 0 and C ij (u, v, w) = N i (R j V i ) 0 for 0 i 3 and 0 j 3. If a linear programming solver requires u 0 and v 0, the quadrilateral may be translated into the first quadrant to satisfy these conditions. 2 Reduction of Constraints The 16 inequality constraints have a lot of redundancy. For example, if N i = (a i, b i ) with a i > 0 and b i > 0, then N i (R 0 V i ) 0 automatically implies N i (R j V 0 ) 0 for 1 j 3. The implication is clearly shown by Figure 1. Figure 1. Reduction of the four constraints N i (R j V i ) 0 for 0 j 3 to the single constraint N i (R 0 V i ) 0. Note that the normal vector N i is in quadrant 1 of the plane. If N i is in quadrant 2, then a i < 0 and b i > 0. The constraint N i (R 1 V i ) 0 implies N i (R j V i ) 0 for j {0, 2, 3}. Similar reductions apply when N i is in quadrant 3 or in quadrant 4. 2

The normal vector N i = (1, 0) is on the boundary between quadrants 1 and 4. The four constraints associated with N i still reduce to a single constraint involving R 0. Similar observations apply to normals (0, 1), ( 1, 0), and (0, 1). Therefore, the linear programming problem does not need all 16 inequality constraints. It suffices to determine the quadrant that contains N i and use the associated, single, inequality constraint. If θ i [0, 2π) is the angle formed by N i and the positive x-axis, then the associated constraint is N i (R 2θi/π V i ) 0 where z denotes the floor of z, the largest integer smaller or equal to z. The index of R is 0 if θ i [0, π/2), is 1 if θ i [π/2, π), is 2 if θ i [π, 3π/2), or 3 if θ i [3π/2, 2π). The linear programming problem to maximize f(w) = w now has only 5 constraints. One of them is w 0. The other 4 are N i (R 2θi/π V i ) 0 for 0 i 3. 3 Existence of Infinitely Many Solutions The fact that multiple solutions exist is shown by the following example. Suppose the quadrilateral is the axis-aligned rectangle: V 0 = (0, 0), V 1 = (1, 0), V 2 = (1, 1/2), and V 3 = (0, 1/2). Let the aspect ratio be r = 4/3. The limiting factor for the maximum area axis-aligned rectangle with aspect ratio 4/3 is the height of the quadrilateral. The height of h = 1/2 for the inscribed rectangle leads to w = rh = 2/3. Many inscribed rectangles of these dimensions exist. The centers are (c, 1/4) for 1/3 c 2/3. The lower left corners are (u, 0) for 0 u 1/3. 4 Geometric Interpretation of the Constraints The last example may be analyzed by considering its convex polyhedral domain defined by the constraints. This domain is in (u, v, w) space. The maximum of f(w) = w must occur at a vertex of the domain. We need only find a vertex of largest w. As the last example shows, there can be infinitely many points at which w is largest, in which case at least two vertices attain largest w, which in turn implies the convex hull of all such vertices attains largest w. The normal vectors to the quadrilateral edges are N 0 = (0, 1), N 1 = ( 1, 0), N 2 = (0, 1), and N 3 = (1, 0). The corresponding constraints are w 0 and 0 N 0 (R 1 V 0 ) = v 0 N 1 (R 2 V 1 ) = (u + w 1) 0 N 2 (R 3 V 2 ) = (v + 3w/4 1/2) 0 N 3 (R 0 V 3 ) = u or w 0, u 0, v 0, u + w 1, and 4v + 3w 2. Figure 2 shows the convex polyhedral domain. 3

Figure 2. The convex polyhedral domain defined by w 0, u 0, v 0, u + w 1, and 4v + 3w 2. The 6 vertices are shown as black dots. The points of maximum w are (u, 0, 2/3) for 0 u 1/3. The base of the polyhedron is the original quadrilateral and occurs when w = 0. This is generally the case since the rectangle corner (u, v) is always a point in the quadrilateral. The polyhedron has four other faces, each face defined by a constraint associated with a quadrilateral edge. Generally, the convex polyhedral domain is pyramidal with 5 faces, the base being the original quadrilateral. The other 4 faces must slant inwards to form the pyramid. The geometric shape of the pyramid implies that is has either a single vertex attaining maximal w (a unique inscribed axis-aligned rectangle with specified aspect ratio) or a line segment attaining maximal w (infinitely many inscribed axis-aligned rectangles with specified aspect ratio). This observation allows us to construct the inscribed rectangle in a simple manner that does not require use of a general linear programming solver. 5 An Algorithm to Construct the Inscribed Rectangle The geometry of the convex polyhedral domain indicates the following construction. If the pyramid has a single vertex attaining maximal w, that vertex is the common point of four faces and can be found by solving either (1) three linear equations in three unknowns or (2) four linear equations in three unknowns, the system necessarily having rank 3. If the pyramid has a line segment attaining maximal w, the segment lies on the line of intersection of two planes corresponding to the equality constraints for two opposite edges of the quadrilateral. All cases can be handled by computing the line of intersection of the planes represented by two linear equations, then clipping that line against the planes for two other linear equations. Specifically, the four inequality constraints defining the faces of the pyramid (not the base) are of the form M i P + d i 0 for 0 i 3. The line of intersection of constraints i = 0 and i = 2 is P(t) = t(m 0 M 2 ) + K 0 for some point K 0 on the line and for all real t. The clipping is achieved by substituting this line equation into the other constraints, 0 M 1 P(t) + d 1 = t(m 1 M 0 M 2 ) + (M 1 K 0 + d 1 ) = α 1 t + β 1 0 M 3 P(t) + d 3 = t(m 3 M 0 M 2 ) + (M 3 K 0 + d 3 ) = α 3 t + β 3 The geometry of the convex polyhedral domain implies that neither α 1 nor α 3 is zero. The inequality α 1 t + β 1 0 defines a semiinfinite t-interval I 1 which is [ β 1 /α 1, + ) if α 1 > 0 or (, β 1 /α 1 ] if α 1 < 0. 4

A semiinfinite interval is similary defined by α 3 t + β 3 0, call it I 3. The intersection I = I 1 I 3 is either empty, a singleton, or a interval of positive and finite length. The geometry of the polyhedral domain rules out I being a semiinfinite interval. I is a single point when β 1 /α 1 = β 3 /α 3, in which case t = β 1 /α 1 and P(t) = (u(t), v(t), w(t)) provides the inscribed rectangle. If I is an interval of positive and finite length, call it I = [t 0, t 1 ], then choose t = t 0 or t = t 1, whichever one produces the largest w(t) value. Once again, P(t) = (u(t), v(t), w(t)) provides the inscribed rectangle. If I is empty, then compute the line of intersection of constraints i = 1 and i = 3, and repeat the above construction. This time, the t-interval is named I and cannot be empty, and the appropriate value of t is constructed to lead to maximum w(t). 5