public class SloppyMath extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
TO_DEGREES |
static double |
TO_RADIANS |
| Constructor and Description |
|---|
SloppyMath() |
| Modifier and Type | Method and Description |
|---|---|
static double |
asin(double a)
Returns the arc sine of a value.
|
static double |
cos(double a)
Returns the trigonometric cosine of an angle.
|
static double |
haversinKilometers(double lat1,
double lon1,
double lat2,
double lon2)
Deprecated.
Use
instead |
static double |
haversinMeters(double sortKey)
Returns the Haversine distance in meters between two points
given the previous result from
haversinSortKey(double, double, double, double) |
static double |
haversinMeters(double lat1,
double lon1,
double lat2,
double lon2)
Returns the Haversine distance in meters between two points
specified in decimal degrees (latitude/longitude).
|
static double |
haversinSortKey(double lat1,
double lon1,
double lat2,
double lon2)
Returns a sort key for distance.
|
static double |
toDegrees(double radians)
Deprecated.
Use
Math.toDegrees(double) on Java 9+. |
static double |
toRadians(double degrees)
Deprecated.
Use
Math.toRadians(double) on Java 9+. |
public static final double TO_RADIANS
public static final double TO_DEGREES
public static double haversinMeters(double lat1,
double lon1,
double lat2,
double lon2)
Error is at most 4E-1 (40cm) from the actual haversine distance, but is typically much smaller for reasonable distances: around 1E-5 (0.01mm) for distances less than 1000km.
lat1 - Latitude of the first point.lon1 - Longitude of the first point.lat2 - Latitude of the second point.lon2 - Longitude of the second point.public static double haversinMeters(double sortKey)
haversinSortKey(double, double, double, double)@Deprecated public static double haversinKilometers(double lat1, double lon1, double lat2, double lon2)
insteadlat1 - Latitude of the first point.lon1 - Longitude of the first point.lat2 - Latitude of the second point.lon2 - Longitude of the second point.public static double haversinSortKey(double lat1,
double lon1,
double lat2,
double lon2)
haversinMeters(double, double, double, double), but it always compares the same.
This can be converted into an actual distance with haversinMeters(double), which
effectively does the second half of the computation.public static double cos(double a)
Error is around 1E-15.
Special cases:
NaN or an infinity, then the result is NaN.
a - an angle, in radians.Math.cos(double)public static double asin(double a)
The returned angle is in the range -pi/2 through pi/2. Error is around 1E-7.
Special cases:
NaN or its absolute value is greater than 1, then the result is NaN.
a - the value whose arc sine is to be returned.Math.asin(double)@Deprecated public static double toDegrees(double radians)
Math.toDegrees(double) on Java 9+.radians - radians to convert to degrees@Deprecated public static double toRadians(double degrees)
Math.toRadians(double) on Java 9+.degrees - degrees to convert to radiansCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.