This sounds like you need a remap function (I’ve answered this in JavaScript before).
def remap(
value,
source_min,
source_max,
dest_min=0,
dest_max=1,
):
return dest_min + (
(value - source_min)
/ (source_max - source_min)
) * (dest_max - dest_min)
Now, for instance to map the value 250 from between 0 to 500 to the range 0 to 1,
>>> remap(250, 0, 500, 0, 1)
0.5
I hope I’ve understood your question correctly.
2
solved PYTHON : Convert between 0-> 500 and x -> y