def renormalize(n, range1, range2):
    """
    normalize a n value in a new range from the old range
    """
    delta1 = range1[1] - range1[0]
    delta2 = range2[1] - range2[0]
    return (delta2 * (n - range1[0]) / delta1) + range2[0]