[Math] New size of a rotated-then-cropped rectangle

geometrytrigonometry

Imagine a rectangle (x1 by y1) always has to be drawn with horizontal and vertical lines (so it can't have lines at 45 degrees). If the rectangle is rotated by angle θ, it needs to have a rectangle drawn inside it so that this new rectangle still follows the rules. In the diagram, the black rectangle is the original, the red one is the rotated rectangle, and the green ones are three possible options (the two extremes, and one which maintains the aspect ratio).

Rotated rectangles diagram

How can I work out (in terms of x1, y1 and θ):

  1. the dimensions (x2 and y2) of the rectangle which maintains the aspect ratio of the original?
  2. the dimensions (x2 and y2) of the rectangle which has the largest possible area within the given boundaries?
  3. x2 for a given y2 (and vice-versa) within a valid range?

Answers to only one part are quite welcome. I've tried to work this out myself by looking at what I know about the resulting triangles, and can't seem to get anywhere (it's been a while since I studied Maths), so an answer to one of these might point me in the right direction.

Best Answer

Let's say that the origin of a coordinate system is at the center of the original black rectangle. This is the center of the rotation and also the center of each of the green rectangles. Consider only the first quadrant (from the origin up and to the right). Exactly 1/4 of the black rectangle and each green rectangle is in the first quadrant. Let's further assume that, as in your picture, the angle of rotation is relatively small (say, less than 45°) and in the clockwise direction, and that $y_1<x_1$.

Let the vertex of the black rectangle that is in the first quadrant be $(a,b)=(\frac{1}{2}x_1,\frac{1}{2}y_1)$. Call the magnitude of the angle of rotation $\alpha$ ($0°<\alpha<45°$). The coordinates of the vertex of the red rectangle in the first quadrant are $(a\cos\alpha+b\sin\alpha,-a\sin\alpha+b\cos\alpha)$. The slope of the upper side of the red rectangle is $-\tan\alpha$. An equation for the upper side of the red rectangle in the first quadrant is $y-(-a\sin\alpha+b\cos\alpha)=-\tan\alpha(x-(a\cos\alpha+b\sin\alpha))$ for $0\le x\le a\cos\alpha+b\sin\alpha$. An equivalent simplified equation is $y=\sec\alpha(b-x\sin\alpha)$. This red upper side intersects the original black upper side at $x=b\cot\alpha(\sec\alpha-1)$.

So:

  • for $b\cot\alpha(\sec\alpha-1)\le x\le a$, the vertex of the green rectangle in the first quadrant will be on the red side, at $(x,\sec\alpha(b-x\sin\alpha))$, and it will have area $4x\sec\alpha(b-x\sin\alpha)$.
  • for $0\le x<b\cot\alpha(\sec\alpha-1)$, the vertex of the green rectangle in the first quadrant will be on the black side (here, I'm assuming from your picture that the green rectangle must be contained entirely within the black rectangle), at $(x,b)$, and it will have area $4xb$.
  • assuming that the green rectangle must be contained entirely within the black rectangle, $x$ cannot be greater than $a$.

Assuming the first case:

  • the maximum area is $b^2\csc\alpha\sec\alpha$ when $x=\frac{1}{2}b\csc\alpha$.
  • the green rectangle will have the same aspect ratio as the black rectangle when $x=\frac{ab}{b\cos\alpha+a\sin\alpha}$ (and the area is $\frac{4ab^3}{(b\cos\alpha+a\sin\alpha)^2}$).

edit: I originally forgot the factors of 4 on the area, moving from my picture of just one-fourth of things back to the whole rectangles. Similarly, note that my $x$- and $y$-values are half of your $x_2$ and $y_2$, respectively. The maximum possible area for the second case (where the vertex is at $(x,b)$) is $4b^2\cot\alpha(\sec\alpha-1)$, which Mathematica seems to be telling me cannot be greater than the maximum area for the first case under my assumptions about the problem.

Related Question