
no.nav.common.utils.MathUtils Maven / Gradle / Ivy
The newest version!
package no.nav.common.utils;
public class MathUtils {
// Precise linear interpolation method, which guarantees = 'to' when t = 1.
public static long linearInterpolation(long from, long to, float t) {
t = (t > 1) ? 1 : Math.max(0, t);
return (long) ((1 - t) * from + t * to);
}
public static int clamp(int val, int min, int max) {
return Math.max(min, Math.min(max, val));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy