Scaling ranges

for example i have two ranges

                       (1) 0 to 3
                       (2) 10 to 15

in the range (1) I have numbers from 0 to 3, where 0 is the minimum, and 3 is the maximum value ... (it also has the values ​​1 and 2) ...

now I wanted to rescale both ranges (1) and (2) to a range from 0 to 1. Can you show me how to do this or at least point to useful sites? thanks a lot!

+3
source share
1 answer

What you describe is called linear interpolation .

, c a b, x 0 1, c a b. x :

x := (c - a) / (b - a)

, 10 15 (, 11), 0 1, :

x := (11 - 10) / (15 - 10)
x := 1/5

, 11 10 15.


( c a b x y z), x

x := (c - a) * (z - y) / (b - a) + y

z = 1 y = 0.

+18

Source: https://habr.com/ru/post/1718211/


All Articles