AlbersEqualArea.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_ALBERSEQUALAREA_HPP)
11 #define GEOGRAPHICLIB_ALBERSEQUALAREA_HPP 1
12 
14 
15 namespace GeographicLib {
16 
61  private:
62  typedef Math::real real;
63  real eps_, epsx_, epsx2_, tol_, tol0_;
64  real _a, _f, _fm, _e2, _e, _e2m, _qZ, _qx;
65  real _sign, _lat0, _k0;
66  real _n0, _m02, _nrho0, _k2, _txi0, _scxi0, _sxi0;
67  static const int numit_ = 5; // Newton iterations in Reverse
68  static const int numit0_ = 20; // Newton iterations in Init
69  static real hyp(real x) { return Math::hypot(real(1), x); }
70  // atanh( e * x)/ e if f > 0
71  // atan (sqrt(-e2) * x)/sqrt(-e2) if f < 0
72  // x if f = 0
73  real atanhee(real x) const {
74  using std::atan2; using std::abs;
75  return _f > 0 ? Math::atanh(_e * x)/_e :
76  // We only invoke atanhee in txif for positive latitude. Then x is
77  // only negative for very prolate ellipsoids (_b/_a >= sqrt(2)) and we
78  // still need to return a positive result in this case; hence the need
79  // for the call to atan2.
80  (_f < 0 ? (atan2(_e * abs(x), real(x < 0 ? -1 : 1))/_e) : x);
81  }
82  // return atanh(sqrt(x))/sqrt(x) - 1, accurate for small x
83  static real atanhxm1(real x);
84 
85  // Divided differences
86  // Definition: Df(x,y) = (f(x)-f(y))/(x-y)
87  // See:
88  // W. M. Kahan and R. J. Fateman,
89  // Symbolic computation of divided differences,
90  // SIGSAM Bull. 33(3), 7-28 (1999)
91  // https://doi.org/10.1145/334714.334716
92  // http://www.cs.berkeley.edu/~fateman/papers/divdiff.pdf
93  //
94  // General rules
95  // h(x) = f(g(x)): Dh(x,y) = Df(g(x),g(y))*Dg(x,y)
96  // h(x) = f(x)*g(x):
97  // Dh(x,y) = Df(x,y)*g(x) + Dg(x,y)*f(y)
98  // = Df(x,y)*g(y) + Dg(x,y)*f(x)
99  // = Df(x,y)*(g(x)+g(y))/2 + Dg(x,y)*(f(x)+f(y))/2
100  //
101  // sn(x) = x/sqrt(1+x^2): Dsn(x,y) = (x+y)/((sn(x)+sn(y))*(1+x^2)*(1+y^2))
102  static real Dsn(real x, real y, real sx, real sy) {
103  // sx = x/hyp(x)
104  real t = x * y;
105  return t > 0 ? (x + y) * Math::sq( (sx * sy)/t ) / (sx + sy) :
106  (x - y != 0 ? (sx - sy) / (x - y) : 1);
107  }
108  // Datanhee(x,y) = atanhee((x-y)/(1-e^2*x*y))/(x-y)
109  real Datanhee(real x, real y) const {
110  real t = x - y, d = 1 - _e2 * x * y;
111  return t != 0 ? atanhee(t / d) / t : 1 / d;
112  }
113  // DDatanhee(x,y) = (Datanhee(1,y) - Datanhee(1,x))/(y-x)
114  real DDatanhee(real x, real y) const;
115  void Init(real sphi1, real cphi1, real sphi2, real cphi2, real k1);
116  real txif(real tphi) const;
117  real tphif(real txi) const;
118 
119  friend class Ellipsoid; // For access to txif, tphif, etc.
120  public:
121 
135  AlbersEqualArea(real a, real f, real stdlat, real k0);
136 
152  AlbersEqualArea(real a, real f, real stdlat1, real stdlat2, real k1);
153 
177  AlbersEqualArea(real a, real f,
178  real sinlat1, real coslat1,
179  real sinlat2, real coslat2,
180  real k1);
181 
193  void SetScale(real lat, real k = real(1));
194 
213  void Forward(real lon0, real lat, real lon,
214  real& x, real& y, real& gamma, real& k) const;
215 
234  void Reverse(real lon0, real x, real y,
235  real& lat, real& lon, real& gamma, real& k) const;
236 
241  void Forward(real lon0, real lat, real lon,
242  real& x, real& y) const {
243  real gamma, k;
244  Forward(lon0, lat, lon, x, y, gamma, k);
245  }
246 
251  void Reverse(real lon0, real x, real y,
252  real& lat, real& lon) const {
253  real gamma, k;
254  Reverse(lon0, x, y, lat, lon, gamma, k);
255  }
256 
259 
264  Math::real MajorRadius() const { return _a; }
265 
270  Math::real Flattening() const { return _f; }
271 
279  Math::real OriginLatitude() const { return _lat0; }
280 
285  Math::real CentralScale() const { return _k0; }
287 
293  static const AlbersEqualArea& CylindricalEqualArea();
294 
300  static const AlbersEqualArea& AzimuthalEqualAreaNorth();
301 
307  static const AlbersEqualArea& AzimuthalEqualAreaSouth();
308  };
309 
310 } // namespace GeographicLib
311 
312 #endif // GEOGRAPHICLIB_ALBERSEQUALAREA_HPP
static real Dsn(real x, real y, real sx, real sy)
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
float real
Definition: datatypes.h:10
Scalar * y
static const double lat
static T atanh(T x)
Definition: Math.hpp:328
Array33i a
void Reverse(real lon0, real x, real y, real &lat, real &lon) const
Albers equal area conic projection.
static T hypot(T x, T y)
Definition: Math.hpp:243
const mpreal gamma(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition: mpreal.h:2262
static T sq(T x)
Definition: Math.hpp:232
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Namespace for GeographicLib.
const double lon0
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
Definition: jet.h:556
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
real Datanhee(real x, real y) const
Header for GeographicLib::Constants class.
Math::real OriginLatitude() const
static const double lon
void Forward(real lon0, real lat, real lon, real &x, real &y) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
#define abs(x)
Definition: datatypes.h:17
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:36