I've asked a programming question on StackOverflow here which should give you a good understanding why I'm trying to do this. I'm asking it here because it's now down entirely to the mathematics of the calculation.
I've got two rectangles: a "crop" rect and an "image" rect that are on top of each other. I've designed it so that either both widths or both heights of each will start out the same (e.g. if they are landscape rectangles, regardless of width, the height of both will be the same).
When rotating the image rect, the crop rect stays the same size, but I need to mathematically calculate how much to enlarge the image rect so that it always completely fills the crop rect. (The .gif in my linked question illustrates this rather well).
- The size and coordinates of each rect before rotation
- The size of the bounding rect that the rotated image rect fits into
- The angle of rotation in radians
How, based on the degree of rotation (radians), and the size of each rectangle, can I calculate the difference in scale required to enlarge the image rect to fit entirely inside the crop rect when rotating it?