def zigzag2(i, curr=0.45, upper=0.48, lower=0.13):
    """
    Generalized version of the zig-zag function.
    Returns points oscillating between two bounds
    linearly.
    """
    if abs(i) <= upper - curr:
        return curr + i
    else:
        i = i - (upper - curr)
        i = i % (2 * (upper - lower))
        if i < upper - lower:
            return upper - i
        else:
            return 2 * lower - upper + i
