 3
 0
I'm hoping for some help as it has been 20 years since I last used trigonometry and Google has come up empty. I'm programming simple image editing software and for a crop function I need a formula to calculate the sides of the largest possible rectangle inside a rotated rectangle, given the coordinates of the center of the inner rectangle and aspect ratio of the sides. Largest is defined as the largest rectangle that touches but not exceeds any edge of the outer rectangle.
I know the length of the sides of the enclosing rectangle, L and W as well as angle of rotation, theta.
I also know the center coordinate of the inner rectangle (Px,Py) relative to the center of the enclosing rectangle as well as aspect ratio of the sides, p and q. Ie. p = r * q
I need this because the user is to freely rotate and drag the image (larger rectangle) and the crop window(smaller rectangle) must autoadjust because the crop window of course cannot fall outside the image. Any help would be greatly appreciated.
Thanks,
Mark
I know the length of the sides of the enclosing rectangle, L and W as well as angle of rotation, theta.
I also know the center coordinate of the inner rectangle (Px,Py) relative to the center of the enclosing rectangle as well as aspect ratio of the sides, p and q. Ie. p = r * q
I need this because the user is to freely rotate and drag the image (larger rectangle) and the crop window(smaller rectangle) must autoadjust because the crop window of course cannot fall outside the image. Any help would be greatly appreciated.
Thanks,
Mark
Attachments

7.3 KB Views: 518