Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have three rectangles of different sizes side by side.

I want to scale them all (maintaining their aspect ratio) so they have the same height and don't exceed a total width.

I know I could find the optimal height by trial and error, but I'd like to find a formula that will work no matter what the sizes of the rectangles.

Can anyone point me in the right direction?

share|cite|improve this question

First, scale them all to the same height (tallest, first, some constant).
Second, add the (new) widths and divide the sum by the desired total width.
Third, scale them all by the inverse of this factor.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.