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 
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 
242  real& x, real& y) const {
243  real gamma, k;
244  Forward(lon0, lat, lon, x, y, gamma, k);
245  }
246 
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
Eigen::Forward
@ Forward
Definition: NumericalDiff.h:19
GeographicLib::AlbersEqualArea
Albers equal area conic projection.
Definition: AlbersEqualArea.hpp:60
GeographicLib::Math::atanh
static T atanh(T x)
Definition: Math.hpp:328
d
static const double d[K][N]
Definition: igam.h:11
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::AlbersEqualArea::tol_
real tol_
Definition: AlbersEqualArea.hpp:63
x
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
Definition: gnuplot_common_settings.hh:12
GeographicLib::AlbersEqualArea::_qZ
real _qZ
Definition: AlbersEqualArea.hpp:64
real
float real
Definition: datatypes.h:10
GeographicLib::AlbersEqualArea::_sign
real _sign
Definition: AlbersEqualArea.hpp:65
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
k0
double k0(double x)
Definition: k0.c:131
GeographicLib::AlbersEqualArea::_txi0
real _txi0
Definition: AlbersEqualArea.hpp:66
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::AlbersEqualArea::Reverse
void Reverse(real lon0, real x, real y, real &lat, real &lon) const
Definition: AlbersEqualArea.hpp:251
GeographicLib::AlbersEqualArea::Datanhee
real Datanhee(real x, real y) const
Definition: AlbersEqualArea.hpp:109
GeographicLib::AlbersEqualArea::Dsn
static real Dsn(real x, real y, real sx, real sy)
Definition: AlbersEqualArea.hpp:102
GeographicLib::AlbersEqualArea::OriginLatitude
Math::real OriginLatitude() const
Definition: AlbersEqualArea.hpp:279
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
GeographicLib::AlbersEqualArea::hyp
static real hyp(real x)
Definition: AlbersEqualArea.hpp:69
k1
double k1(double x)
Definition: k1.c:133
GeographicLib::AlbersEqualArea::Flattening
Math::real Flattening() const
Definition: AlbersEqualArea.hpp:270
GeographicLib::AlbersEqualArea::CentralScale
Math::real CentralScale() const
Definition: AlbersEqualArea.hpp:285
gamma
#define gamma
Definition: mconf.h:85
Constants.hpp
Header for GeographicLib::Constants class.
y
Scalar * y
Definition: level1_cplx_impl.h:124
atan2
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:110
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
GeographicLib::AlbersEqualArea::Forward
void Forward(real lon0, real lat, real lon, real &x, real &y) const
Definition: AlbersEqualArea.hpp:241
abs
#define abs(x)
Definition: datatypes.h:17
GeographicLib::AlbersEqualArea::atanhee
real atanhee(real x) const
Definition: AlbersEqualArea.hpp:73
lon
static const double lon
Definition: testGeographicLib.cpp:34
GeographicLib::Math::sq
static T sq(T x)
Definition: Math.hpp:232
align_3::t
Point2 t(10, 10)
GeographicLib::Ellipsoid
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
GeographicLib::AlbersEqualArea::real
Math::real real
Definition: AlbersEqualArea.hpp:62
GeographicLib::Math::hypot
static T hypot(T x, T y)
Definition: Math.hpp:243
real
Definition: main.h:100
lat
static const double lat
Definition: testGeographicLib.cpp:34
GeographicLib::AlbersEqualArea::MajorRadius
Math::real MajorRadius() const
Definition: AlbersEqualArea.hpp:264


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:31:52