Reputation: 6276
I have found many answered questions explaining how to calculate the bounding box of a rotated rectangle, however what I need to do is almost the reverse.
The red rectangle A
is described as:
var box = {
x : 0,
y : 0,
w : 100,
h : 200
};
And the dimensions of the blue rectangle B
are exactly the same when it is not rotated.
Given that rectangle B
is rotated around its center point and that it's angle is provided in radians, how can I calculate the minimum size rectangle B
can be when rectangle A
must always fit inside it while maintaining its original aspect ratio (as previously mentioned, the same as rectangle A
)
Upvotes: 2
Views: 739
Reputation: 25013
If you label the sides of the rectangles and draw in an extra line (green in the diagram), you can see what you need to calculate:
So c = a * cos(θ) + b * sin(θ)
and d=b*c/a
Upvotes: 2