WWMath { public static double normalizeAngle360(double degrees) { double angle = degrees % 360; return angle >= 0 ? angle : (angle < 0 ? 360 + angle : 360 - angle); }  static double clamp(double value, double min, double max); static double clampAngle180(double degrees); static double clampAngle360(double degrees); static double fract(double value); static double interpolate(double amount, double value1, double value2); static double interpolateAngle180(double amount, double degrees1, double degrees2); static double interpolateAngle360(double amount, double degrees1, double degrees2); static int mod(int value, int modulus); static double normalizeAngle180(double degrees); static double normalizeAngle360(double degrees); static Viewport boundingRectForUnitSquare(Matrix4 unitSquareTransform, Viewport result); static boolean isPowerOfTwo(int value); static int powerOfTwoCeiling(int value);  }
@Test public void testNormalizeDegrees() throws Exception { assertEquals("zero", 0.0, WWMath.normalizeAngle360(0.0), 0); assertEquals("180", 180.0, WWMath.normalizeAngle360(180.0), 0); assertEquals("181", 181.0, WWMath.normalizeAngle360(181.0), 0); assertEquals("359", 359.0, WWMath.normalizeAngle360(359.0), 0); assertEquals("360", 0.0, WWMath.normalizeAngle360(360.0), 0); assertEquals("361", 1.0, WWMath.normalizeAngle360(361.0), 0); assertEquals("720", 0.0, WWMath.normalizeAngle360(720.0), 0); assertEquals("721", 1.0, WWMath.normalizeAngle360(721.0), 0); assertEquals("-1", 359.0, WWMath.normalizeAngle360(-1.0), 0); assertEquals("-359", 1.0, WWMath.normalizeAngle360(-359.0), 0); assertEquals("-360", 0.0, WWMath.normalizeAngle360(-360.0), 0); assertEquals("-361", 359.0, WWMath.normalizeAngle360(-361.0), 0); assertEquals("-719", 1.0, WWMath.normalizeAngle360(-719.0), 0); assertEquals("-720", 0.0, WWMath.normalizeAngle360(-720.0), 0); assertEquals("-721", 359.0, WWMath.normalizeAngle360(-721.0), 0); assertTrue("NaN", Double.isNaN(WWMath.normalizeAngle360(Double.NaN))); }