com.mapbox.mapboxsdk.utils.MathUtils Maven / Gradle / Ivy
package com.mapbox.mapboxsdk.utils;
public class MathUtils {
/**
* Test a value in specified range, returning minimum if it's below, and maximum if it's above
* @param value Value to test
* @param min Minimum value of range
* @param max Maximum value of range
* @return value if it's between min and max, min if it's below, max if it's above
*/
public static double clamp(double value, double min, double max) {
return Math.max(min, Math.min(max, value));
}
/**
* Test a value in specified range, returning minimum if it's below, and maximum if it's above
* @param value Value to test
* @param min Minimum value of range
* @param max Maximum value of range
* @return value if it's between min and max, min if it's below, max if it's above
*/
public static float clamp(float value, float min, float max) {
return Math.max(min, Math.min(max, value));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy