Package science.aist.jack.math
Class MathUtils
- java.lang.Object
-
- science.aist.jack.math.MathUtils
-
public class MathUtils extends Object
Utility class for different math related operations
- Since:
- 2.0
- Author:
- Lukas Reithmeier, Andreas Pointner
-
-
Field Summary
Fields Modifier and Type Field Description static String
VALUES_MUST_NOT_BE_NULL
-
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 valuestatic boolean
biggerThan(Double bigger, Double smaller)
determines if one value is bigger than an other valuestatic double
cosd(double angleDeg)
Executes math.cos for degreesstatic boolean
equals(@NonNull Double a, @NonNull Double b, double epsilon)
determines if two double values are equalstatic boolean
equals(Double a, Double b)
determines if two double values are equalstatic boolean
higher(Double highest, Double candidate)
determines if a candidate is higher than a highest numberstatic boolean
lower(Double lowest, Double candidate)
determines if a candidate is lower than a highest numberstatic boolean
lowerThan(@NonNull Double lower, @NonNull Double bigger, double epsilon)
determines if one value is bigger than an other valuestatic boolean
lowerThan(Double lower, Double bigger)
determines if one value is bigger than an other valuestatic 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 valuesstatic MinMax<Integer>
minMax(int... values)
Gets the min and the max value of the given valuesstatic double
percent(double min, double max, double value)
Calculates the percentage value of a given value between a given maximum and a given minimumstatic double
sind(double angleDeg)
Executes math.sin for degrees
-
-
-
Field Detail
-
VALUES_MUST_NOT_BE_NULL
public static final String VALUES_MUST_NOT_BE_NULL
- See Also:
- Constant Field Values
-
-
Method Detail
-
higher
public static boolean higher(Double highest, Double candidate)
determines if a candidate is higher than a highest number- Parameters:
highest
- highestcandidate
- 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
- lowestcandidate
- 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 valueb
- second valueepsilon
- the epsilon to be used to check if two double values are equal- Returns:
- a == b
-
equals
public static boolean equals(Double a, Double b)
determines if two double values are equal- Parameters:
a
- first valueb
- second value- Returns:
- a == b
- See Also:
equals(Double, Double, double)
-
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 valuesmaller
- second valueepsilon
- 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 valuesmaller
- 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 valuebigger
- second valueepsilon
- 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 valuebigger
- 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 valuemax
- the maximum valuevalue
- 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
-
-