Class MathTools


  • public class MathTools
    extends Object
    Contains methods Math might also contain but doesn't.
    • Constructor Detail

      • MathTools

        public MathTools()
    • Method Detail

      • isInInterval

        public static boolean isInInterval​(double lowerBound,
                                           double value,
                                           double upperBound)
        Checks whether the specified value lies in the closed interval defined by the specified bounds.
        Parameters:
        lowerBound - the interval's lower bound; included in the interval
        value - the value which will be checked
        upperBound - the interval's upper bound; included in the interval
        Returns:
        true if lowerBound <= value <= upperBound
        false otherwise
      • inInterval

        public static double inInterval​(double lowerBound,
                                        double value,
                                        double upperBound)
        Checks whether the specified value lies in the closed interval defined by the specified bounds. If it does, it is returned; otherwise the bound closer to the value will be returned.
        Parameters:
        lowerBound - the interval's lower bound; included in the interval
        value - the value which will be checked
        upperBound - the interval's upper bound; included in the interval
        Returns:
        value if lowerBound <= value <= upperBound
        lowerBound if value < lowerBound
        upperBound if upperBound < value
      • min

        public static double min​(double... values)
        Returns the smallest value in the specified array according to Math.min(double, double).
        Parameters:
        values - a non-null, non-empty array of double values
        Returns:
        a value from the array which is smaller then or equal to any other value from the array
        Throws:
        NullPointerException - if the values array is null
        IllegalArgumentException - if the values array is empty (i.e. has length 0)