Class MathExtra


  • public final class MathExtra
    extends Object
    • Method Detail

      • clamp

        public static double clamp​(double value,
                                   double min,
                                   double max)
        This method clamp a number within a range of numbers. If the value is greater than the range, it returns the highest number and not the overflow number. If the value is less than the range, it returns the smallest number and not the overflow number.
        Parameters:
        value - Value to analyze
        min - Minimum range value
        max - Maximum range value
        Returns:
        Returns a value within the given range
      • percentage

        public static double percentage​(double value,
                                        double percentage)
        Find the percent of a number.
        Parameters:
        value - Base value
        percentage - Percentage to calculate
        Returns:
        Returns a percentage of a number