def renormalize(a, from_range, to_range):
    """Renormalize `a` from one range to another."""
    delta1 = from_range[1] - from_range[0]
    delta2 = to_range[1] - to_range[0]
    return (delta2 * (a - from_range[0]) / delta1) + to_range[0]