def fixAnglePlusMinusPi(a):
    """
    A is an angle in radians;  return an equivalent angle between plus
    and minus pi
    """
    pi2 = 2.0* math.pi
    while abs(a) > math.pi:
        if a > math.pi:
            a = a - pi2
        elif a < -math.pi:
            a = a + pi2
    return a
dataset/ETHPy150Open rll/lfd/lfd/rapprentice/util.py/fixAnglePlusMinusPi/original