Hey everyone, I have a math question that's been bugging me.

Basically what I'm trying to do is this (view images attached):

I have an outer rectangle of WxH dimensions.

I have some arbitrary rectangle which is some MxN dimension and rotated at an angle from 0-360 degrees.

I need to find the best-fitting rectangle which can fit inside of this rotated rectangle, but is basically a shrunken version of the WxH rectangle (the inner white rectangle). How would I go about finding that mathematically?

As far as what I've tried, I've tried a lot of random mathematical calculations but nothing really works in all cases (when there is a tall rectangle as opposed to a wide one, etc).