/** * Distance between two valid locations. * @param a a valid location * @param b a valid location * @return the absolute distance between the locations in the circular location space. */ public static double distance(double a, double b) { if (!isValid(a) || !isValid(b)) { String errMsg = "Invalid Location ! a = " + a + " b = " + b + " Please report this bug!"; Logger.error(Location.class, errMsg, new Exception("error")); throw new IllegalArgumentException(errMsg); } return simpleDistance(a, b); }
/** * Distance between two potentially invalid locations. * @param a a valid location * @param b a valid location * @return the absolute distance between the locations in the circular location space. * Invalid locations are considered to be at 2.0, and the result is returned accordingly. */ public static double distanceAllowInvalid(double a, double b) { if (!isValid(a) && !isValid(b)) { return 0.0; // Both are out of range so both are equal. } if (!isValid(a)) { return 2.0 - b; } if (!isValid(b)) { return 2.0 - a; } // Both values are valid. return simpleDistance(a, b); }