Width:

Height:

Height = hypotenuse * height_aspect_ratio / square_root(width_aspect_ratio^2 + height_aspect_ratio^2)

Width is the same except instead of dividing height_aspect_ratio, you divide width_aspect_ratio instead.

This was found using the law of sines initially and then it struck me that pythagoreans theorem would work just as well. However, law of sines works for angles that aren't Pi/2 or 90 degrees. For the sake of ye olde JS