-
public class MathUtilUtility functions that are used my both PolyUtil and SphericalUtil.
-
-
Field Summary
Fields Modifier and Type Field Description private final DoubleEARTH_RADIUSpublic final static MathUtilINSTANCE
-
Method Summary
Modifier and Type Method Description final static Doubleclamp(Double x, Double low, Double high)Restrict x to the range low, high. final static Doublewrap(Double n, Double min, Double max)Wraps the given value into the inclusive-exclusive interval between min and max. final static Doublemod(Double x, Double m)Returns the non-negative remainder of x / m. final static Doublemercator(Double lat)Returns mercator Y corresponding to latitude. final static DoubleinverseMercator(Double y)Returns latitude from mercator Y. final static Doublehav(Double x)Returns haversine(angle-in-radians). final static DoublearcHav(Double x)Computes inverse haversine. final static DoublesinFromHav(Double h)final static DoublehavFromSin(Double x)final static DoublesinSumFromHav(Double x, Double y)final static DoublehavDistance(Double lat1, Double lat2, Double dLng)Returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere. final DoublegetEARTH_RADIUS()The earth's radius, in meters. -
-
Method Detail
-
clamp
final static Double clamp(Double x, Double low, Double high)
Restrict x to the range low, high.
-
wrap
final static Double wrap(Double n, Double min, Double max)
Wraps the given value into the inclusive-exclusive interval between min and max.
- Parameters:
n- The value to wrap.min- The minimum.max- The maximum.
-
mod
final static Double mod(Double x, Double m)
Returns the non-negative remainder of x / m.
- Parameters:
x- The operand.m- The modulus.
-
mercator
final static Double mercator(Double lat)
Returns mercator Y corresponding to latitude. See http://en.wikipedia.org/wiki/Mercator_projection .
-
inverseMercator
final static Double inverseMercator(Double y)
Returns latitude from mercator Y.
-
hav
final static Double hav(Double x)
Returns haversine(angle-in-radians). hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2.
-
arcHav
final static Double arcHav(Double x)
Computes inverse haversine. Has good numerical stability around 0. arcHav(x) == acos(1 - 2 * x) == 2 * asin(sqrt(x)). The argument must be in 0, 1, and the result is positive.
-
sinFromHav
final static Double sinFromHav(Double h)
-
havFromSin
final static Double havFromSin(Double x)
-
sinSumFromHav
final static Double sinSumFromHav(Double x, Double y)
-
havDistance
final static Double havDistance(Double lat1, Double lat2, Double dLng)
Returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere.
-
getEARTH_RADIUS
final Double getEARTH_RADIUS()
The earth's radius, in meters. Mean radius as defined by IUGG.
-
-
-
-