Fit rotated object to a window

I re-asked the question in a new post since I think a new approach is required