def map(value, in_low, in_high, out_low, out_high):
    """
    Map value from on range to another.

    ((value - in_low) * (out_high - out_low)) / (in_high - in_low) + out_low
    """
    # example from /animation_nodes/nodes/number/map_range.py
    # if inMin == inMax:
    #     newValue = 0
    # # with clamping
    #     if inMin < inMax:
    #         _value = min(max(value, inMin), inMax)
    #     else:
    #         _value = min(max(value, inMax), inMin)
    #     with interpolation
    #         newValue = outMin + interpolation(
    #             (_value - inMin) / (inMax - inMin)
    #         ) * (outMax - outMin)
    #     without interpolation
    #         newValue = outMin + (
    #             (_value - inMin) / (inMax - inMin)
    #         ) * (outMax - outMin)
    # # without clamping
    #     newValue = outMin + (
    #         (value - inMin) / (inMax - inMin)
    #     ) * (outMax - outMin)
    # # without clamping - reworded
    # result = (
    #     (
    #         ((value - in_low) / (in_high - in_low)) *
    #         (out_high - out_low)
    #     ) + out_low
    # )

    result = None

    # based on http://arduino.cc/en/Reference/Map
    # and http://stackoverflow.com/a/5650012/574981
    result = (
        (
            ((value - in_low) * (out_high - out_low)) /
            (in_high - in_low)
        ) + out_low
    )

    return result