map a number from one range to another
/**
* map a number from one range to another
* @param {num} value the value to be mapped
* @param {num} old_min the minimum of value
* @param {num} old_max the maximum of value
* @param {num} new_min the new minimum value
* @param {num} new_max the new maximum value
* @return {num} the value remaped on the range [new_min new_max]
*/
public double map(double value, double old_min, double old_max, double new_min, double new_max) {
return (value - old_min) / (old_max - old_min) * (new_max - new_min) + new_min;
}
/**
* map a number from one range to another
* @param {num} value the value to be mapped
* @param {num} old_min the minimum of value
* @param {num} old_max the maximum of value
* @param {num} new_min the new minimum value
* @param {num} new_max the new maximum value
* @return {num} the value remaped on the range [new_min new_max]
*/
function map(value, old_min, old_max, new_min, new_max) {
return (value - old_min) / (old_max - old_min) * (new_max - new_min) + new_min;
}