public class SloppyMath
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static double |
ASIN_DELTA |
private static double |
ASIN_INDEXER |
private static double |
ASIN_MAX_VALUE_FOR_TABS |
private static double |
ASIN_PIO2_HI |
private static double |
ASIN_PIO2_LO |
private static double |
ASIN_PS0 |
private static double |
ASIN_PS1 |
private static double |
ASIN_PS2 |
private static double |
ASIN_PS3 |
private static double |
ASIN_PS4 |
private static double |
ASIN_PS5 |
private static double |
ASIN_QS1 |
private static double |
ASIN_QS2 |
private static double |
ASIN_QS3 |
private static double |
ASIN_QS4 |
private static int |
ASIN_TABS_SIZE |
private static double[] |
asinDer1DivF1Tab |
private static double[] |
asinDer2DivF2Tab |
private static double[] |
asinDer3DivF3Tab |
private static double[] |
asinDer4DivF4Tab |
private static double[] |
asinTab |
private static double[] |
cosTab |
private static double |
ONE_DIV_F2 |
private static double |
ONE_DIV_F3 |
private static double |
ONE_DIV_F4 |
private static double |
PIO2_HI |
private static double |
PIO2_LO |
private static double |
SIN_COS_DELTA_HI |
private static double |
SIN_COS_DELTA_LO |
private static double |
SIN_COS_INDEXER |
(package private) static double |
SIN_COS_MAX_VALUE_FOR_INT_MODULO |
private static int |
SIN_COS_TABS_SIZE |
private static double[] |
sinTab |
static double |
TO_DEGREES |
private static double |
TO_KILOMETERS |
private static double |
TO_METERS |
static double |
TO_RADIANS |
private static double |
TWOPI_HI |
private static double |
TWOPI_LO |
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)
Convert to degrees.
|
static double |
toRadians(double degrees)
Convert to radians.
|
public static final double TO_RADIANS
public static final double TO_DEGREES
private static final double TO_METERS
private static final double TO_KILOMETERS
private static final double ONE_DIV_F2
private static final double ONE_DIV_F3
private static final double ONE_DIV_F4
private static final double PIO2_HI
private static final double PIO2_LO
private static final double TWOPI_HI
private static final double TWOPI_LO
private static final int SIN_COS_TABS_SIZE
private static final double SIN_COS_DELTA_HI
private static final double SIN_COS_DELTA_LO
private static final double SIN_COS_INDEXER
private static final double[] sinTab
private static final double[] cosTab
static final double SIN_COS_MAX_VALUE_FOR_INT_MODULO
private static final double ASIN_MAX_VALUE_FOR_TABS
private static final int ASIN_TABS_SIZE
private static final double ASIN_DELTA
private static final double ASIN_INDEXER
private static final double[] asinTab
private static final double[] asinDer1DivF1Tab
private static final double[] asinDer2DivF2Tab
private static final double[] asinDer3DivF3Tab
private static final double[] asinDer4DivF4Tab
private static final double ASIN_PIO2_HI
private static final double ASIN_PIO2_LO
private static final double ASIN_PS0
private static final double ASIN_PS1
private static final double ASIN_PS2
private static final double ASIN_PS3
private static final double ASIN_PS4
private static final double ASIN_PS5
private static final double ASIN_QS1
private static final double ASIN_QS2
private static final double ASIN_QS3
private static final double ASIN_QS4
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)
instead
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 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)
public static double toDegrees(double radians)
radians
- radians to convert to degreespublic static double toRadians(double degrees)
degrees
- degrees to convert to radians