def wrapCtr(angDeg):
    """Returns the angle (in degrees) wrapped into the range (-180, 180]"""
    # First wrap into [0, 360]; result is 360 if ctrAng < 0 but so near 0 that adding 360 rounds it
    ctrAng = angDeg % 360.0
    if ctrAng > 180.0:
        ctrAng -= 360.0
    return ctrAng