public class MathUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static double |
average(java.lang.Double... nums)
Returns the average value of the input doubles.
|
static double |
average(double[] nums)
Returns the average value of the input doubles.
|
static boolean |
doublesEqual(double d1,
double d2)
Compares two doubles for equality, returning true if they are equal.
|
static boolean |
doublesEqual(double d1,
double d2,
double comparator)
Compares two doubles for equality, returning true if they are equal.
|
static double |
findDistance(double x1,
double y1,
double x2,
double y2)
Returns the distance (always positive) between two points in a coordinate system.
|
static double |
findHypotenuse(double leg1,
double leg2)
Returns the hypotenuse of a triangle given two legs according to the Pythagorean Theorem
|
static boolean |
isWithinTolerance(double value,
double target,
double tolerance)
Returns true if the value is within +/- tolerance of target
|
public static boolean doublesEqual(double d1, double d2)
public static boolean doublesEqual(double d1, double d2, double comparator)
d1
- d2
- comparator
- The value used to compare the doubles after subtracting (ex. 0.0000001). If working with especially small numbers, you would want
to set this very low since the difference between them may just be small and not an issue with double comparation.public static double average(double[] nums)
public static double average(java.lang.Double... nums)
public static double findDistance(double x1, double y1, double x2, double y2)
x1
- The x-coord of point 1y1
- The y-coord of point 1x2
- The x-coord of point 2y2
- The y-coord of point 2public static boolean isWithinTolerance(double value, double target, double tolerance)
tolerance
- The tolerance (must be positive)public static double findHypotenuse(double leg1, double leg2)
leg1
- The length of the first legleg2
- The length of the second leg