Class MathUtils


  • public class MathUtils
    extends Object

    Utility class for different math related operations

    Since:
    2.0
    Author:
    Lukas Reithmeier, Andreas Pointner
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean biggerThan​(@NonNull Double bigger, @NonNull Double smaller, double epsilon)
      determines if one value is bigger than an other value
      static boolean biggerThan​(Double bigger, Double smaller)
      determines if one value is bigger than an other value
      static double cosd​(double angleDeg)
      Executes math.cos for degrees
      static boolean equals​(@NonNull Double a, @NonNull Double b, double epsilon)
      determines if two double values are equal
      static boolean equals​(Double a, Double b)
      determines if two double values are equal
      static boolean higher​(Double highest, Double candidate)
      determines if a candidate is higher than a highest number
      static boolean lower​(Double lowest, Double candidate)
      determines if a candidate is lower than a highest number
      static boolean lowerThan​(@NonNull Double lower, @NonNull Double bigger, double epsilon)
      determines if one value is bigger than an other value
      static boolean lowerThan​(Double lower, Double bigger)
      determines if one value is bigger than an other value
      static int max​(int... val)
      Calculates the maximum of all given values.
      static int min​(int... val)
      Calculates the minimum of all given values.
      static MinMax<Double> minMax​(double... values)
      Gets the min and the max value of the given values
      static MinMax<Integer> minMax​(int... values)
      Gets the min and the max value of the given values
      static double percent​(double min, double max, double value)
      Calculates the percentage value of a given value between a given maximum and a given minimum
      static double sind​(double angleDeg)
      Executes math.sin for degrees
    • Method Detail

      • higher

        public static boolean higher​(Double highest,
                                     Double candidate)
        determines if a candidate is higher than a highest number
        Parameters:
        highest - highest
        candidate - candidate
        Returns:
        true, if a candidate is higher than a highest number
      • lower

        public static boolean lower​(Double lowest,
                                    Double candidate)
        determines if a candidate is lower than a highest number
        Parameters:
        lowest - lowest
        candidate - candidate
        Returns:
        true, if a candidate is lower than a highest number
      • equals

        public static boolean equals​(@NonNull
                                     @NonNull Double a,
                                     @NonNull
                                     @NonNull Double b,
                                     double epsilon)
        determines if two double values are equal
        Parameters:
        a - first value
        b - second value
        epsilon - the epsilon to be used to check if two double values are equal
        Returns:
        a == b
      • biggerThan

        public static boolean biggerThan​(@NonNull
                                         @NonNull Double bigger,
                                         @NonNull
                                         @NonNull Double smaller,
                                         double epsilon)
        determines if one value is bigger than an other value
        Parameters:
        bigger - first value
        smaller - second value
        epsilon - the epsilon to be used to check which double value is bigger
        Returns:
        true, if the first value is bigger than the second value
      • biggerThan

        public static boolean biggerThan​(Double bigger,
                                         Double smaller)
        determines if one value is bigger than an other value
        Parameters:
        bigger - first value
        smaller - second value
        Returns:
        true, if the first value is bigger than the second value
        See Also:
        biggerThan(Double, Double, double)
      • lowerThan

        public static boolean lowerThan​(@NonNull
                                        @NonNull Double lower,
                                        @NonNull
                                        @NonNull Double bigger,
                                        double epsilon)
        determines if one value is bigger than an other value
        Parameters:
        lower - first value
        bigger - second value
        epsilon - the epsilon to be used to check which double value is lower
        Returns:
        true, if the second value is bigger than the first value
      • lowerThan

        public static boolean lowerThan​(Double lower,
                                        Double bigger)
        determines if one value is bigger than an other value
        Parameters:
        lower - first value
        bigger - second value
        Returns:
        true, if the second value is bigger than the first value
        See Also:
        lowerThan(Double, Double, double)
      • percent

        public static double percent​(double min,
                                     double max,
                                     double value)
        Calculates the percentage value of a given value between a given maximum and a given minimum
        Parameters:
        min - the minimum value
        max - the maximum value
        value - the value to calculate the percentage
        Returns:
        the percentage of value in relation to min and max
      • cosd

        public static double cosd​(double angleDeg)
        Executes math.cos for degrees
        Parameters:
        angleDeg - angle in degrees
        Returns:
        Math.cos() result
      • sind

        public static double sind​(double angleDeg)
        Executes math.sin for degrees
        Parameters:
        angleDeg - angle in degrees
        Returns:
        Math.sin() result
      • max

        public static int max​(int... val)
        Calculates the maximum of all given values.
        Parameters:
        val - the values
        Returns:
        the maximum value
      • min

        public static int min​(int... val)
        Calculates the minimum of all given values. If the values are empty, Integer.MAX_VALUE is returned.
        Parameters:
        val - the values
        Returns:
        the min value of all values
      • minMax

        public static MinMax<Integer> minMax​(int... values)
        Gets the min and the max value of the given values
        Parameters:
        values - for which min and max should be determined
        Returns:
        MinMax for the given values
      • minMax

        public static MinMax<Double> minMax​(double... values)
        Gets the min and the max value of the given values
        Parameters:
        values - for which min and max should be determined
        Returns:
        MinMax for the given values