returns the value in the new range val - input value min_val, max_val - minimum and maximum values at the input in map min_new, max_new - minimum and maximum values in the output of the map
the function limits the val range to min_new and max_new in case the input parameters min and max leave the range