def scale(input_interval, output_interval, value):
    """
        For two intervals (input and output)
        Scales a specific value linear from [input_min, input_max] to [output_min, output_max].
    """
    min_to, max_to = output_interval
    min_from, max_from = input_interval
    mapped_value = min_to + (max_to - min_to) * ((value - min_from) / (max_from - min_from))
    return mapped_value