MathUtil { public static double mapPercentage(double value, double inMin, double inMax) { return map(value, inMin, inMax, 0, 100); } private  MathUtil(); static double mapPercentage(double value, double inMin, double inMax); static double map(double value, double inMin, double inMax, double outMin, double outMax); static double mapClamped(double value, double inMin, double inMax, double outMin, double outMax); static double clamp(double v, double min, double max);  }
@Test public void mapPercentageWorksAsExpected() { assertEquals(50D, MathUtil.mapPercentage(0.25, 0, 0.5), EPSILON); assertEquals(25D, MathUtil.mapPercentage(1.5, 1, 3), EPSILON); assertEquals(-100D, MathUtil.mapPercentage(-1, 1, 3), EPSILON); }