How to calculate progression ratio of a set of numbers?

724 Views Asked by At

English is not my native language, so I will try to explain my problem. I am doing web design and I am trying to use math to calculate the width of an element within different screen resolutions. I found out that on resolution 1200, the element should have a width of 150. On resolution 991, the element should have a width of 78. So the two sets are (991,1200) and (78,150).

991 -> 78
1200 -> 150

In CSS there is a unit (vw) which is equal to the current resolution. So for example if the user is on 1100 resolution, 100vw is equal to 1100. I will be using this unit to automate calculation for different resolutions and it will be incredibly useful if there is a formula for calculating the ratio between the two sets of numbers. My question is how to find the ratio on any current resolution? Also, is this called geometric progression?

1

There are 1 best solutions below

5
On BEST ANSWER

If I understand your question correctly, you're looking for an arithmetic progression (not geometric).

The formula is: $78+(R-991)\frac{72}{209}$ where $R$ is the screen resolution.

Method:

For two "sets" (as you call them) $(a,b)$ and $(c,d)$, you can easily find the formula like this:

$$b+(R-a)\frac{d-b}{c-a}.$$