Mapping values
Map values from one range to another.
Function definition
function mapRange(value, oldMin, oldMax, newMin, newMax) {
return ((value - oldMin) * (newMax - newMin) / (oldMax - oldMin)) + newMin;
}
Example
var out_x = mapRange(in_x, 279, 922, -1.72, 1.72);
var out_y = mapRange(in_y, 315, 771, 4.61, 2.16);
Need more help with this?
Don’t hesitate to contact us here.