Added an integer MathUtil with clamp(low, value, high).

This commit is contained in:
Michael Bayne
2011-11-16 13:55:34 -08:00
parent 6f7b519102
commit 26cf80f38f
+20
View File
@@ -0,0 +1,20 @@
//
// Pythagoras - a collection of geometry classes
// http://github.com/samskivert/pythagoras
package pythagoras.i;
/**
* Math utility methods.
*/
public class MathUtil
{
/**
* Clamps the supplied {@code value} to between {@code low} and {@code high} (both inclusive).
*/
public static int clamp (int low, int value, int high) {
if (value < low) return low;
if (value > high) return high;
return value;
}
}