def map_value(in_v, in_min, in_max, out_min, out_max):
    """Helper method to map an input value (v_in)
    between alternative max/min ranges."""
    v = (in_v - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
    return max(min(out_max, v), out_min)