I have a rectangle of width $w$ and height $h$. Inside this rectangle, I want to draw quadrilaterals whose edges all form the same angle magnitude against the edges of the rectangle:

$$|\phi_{top}| = |\phi_{bottom}| = |\phi_{left}| = |\phi_{right}|$$


So, for a given value of $|\phi|$, there are two (+ and -) options at each edge. This produces a family of $4^2 = 16$ possible shapes to draw inside my rectangle.

I'm interested in trying to draw the 16 "largest" quadrilaterals that fit inside the rectangle. "Largest" could mean the maximum span (horizontal + vertical), or something similar (e.g. maximum area).

I have attempted to hand-draw an example set with $|\phi| = 15°$. I color-coded the shapes that looked the same (congruent):


I realize some of those shapes could be translated horizontally. I just drew the shape shifted left as far as possible.

I also realize that for some combinations of $w$, $h$ and $|\phi|$, the quadrilateral could become a triangle. I'm happy to treat those cases as invalid (ignore).

I'm not sure how to find these shapes mathematically. The first thing I tried was to write equations for the 4 edges of the quadrilateral:

$$ y_{tr} = y_{tl} + g_{t} (x_{tr} - x_{tl}) $$

$$ y_{br} = y_{bl} + g_{b} (x_{br} - x_{bl}) $$

$$ x_{bl} = x_{tl} + g_{l} (y_{bl} - y_{tl}) $$

$$ x_{br} = x_{tr} + g_{r} (y_{br} - y_{tr}) $$

where the four corner points are top-left $(x_{tl}, y_{tl})$, top-right $(x_{tr}, y_{tr})$, bottom-left $(x_{bl}, y_{bl})$ and bottom-right $(x_{br}, y_{br})$. I expressed the $\phi$ angles in terms of edge gradients $g_t = tan^{-1}(\phi_{top})$ etc.

So, for each of the 16 combinations of ${g_t, g_b, g_l, g_r}$, I have 4 equations in 8 unknowns. And I know a few constraints:

  • The four $x$ values must be between $0$ and $w$.
  • The four $y$ values must be between $0$ and $h$.
  • $|g_t| = |g_b| = |g_l| = |g_r|$

I think I can arbitrarily place one corner at $(0, 0)$, which would leave me 4 equations in 6 unknowns.

Maybe I could also arbitrarily constrain that $w >= h$. I think this would guarantee that the vertical span is always exactly $h$. But then I'm stuck. Is there some way to incorporate my constraints and reduce the number of unknowns to 4 so I can solve?

  • $\begingroup$ Well, some of the points sit on the sides of the outer rectangle, which provides at least 3 more equations. The rest is your degree of freedom which you can use. Say, in the green rectangle [0000] you can make the long side even longer at the cost of making the short side even shorter. $\endgroup$ Oct 14, 2023 at 13:11
  • $\begingroup$ @IvanNeretin I have been working on the green rectangle [0000] specifically, and I now realize that even in this one simple case, I struggle to derive the solution. I will focus on this one case in isolation, in the hope that it sheds some light on the other cases. $\endgroup$
    – Harry
    Oct 14, 2023 at 13:25
  • $\begingroup$ For the green rectangle, isn't the maximum area given (trivially) by $\phi=0$? $\endgroup$ Oct 15, 2023 at 16:41
  • $\begingroup$ And the same should be true for all the other cases too. Am I wrong? $\endgroup$ Oct 15, 2023 at 16:45
  • $\begingroup$ @Intelligentipauca $\phi$, $w$ and $h$ are given. $\endgroup$
    – Harry
    Oct 15, 2023 at 16:51

1 Answer 1


This StackOverflow solution shows how to maximize area in the case of the green rectangle ("0000"). Expressed in the notation of this question, the main result is:

$$ y_{bl} = \left\{\begin{array}{l}\frac{h}{2}, & \text{if } \frac{h}{w} \leq \sin(2\phi) \\\frac{h}{2}(1+\sec(2\phi)) - \frac{w}{2}\tan(2\phi), & \text{otherwise.} \end{array}\right. $$

I also worked through the magenta parallelogram ("0101") in a similar way, and got an identical result.

Then I realized I don't specifically need to maximize area in my case. I would be happy with a solution that just maximizes span in x and y.

In all cases, it is possible to define shapes that simultaneously span the full width and the full height:

enter image description here

In each case, this constrains exactly 4 of the 8 unknowns. That leaves 4 equations in 4 unknowns (for each of the 5 cases). So, I just had to construct the 5 systems of linear equations to solve.

I have summarized my results below. The constrained coordinates are on the left, and the system of equations is on the right. I have checked them all numerically using a Python script.


enter image description here


enter image description here

Right Trapezoids

enter image description here

Right Irregular Quadrilaterals

enter image description here

Non-Right Irregular Quadrilaterals

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .