Package 

Object MathUtil


  • 
    public class MathUtil
    
                        

    Utility functions that are used my both PolyUtil and SphericalUtil.

    • Method Detail

      • 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 .

      • 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.

      • getEARTH_RADIUS

         final Double getEARTH_RADIUS()

        The earth's radius, in meters. Mean radius as defined by IUGG.