Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question

1 Answer 1

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|improve this answer

Your Answer

 
discard

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.