MapNumRange
Maps a number from one range to another range.
- Returns
num
mapped between oMin
-oMax
from iMin
-iMax
.
func MapNumRange(num, iMin, iMax, oMin, oMax float64) float64 {
return ((num-iMin)*(oMax-oMin))/(iMax-iMin) + oMin
}
MapNumRange(5.0, 0.0, 10.0, 0.0, 100.0) // 50.0