LambertConformalConic.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP)
11 #define GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP 1
12 
14 
15 namespace GeographicLib {
16 
64  private:
65  typedef Math::real real;
66  real eps_, epsx_, ahypover_;
67  real _a, _f, _fm, _e2, _es;
68  real _sign, _n, _nc, _t0nm1, _scale, _lat0, _k0;
69  real _scbet0, _tchi0, _scchi0, _psi0, _nrho0, _drhomax;
70  static const int numit_ = 5;
71  static real hyp(real x) { return Math::hypot(real(1), x); }
72  // Divided differences
73  // Definition: Df(x,y) = (f(x)-f(y))/(x-y)
74  // See:
75  // W. M. Kahan and R. J. Fateman,
76  // Symbolic computation of divided differences,
77  // SIGSAM Bull. 33(3), 7-28 (1999)
78  // https://doi.org/10.1145/334714.334716
79  // http://www.cs.berkeley.edu/~fateman/papers/divdiff.pdf
80  //
81  // General rules
82  // h(x) = f(g(x)): Dh(x,y) = Df(g(x),g(y))*Dg(x,y)
83  // h(x) = f(x)*g(x):
84  // Dh(x,y) = Df(x,y)*g(x) + Dg(x,y)*f(y)
85  // = Df(x,y)*g(y) + Dg(x,y)*f(x)
86  // = Df(x,y)*(g(x)+g(y))/2 + Dg(x,y)*(f(x)+f(y))/2
87  //
88  // hyp(x) = sqrt(1+x^2): Dhyp(x,y) = (x+y)/(hyp(x)+hyp(y))
89  static real Dhyp(real x, real y, real hx, real hy)
90  // hx = hyp(x)
91  { return (x + y) / (hx + hy); }
92  // sn(x) = x/sqrt(1+x^2): Dsn(x,y) = (x+y)/((sn(x)+sn(y))*(1+x^2)*(1+y^2))
93  static real Dsn(real x, real y, real sx, real sy) {
94  // sx = x/hyp(x)
95  real t = x * y;
96  return t > 0 ? (x + y) * Math::sq( (sx * sy)/t ) / (sx + sy) :
97  (x - y != 0 ? (sx - sy) / (x - y) : 1);
98  }
99  // Dlog1p(x,y) = log1p((x-y)/(1+y))/(x-y)
100  static real Dlog1p(real x, real y) {
101  real t = x - y; if (t < 0) { t = -t; y = x; }
102  return t != 0 ? Math::log1p(t / (1 + y)) / t : 1 / (1 + x);
103  }
104  // Dexp(x,y) = exp((x+y)/2) * 2*sinh((x-y)/2)/(x-y)
105  static real Dexp(real x, real y) {
106  using std::sinh; using std::exp;
107  real t = (x - y)/2;
108  return (t != 0 ? sinh(t)/t : 1) * exp((x + y)/2);
109  }
110  // Dsinh(x,y) = 2*sinh((x-y)/2)/(x-y) * cosh((x+y)/2)
111  // cosh((x+y)/2) = (c+sinh(x)*sinh(y)/c)/2
112  // c=sqrt((1+cosh(x))*(1+cosh(y)))
113  // cosh((x+y)/2) = sqrt( (sinh(x)*sinh(y) + cosh(x)*cosh(y) + 1)/2 )
114  static real Dsinh(real x, real y, real sx, real sy, real cx, real cy)
115  // sx = sinh(x), cx = cosh(x)
116  {
117  // real t = (x - y)/2, c = sqrt((1 + cx) * (1 + cy));
118  // return (t ? sinh(t)/t : real(1)) * (c + sx * sy / c) /2;
119  using std::sinh; using std::sqrt;
120  real t = (x - y)/2;
121  return (t != 0 ? sinh(t)/t : 1) * sqrt((sx * sy + cx * cy + 1) /2);
122  }
123  // Dasinh(x,y) = asinh((x-y)*(x+y)/(x*sqrt(1+y^2)+y*sqrt(1+x^2)))/(x-y)
124  // = asinh((x*sqrt(1+y^2)-y*sqrt(1+x^2)))/(x-y)
125  static real Dasinh(real x, real y, real hx, real hy) {
126  // hx = hyp(x)
127  real t = x - y;
128  return t != 0 ?
129  Math::asinh(x*y > 0 ? t * (x+y) / (x*hy + y*hx) : x*hy - y*hx) / t :
130  1/hx;
131  }
132  // Deatanhe(x,y) = eatanhe((x-y)/(1-e^2*x*y))/(x-y)
133  real Deatanhe(real x, real y) const {
134  real t = x - y, d = 1 - _e2 * x * y;
135  return t != 0 ? Math::eatanhe(t / d, _es) / t : _e2 / d;
136  }
137  void Init(real sphi1, real cphi1, real sphi2, real cphi2, real k1);
138  public:
139 
153  LambertConformalConic(real a, real f, real stdlat, real k0);
154 
170  LambertConformalConic(real a, real f, real stdlat1, real stdlat2, real k1);
171 
200  LambertConformalConic(real a, real f,
201  real sinlat1, real coslat1,
202  real sinlat2, real coslat2,
203  real k1);
204 
214  void SetScale(real lat, real k = real(1));
215 
235  void Forward(real lon0, real lat, real lon,
236  real& x, real& y, real& gamma, real& k) const;
237 
255  void Reverse(real lon0, real x, real y,
256  real& lat, real& lon, real& gamma, real& k) const;
257 
262  void Forward(real lon0, real lat, real lon,
263  real& x, real& y) const {
264  real gamma, k;
265  Forward(lon0, lat, lon, x, y, gamma, k);
266  }
267 
272  void Reverse(real lon0, real x, real y,
273  real& lat, real& lon) const {
274  real gamma, k;
275  Reverse(lon0, x, y, lat, lon, gamma, k);
276  }
277 
280 
285  Math::real MajorRadius() const { return _a; }
286 
291  Math::real Flattening() const { return _f; }
292 
300  Math::real OriginLatitude() const { return _lat0; }
301 
306  Math::real CentralScale() const { return _k0; }
308 
314  static const LambertConformalConic& Mercator();
315  };
316 
317 } // namespace GeographicLib
318 
319 #endif // GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
float real
Definition: datatypes.h:10
Scalar * y
void Reverse(real lon0, real x, real y, real &lat, real &lon) const
static const double lat
static real Dsn(real x, real y, real sx, real sy)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
Lambert conformal conic projection.
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
const double cx
Array33i a
static T asinh(T x)
Definition: Math.hpp:311
void Forward(real lon0, real lat, real lon, real &x, real &y) const
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
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
static T sq(T x)
Definition: Math.hpp:232
static real Dsinh(real x, real y, real sx, real sy, real cx, real cy)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Namespace for GeographicLib.
const double lon0
static real Dhyp(real x, real y, real hx, real hy)
static T log1p(T x)
Definition: Math.hpp:288
Header for GeographicLib::Constants class.
const double cy
static real Dasinh(real x, real y, real hx, real hy)
static const double lon
static T eatanhe(T x, T es)
Definition: Math.cpp:21
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
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:27