Added an integer MathUtil with clamp(low, value, high).
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user