How to determine width and height of outer rectangle when it is scalled to an inner rectangle

by Diego Alves   Last Updated September 13, 2017 14:20 PM

I have a rectangle with more than 800 width and 600 height. It can be 1000 x 600, 2000 x 1000 and etc. I want to scale it to 800 x 600. I want to determine which one matches first, the height or the width and also get the other value that didn't meet first.

|                |
|  |800x600   |  |
|  |inners rec|  |
|                |outer rectangle(1000 x 1000) if I resize which one will hit the boundaries of the inner rectangle left and right or top and bottom.

Answers 1

Take the ratio in each axis and use the smaller one. So if you start with $2000 \times 1000$ the horizontal is $\frac {800}{2000}=0.4$, the vertial is $\frac {600}{1000}=0.6$. So you scale by a factor $0.4$ and the vertical is $0.4 \cdot 1000=400$. These are rectangles, not squares.

Ross Millikan
Ross Millikan
September 13, 2017 14:06 PM

Related Questions

Graphing on the complex plane

Updated March 28, 2018 06:20 AM