[Solved] How to make number ranging from 5 to -5 instead range from 5 to 10? [closed]


From [-5, 5] to [5, 10]: output = (input + 7.5) * 0.5

From [5, 10] to [-5, 5]: output = (input – 7.5 ) * 2

From [5, 10] to [5, -5]: output = (input – 7.5 ) * -2

The idea is to first shift the average of input’s range to average of output’s range by adding.
Then, scale the input’s range to the output’s range by multiplying.

Take From [5, 10] to [-5, 5] as an example. The average of input’s range is (5 + 10)/2 = 7.5, the average of output’s range is (-5 + 5)/2 = 0. Since the difference is 7.5, you need to add -7.5, which is same as – 7.5. Then the range for the input is 10 – 5 = 5, the range for the output is 5 – (-5) = 10. So you need to scale it by multiplying by 2.

1

solved How to make number ranging from 5 to -5 instead range from 5 to 10? [closed]