public class MathUtils extends Object
Constructor and Description |
---|
MathUtils() |
Modifier and Type | Method and Description |
---|---|
static float |
getBearing(double latitude1,
double longitude1,
double latitude2,
double longitude2)
Gets the relative bearing from one geographical coordinate to another.
|
static float |
getDistance(double latitude1,
double longitude1,
double latitude2,
double longitude2)
Gets the great circle distance in kilometers between two geographical points, using
the haversine formula.
|
static int |
getHalfWindIndex(float heading)
Converts the specified heading angle into an index between 0-15 that can be used to retrieve
the direction name for that heading (known as "boxing the compass", down to the half-wind
level).
|
static float |
mod(float a,
float b)
Calculates
a mod b in a way that respects negative values (for example,
mod(-1, 5) == 4 , rather than -1 ). |
static int |
mod(int a,
int b)
Calculates
a mod b in a way that respects negative values (for example,
mod(-1, 5) == 4 , rather than -1 ). |
public static int mod(int a, int b)
a mod b
in a way that respects negative values (for example,
mod(-1, 5) == 4
, rather than -1
).a
- the dividendb
- the divisora mod b
public static float mod(float a, float b)
a mod b
in a way that respects negative values (for example,
mod(-1, 5) == 4
, rather than -1
).a
- the dividendb
- the divisora mod b
public static int getHalfWindIndex(float heading)
heading
- the heading anglepublic static float getBearing(double latitude1, double longitude1, double latitude2, double longitude2)
latitude1
- the latitude of the source pointlongitude1
- the longitude of the source pointlatitude2
- the latitude of the destination pointlongitude2
- the longitude of the destination pointpublic static float getDistance(double latitude1, double longitude1, double latitude2, double longitude2)
latitude1
- the latitude of the first pointlongitude1
- the longitude of the first pointlatitude2
- the latitude of the second pointlongitude2
- the longitude of the second pointCopyright © 2014. All rights reserved.