How to make a range thats not 0-1 0-1
How do I take a range thats from 0-.7 or so and make it 0-1 so that .7 is now 1 and 0 of course is still 0? Thanks
To adjust a value from the original range (min0 to max0) to the new range (min1 to max1), use this function:
If min0 = 0, max0 = 0.7, min1 = 0 and max1 = 1, then the function would simplify to:
Just as uavfun said.
f(v) = ((v - min0) / (max0 - min0)) * (max1 - min1) + min1
If min0 = 0, max0 = 0.7, min1 = 0 and max1 = 1, then the function would simplify to:
f(v) = ((v - 0) / (0.7 - 0)) * 1 + 0 = v / 0.7
Just as uavfun said.
Basically what you have to do is scale the value so that it's in the given range. Here's a visual:
Agony already posted the formula, I just thought I'd explain it a little more.
|----|----|0 .4 .7|----|----|0 .5 1
Agony already posted the formula, I just thought I'd explain it a little more.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement