/** * Converts from a positive infinite range to the range from zero to maxiumum. Uses an exponential * conversion. * * @param distance a (possibly very great) distance * @param maximum the new maximum value. * @return the clamped value * @see #closedDistanceRangeToInfinite(double, double) */ public static double infiniteDistanceRangeToClosed(double distance, double maximum) { return (maximum - (maximum * Math.exp(-alpha * distance))); }
/** * Converts from the range zero to one to zero to the specified maximum. It uses a log value. * * @param distance the distance * @param maximum the max * @return the undamped distance * @see #infiniteDistanceRangeToClosed(double, double) */ public static double closedDistanceRangeToInfinite(double distance, double maximum) { return (-alpha * Math.log(1 - (distance / maximum))); }