def optimizeAngle(angle):
 if (angle < 0):
  angle %= (-360)
 else:
  angle %= 360
 if (angle >= 270):
  angle -= 360
 elif (angle < (-90)):
  angle += 360
 return angle

def optimizeAngle ( angle ) : if ( angle < 0 ) : angle %= ( - 360 ) else : angle %= 360 if ( angle >= 270 ) : angle -= 360 elif ( angle < ( - 90 ) ) : angle += 360 return angle
because any rotation can be expressed within 360 degrees of any given number .