Rhumb.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_RHUMB_HPP)
11 #define GEOGRAPHICLIB_RHUMB_HPP 1
12 
15 
16 #if !defined(GEOGRAPHICLIB_RHUMBAREA_ORDER)
17 
21 # define GEOGRAPHICLIB_RHUMBAREA_ORDER \
22  (GEOGRAPHICLIB_PRECISION == 2 ? 6 : \
23  (GEOGRAPHICLIB_PRECISION == 1 ? 4 : 8))
24 #endif
25 
26 namespace GeographicLib {
27 
28  class RhumbLine;
29  template <class T> class PolygonAreaT;
30 
67  private:
68  typedef Math::real real;
69  friend class RhumbLine;
70  template <class T> friend class PolygonAreaT;
72  bool _exact;
74  static const int tm_maxord = GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER;
75  static const int maxpow_ = GEOGRAPHICLIB_RHUMBAREA_ORDER;
76  // _R[0] unused
77  real _R[maxpow_ + 1];
78  static real gd(real x)
79  { using std::atan; using std::sinh; return atan(sinh(x)); }
80 
81  // Use divided differences to determine (mu2 - mu1) / (psi2 - psi1)
82  // accurately
83  //
84  // Definition: Df(x,y,d) = (f(x) - f(y)) / (x - y)
85  // See:
86  // W. M. Kahan and R. J. Fateman,
87  // Symbolic computation of divided differences,
88  // SIGSAM Bull. 33(3), 7-28 (1999)
89  // https://doi.org/10.1145/334714.334716
90  // http://www.cs.berkeley.edu/~fateman/papers/divdiff.pdf
91 
92  static real Dlog(real x, real y) {
93  real t = x - y;
94  return t != 0 ? 2 * Math::atanh(t / (x + y)) / t : 1 / x;
95  }
96  // N.B., x and y are in degrees
97  static real Dtan(real x, real y) {
98  real d = x - y, tx = Math::tand(x), ty = Math::tand(y), txy = tx * ty;
99  return d != 0 ?
100  (2 * txy > -1 ? (1 + txy) * Math::tand(d) : tx - ty) /
101  (d * Math::degree()) :
102  1 + txy;
103  }
104  static real Datan(real x, real y) {
105  using std::atan;
106  real d = x - y, xy = x * y;
107  return d != 0 ?
108  (2 * xy > -1 ? atan( d / (1 + xy) ) : atan(x) - atan(y)) / d :
109  1 / (1 + xy);
110  }
111  static real Dsin(real x, real y) {
112  using std::sin; using std::cos;
113  real d = (x - y) / 2;
114  return cos((x + y)/2) * (d != 0 ? sin(d) / d : 1);
115  }
116  static real Dsinh(real x, real y) {
117  using std::sinh; using std::cosh;
118  real d = (x - y) / 2;
119  return cosh((x + y) / 2) * (d != 0 ? sinh(d) / d : 1);
120  }
121  static real Dcosh(real x, real y) {
122  using std::sinh;
123  real d = (x - y) / 2;
124  return sinh((x + y) / 2) * (d != 0 ? sinh(d) / d : 1);
125  }
126  static real Dasinh(real x, real y) {
127  real d = x - y,
128  hx = Math::hypot(real(1), x), hy = Math::hypot(real(1), y);
129  return d != 0 ? Math::asinh(x*y > 0 ? d * (x + y) / (x*hy + y*hx) :
130  x*hy - y*hx) / d :
131  1 / hx;
132  }
133  static real Dgd(real x, real y) {
134  using std::sinh;
135  return Datan(sinh(x), sinh(y)) * Dsinh(x, y);
136  }
137  // N.B., x and y are the tangents of the angles
138  static real Dgdinv(real x, real y)
139  { return Dasinh(x, y) / Datan(x, y); }
140  // Copied from LambertConformalConic...
141  // Deatanhe(x,y) = eatanhe((x-y)/(1-e^2*x*y))/(x-y)
142  real Deatanhe(real x, real y) const {
143  real t = x - y, d = 1 - _ell._e2 * x * y;
144  return t != 0 ? Math::eatanhe(t / d, _ell._es) / t : _ell._e2 / d;
145  }
146  // (E(x) - E(y)) / (x - y) -- E = incomplete elliptic integral of 2nd kind
147  real DE(real x, real y) const;
148  // (mux - muy) / (phix - phiy) using elliptic integrals
149  real DRectifying(real latx, real laty) const;
150  // (psix - psiy) / (phix - phiy)
151  real DIsometric(real latx, real laty) const;
152 
153  // (sum(c[j]*sin(2*j*x),j=1..n) - sum(c[j]*sin(2*j*x),j=1..n)) / (x - y)
154  static real SinCosSeries(bool sinp,
155  real x, real y, const real c[], int n);
156  // (mux - muy) / (chix - chiy) using Krueger's series
157  real DConformalToRectifying(real chix, real chiy) const;
158  // (chix - chiy) / (mux - muy) using Krueger's series
159  real DRectifyingToConformal(real mux, real muy) const;
160 
161  // (mux - muy) / (psix - psiy)
162  // N.B., psix and psiy are in degrees
163  real DIsometricToRectifying(real psix, real psiy) const;
164  // (psix - psiy) / (mux - muy)
165  real DRectifyingToIsometric(real mux, real muy) const;
166 
167  real MeanSinXi(real psi1, real psi2) const;
168 
169  // The following two functions (with lots of ignored arguments) mimic the
170  // interface to the corresponding Geodesic function. These are needed by
171  // PolygonAreaT.
172  void GenDirect(real lat1, real lon1, real azi12,
173  bool, real s12, unsigned outmask,
174  real& lat2, real& lon2, real&, real&, real&, real&, real&,
175  real& S12) const {
176  GenDirect(lat1, lon1, azi12, s12, outmask, lat2, lon2, S12);
177  }
178  void GenInverse(real lat1, real lon1, real lat2, real lon2,
179  unsigned outmask, real& s12, real& azi12,
180  real&, real& , real& , real& , real& S12) const {
181  GenInverse(lat1, lon1, lat2, lon2, outmask, s12, azi12, S12);
182  }
183  public:
184 
190  enum mask {
195  NONE = 0U,
200  LATITUDE = 1U<<7,
205  LONGITUDE = 1U<<8,
210  AZIMUTH = 1U<<9,
215  DISTANCE = 1U<<10,
220  AREA = 1U<<14,
225  LONG_UNROLL = 1U<<15,
230  ALL = 0x7F80U,
231  };
232 
247  Rhumb(real a, real f, bool exact = true);
248 
271  void Direct(real lat1, real lon1, real azi12, real s12,
272  real& lat2, real& lon2, real& S12) const {
273  GenDirect(lat1, lon1, azi12, s12,
274  LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
275  }
276 
280  void Direct(real lat1, real lon1, real azi12, real s12,
281  real& lat2, real& lon2) const {
282  real t;
283  GenDirect(lat1, lon1, azi12, s12, LATITUDE | LONGITUDE, lat2, lon2, t);
284  }
285 
313  void GenDirect(real lat1, real lon1, real azi12, real s12,
314  unsigned outmask, real& lat2, real& lon2, real& S12) const;
315 
338  void Inverse(real lat1, real lon1, real lat2, real lon2,
339  real& s12, real& azi12, real& S12) const {
340  GenInverse(lat1, lon1, lat2, lon2,
341  DISTANCE | AZIMUTH | AREA, s12, azi12, S12);
342  }
343 
347  void Inverse(real lat1, real lon1, real lat2, real lon2,
348  real& s12, real& azi12) const {
349  real t;
350  GenInverse(lat1, lon1, lat2, lon2, DISTANCE | AZIMUTH, s12, azi12, t);
351  }
352 
373  void GenInverse(real lat1, real lon1, real lat2, real lon2,
374  unsigned outmask,
375  real& s12, real& azi12, real& S12) const;
376 
392  RhumbLine Line(real lat1, real lon1, real azi12) const;
393 
396 
402  Math::real MajorRadius() const { return _ell.MajorRadius(); }
403 
408  Math::real Flattening() const { return _ell.Flattening(); }
409 
410  Math::real EllipsoidArea() const { return _ell.Area(); }
411 
416  static const Rhumb& WGS84();
417  };
418 
438  private:
439  typedef Math::real real;
440  friend class Rhumb;
441  const Rhumb& _rh;
442  bool _exact;
443  real _lat1, _lon1, _azi12, _salp, _calp, _mu1, _psi1, _r1;
444  RhumbLine& operator=(const RhumbLine&); // copy assignment not allowed
445  RhumbLine(const Rhumb& rh, real lat1, real lon1, real azi12,
446  bool exact);
447  public:
448 
452  enum mask {
457  NONE = Rhumb::NONE,
462  LATITUDE = Rhumb::LATITUDE,
467  LONGITUDE = Rhumb::LONGITUDE,
472  AZIMUTH = Rhumb::AZIMUTH,
477  DISTANCE = Rhumb::DISTANCE,
482  AREA = Rhumb::AREA,
487  LONG_UNROLL = Rhumb::LONG_UNROLL,
492  ALL = Rhumb::ALL,
493  };
494 
512  void Position(real s12, real& lat2, real& lon2, real& S12) const {
513  GenPosition(s12, LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
514  }
515 
520  void Position(real s12, real& lat2, real& lon2) const {
521  real t;
522  GenPosition(s12, LATITUDE | LONGITUDE, lat2, lon2, t);
523  }
524 
553  void GenPosition(real s12, unsigned outmask,
554  real& lat2, real& lon2, real& S12) const;
555 
558 
563  Math::real Latitude() const { return _lat1; }
564 
568  Math::real Longitude() const { return _lon1; }
569 
573  Math::real Azimuth() const { return _azi12; }
574 
579  Math::real MajorRadius() const { return _rh.MajorRadius(); }
580 
585  Math::real Flattening() const { return _rh.Flattening(); }
586  };
587 
588 } // namespace GeographicLib
589 
590 #endif // GEOGRAPHICLIB_RHUMB_HPP
GeographicLib::RhumbLine::_exact
bool _exact
Definition: Rhumb.hpp:442
GeographicLib::Rhumb::Direct
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:280
GeographicLib::Rhumb::GenInverse
void GenInverse(real lat1, real lon1, real lat2, real lon2, unsigned outmask, real &s12, real &azi12, real &, real &, real &, real &, real &S12) const
Definition: Rhumb.hpp:178
GeographicLib::Math::atanh
static T atanh(T x)
Definition: Math.hpp:328
GeographicLib::Rhumb::EllipsoidArea
Math::real EllipsoidArea() const
Definition: Rhumb.hpp:410
GeographicLib::Math::tand
static T tand(T x)
Definition: Math.hpp:671
GeographicLib::Rhumb::_exact
bool _exact
Definition: Rhumb.hpp:72
GeographicLib::Rhumb::MajorRadius
Math::real MajorRadius() const
Definition: Rhumb.hpp:402
GEOGRAPHICLIB_RHUMBAREA_ORDER
#define GEOGRAPHICLIB_RHUMBAREA_ORDER
Definition: Rhumb.hpp:21
atan
const EIGEN_DEVICE_FUNC AtanReturnType atan() const
Definition: ArrayCwiseUnaryOps.h:283
d
static const double d[K][N]
Definition: igam.h:11
GeographicLib::Rhumb::mask
mask
Definition: Rhumb.hpp:190
ceres::sin
Jet< T, N > sin(const Jet< T, N > &f)
Definition: jet.h:439
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::Rhumb::ALL
@ ALL
Definition: Rhumb.hpp:230
xy
Matrix< float, 2, 1 > xy
Definition: LLT_solve.cpp:7
GeographicLib::Ellipsoid::Flattening
Math::real Flattening() const
Definition: Ellipsoid.hpp:120
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
GeographicLib::Rhumb
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
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
real
float real
Definition: datatypes.h:10
GeographicLib::Rhumb::gd
static real gd(real x)
Definition: Rhumb.hpp:78
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
GeographicLib::RhumbLine::MajorRadius
Math::real MajorRadius() const
Definition: Rhumb.hpp:579
GeographicLib::Rhumb::Inverse
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12, real &S12) const
Definition: Rhumb.hpp:338
GeographicLib::Rhumb::Dsinh
static real Dsinh(real x, real y)
Definition: Rhumb.hpp:116
GeographicLib::Rhumb::Direct
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:271
ceres::cos
Jet< T, N > cos(const Jet< T, N > &f)
Definition: jet.h:426
cosh
const EIGEN_DEVICE_FUNC CoshReturnType cosh() const
Definition: ArrayCwiseUnaryOps.h:353
GeographicLib::Ellipsoid::MajorRadius
Math::real MajorRadius() const
Definition: Ellipsoid.hpp:80
n
int n
Definition: BiCGSTAB_simple.cpp:1
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER
#define GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER
Definition: TransverseMercator.hpp:20
GeographicLib::Math::degree
static T degree()
Definition: Math.hpp:216
GeographicLib::PolygonAreaT
Polygon areas.
Definition: PolygonArea.hpp:65
GeographicLib::Rhumb::AREA
@ AREA
Definition: Rhumb.hpp:220
GeographicLib::Rhumb::Dgdinv
static real Dgdinv(real x, real y)
Definition: Rhumb.hpp:138
GeographicLib::RhumbLine::Flattening
Math::real Flattening() const
Definition: Rhumb.hpp:585
GeographicLib::Rhumb::NONE
@ NONE
Definition: Rhumb.hpp:195
GeographicLib::Rhumb::Inverse
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12) const
Definition: Rhumb.hpp:347
GeographicLib::Rhumb::LATITUDE
@ LATITUDE
Definition: Rhumb.hpp:200
GeographicLib::RhumbLine::mask
mask
Definition: Rhumb.hpp:452
GeographicLib::Ellipsoid::_es
real _es
Definition: Ellipsoid.hpp:44
GeographicLib::Rhumb::Dcosh
static real Dcosh(real x, real y)
Definition: Rhumb.hpp:121
GeographicLib::Rhumb::AZIMUTH
@ AZIMUTH
Definition: Rhumb.hpp:210
GeographicLib::RhumbLine::Latitude
Math::real Latitude() const
Definition: Rhumb.hpp:563
GeographicLib::Math::asinh
static T asinh(T x)
Definition: Math.hpp:311
GeographicLib::Rhumb::GenDirect
void GenDirect(real lat1, real lon1, real azi12, bool, real s12, unsigned outmask, real &lat2, real &lon2, real &, real &, real &, real &, real &, real &S12) const
Definition: Rhumb.hpp:172
Constants.hpp
Header for GeographicLib::Constants class.
GeographicLib::Ellipsoid::_e2
real _e2
Definition: Ellipsoid.hpp:44
GeographicLib::RhumbLine
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:437
y
Scalar * y
Definition: level1_cplx_impl.h:124
GeographicLib::Rhumb::LONGITUDE
@ LONGITUDE
Definition: Rhumb.hpp:205
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
GeographicLib::RhumbLine::Position
void Position(real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:520
GeographicLib::Rhumb::Dsin
static real Dsin(real x, real y)
Definition: Rhumb.hpp:111
GeographicLib::Rhumb::real
Math::real real
Definition: Rhumb.hpp:68
GeographicLib::Rhumb::DISTANCE
@ DISTANCE
Definition: Rhumb.hpp:215
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
GeographicLib::RhumbLine::Longitude
Math::real Longitude() const
Definition: Rhumb.hpp:568
Ellipsoid.hpp
Header for GeographicLib::Ellipsoid class.
GeographicLib::Rhumb::Flattening
Math::real Flattening() const
Definition: Rhumb.hpp:408
GeographicLib::Rhumb::Dgd
static real Dgd(real x, real y)
Definition: Rhumb.hpp:133
GeographicLib::Rhumb::Dtan
static real Dtan(real x, real y)
Definition: Rhumb.hpp:97
GeographicLib::Rhumb::Dasinh
static real Dasinh(real x, real y)
Definition: Rhumb.hpp:126
GeographicLib::RhumbLine::_rh
const Rhumb & _rh
Definition: Rhumb.hpp:441
GeographicLib::Rhumb::Deatanhe
real Deatanhe(real x, real y) const
Definition: Rhumb.hpp:142
U
@ U
Definition: testDecisionTree.cpp:342
GeographicLib::RhumbLine::Position
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:512
GeographicLib::RhumbLine::real
Math::real real
Definition: Rhumb.hpp:439
GeographicLib::Rhumb::LONG_UNROLL
@ LONG_UNROLL
Definition: Rhumb.hpp:225
GeographicLib::Math::eatanhe
static T eatanhe(T x, T es)
Definition: Math.cpp:21
GeographicLib::Rhumb::_ell
Ellipsoid _ell
Definition: Rhumb.hpp:71
sinh
const EIGEN_DEVICE_FUNC SinhReturnType sinh() const
Definition: ArrayCwiseUnaryOps.h:339
GeographicLib::Rhumb::Datan
static real Datan(real x, real y)
Definition: Rhumb.hpp:104
align_3::t
Point2 t(10, 10)
GeographicLib::RhumbLine::_salp
real _salp
Definition: Rhumb.hpp:443
GeographicLib::Ellipsoid
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
GeographicLib::Math::hypot
static T hypot(T x, T y)
Definition: Math.hpp:243
real
Definition: main.h:100
GeographicLib::Ellipsoid::Area
Math::real Area() const
Definition: src/Ellipsoid.cpp:40
GeographicLib::Rhumb::_c2
real _c2
Definition: Rhumb.hpp:73
GeographicLib::RhumbLine::Azimuth
Math::real Azimuth() const
Definition: Rhumb.hpp:573
GeographicLib::Rhumb::Dlog
static real Dlog(real x, real y)
Definition: Rhumb.hpp:92


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:08