Quote:

I need to enclose any given rectangle with another rectangle.

The enclosing rectangle must be of a specific ratio - e.g. width is twice its height, for example.

In actual fact, the ratio I need for the enclosing rectagle is that the width is 1.62344 times the height.

So given any rectange $\displaystyle R$ with height $\displaystyle h$ and width $\displaystyle w$,

I need to find rectangle $\displaystyle R_2$ with height $\displaystyle h_2$ and width $\displaystyle w_2$

such that $\displaystyle R$ sits inside $\displaystyle R_2$, and $\displaystyle R_2$ is just big enough to enclose $\displaystyle R$

. . but no bigger than it needs to be.