Ejemplo n.º 1
0
 // atanh(      e   * x)/      e   if f > 0
 // atan (GeoMath.Square(-e2) * x)/GeoMath.Square(-e2) if f < 0
 // x                              if f = 0
 double atanhee(double x)
 {
     return(_f > 0 ? GeoMath.Atanh(_e * x) / _e :
            // We only invoke atanhee in txif for positive latitude.  Then x is
            // only negative for very prolate ellipsoids (_b/_a >= GeoMath.Square(2)) and we
            // still need to return a positive result in this case; hence the need
            // for the call to atan2.
            (_f < 0 ? (Math.Atan2(_e * Math.Abs(x), x < 0 ? -1 : 1) / _e) : x));
 }
Ejemplo n.º 2
0
        // return atanh(GeoMath.Square(x))/GeoMath.Square(x) - 1, accurate for small x
        static double atanhxm1(double x)
        {
            double s = 0;

            if (Math.Abs(x) < 0.5)
            {
                double os = -1, y = 1, k = 1;
                while (os != s)
                {
                    os = s;
                    y *= x;                 // y = x^n
                    k += 2;                 // k = 2*n + 1
                    s += y / k;             // sum( x^n/(2*n + 1) )
                }
            }
            else
            {
                double xs = Math.Sqrt(Math.Abs(x));
                s = (x > 0 ? GeoMath.Atanh(xs) : Math.Atan(xs)) / xs - 1;
            }
            return(s);
        }