@Test public void testClamp() { assertEquals(0, MathUtils.clamp(-4, 0, 7)); assertEquals(3, MathUtils.clamp(3, -2, 7)); assertEquals(0, MathUtils.clamp(0, 0, 7)); assertEquals(7, MathUtils.clamp(7, 0, 7)); assertEquals(7, MathUtils.clamp(8, -2, 7)); assertEquals(0.0, MathUtils.clamp(-0.4, 0.0, 7.0), 0.0); assertEquals(3.0, MathUtils.clamp(3.0, 0.0, 7.0), 0.0); assertEquals(0.1, MathUtils.clamp(0.1, 0.0, 7.0), 0.0); assertEquals(7.0, MathUtils.clamp(7.0, 0.0, 7.0), 0.0); assertEquals(-0.6, MathUtils.clamp(-0.7, -0.6, 7.0), 0.0); assertEquals(0.0f, MathUtils.clamp(-0.4f, 0.0f, 7.0f), 0.0f); assertEquals(3.0f, MathUtils.clamp(3.0f, 0.0f, 7.0f), 0.0f); assertEquals(0.1f, MathUtils.clamp(0.1f, 0.0f, 7.0f), 0.0f); assertEquals(7.0f, MathUtils.clamp(7.0f, 0.0f, 7.0f), 0.0f); assertEquals(-0.6f, MathUtils.clamp(-0.7f, -0.6f, 7.0f), 0.0f); }
public static float clamp(float value, float min, float max) { if (value < min) { return min; } else if (value > max) { return max; } return value; }
MathUtils { public static float clamp(float value, float min, float max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } }
MathUtils { public static float clamp(float value, float min, float max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } private  MathUtils(); }
MathUtils { public static float clamp(float value, float min, float max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } private  MathUtils(); static float clamp(float value, float min, float max); static double clamp(double value, double min, double max); static int clamp(int value, int min, int max); }
MathUtils { public static float clamp(float value, float min, float max) { if (value < min) { return min; } else if (value > max) { return max; } return value; } private  MathUtils(); static float clamp(float value, float min, float max); static double clamp(double value, double min, double max); static int clamp(int value, int min, int max);  }