def mapVal(inputPos, in_min, in_max, out_min, out_max):
    """ This function will linearly scale an incoming value 
        belonging to a certain range (in_max - in_min) to a new 
        value in the out range (out_max - out_min). """
    
 
    scale = ((out_max - out_min) / (in_max - in_min))
    return float(((inputPos - in_min) * scale) + out_min)