Good problem! My answer: I don't know
BUT I'm pretty sure B needs to end up as a square (a square is a rectangle).
Apologies if I'm poor at describing this problem.
I have a rectangle, A, of known size, that starts aligned to the x/y axes, and can rotate around its centre point.
For any given angle of rotation, I need to determine the maximum dimensions of a second rectangle, B, that:
- is inscribed inside A
- maintains the same proportions as A
- maintains alignment to the x/y axes
So, here A (the black rectangle) has been rotated through 30 degrees (the red rectangle). How do I determine the maximum size of B (the blue rectangle)?
Many thanks for any help.
The vertices of the blue rectangle will lie on the diagonals of the black rectangle (green lines on the attachment). So all you have to do is to see where the green lines intersect the red lines, choose the two such intersections that are closer to the centre of the rectangle, and take those to be opposite vertices of the blue rectangle.
If the black rectangle has sides on the lines and , where a>b, and the red rectangle is obtained by rotating it through an angle θ (between 0 and π/2), then I think that the vertices of the blue rectangle will be at (but I haven't checked that calculation carefully).
the above formula was used in an ImageMagick discussion forum to develop a video rotation sequence.
the coordinates was used to define a 'scaling factor' enlarging an rotated image so that it completely defines the images original bounds.
ImageMagick • View topic - optimizing 'convert' speed