GeographicLib  1.40
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Rhumb.hpp
Go to the documentation of this file.
1 /**
2  * \file Rhumb.hpp
3  * \brief Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes
4  *
5  * Copyright (c) Charles Karney (2012) <charles@karney.com> and licensed under
6  * the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
10 #if !defined(GEOGRAPHICLIB_RHUMB_HPP)
11 #define GEOGRAPHICLIB_RHUMB_HPP 1
12 
15 
16 #if !defined(GEOGRAPHICLIB_RHUMBAREA_ORDER)
17 /**
18  * The order of the series approximation used in rhumb area calculations.
19  * GEOGRAPHICLIB_RHUMBAREA_ORDER can be set to any integer in [4, 8].
20  **********************************************************************/
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 
31  /**
32  * \brief Solve of the direct and inverse rhumb problems.
33  *
34  * The path of constant azimuth between two points on a ellipsoid at (\e
35  * lat1, \e lon1) and (\e lat2, \e lon2) is called the rhumb line (also
36  * called the loxodrome). Its length is \e s12 and its azimuth is \e azi12.
37  * (The azimuth is the heading measured clockwise from north.)
38  *
39  * Given \e lat1, \e lon1, \e azi12, and \e s12, we can determine \e lat2,
40  * and \e lon2. This is the \e direct rhumb problem and its solution is
41  * given by the function Rhumb::Direct.
42  *
43  * Given \e lat1, \e lon1, \e lat2, and \e lon2, we can determine \e azi12
44  * and \e s12. This is the \e inverse rhumb problem, whose solution is given
45  * by Rhumb::Inverse. This finds the shortest such rhumb line, i.e., the one
46  * that wraps no more than half way around the earth. If the end points are
47  * on opposite meridians, there are two shortest rhumb lines and the
48  * east-going one is chosen.
49  *
50  * These routines also optionally calculate the area under the rhumb line, \e
51  * S12. This is the area, measured counter-clockwise, of the rhumb line
52  * quadrilateral with corners (<i>lat1</i>,<i>lon1</i>), (0,<i>lon1</i>),
53  * (0,<i>lon2</i>), and (<i>lat2</i>,<i>lon2</i>).
54  *
55  * Note that rhumb lines may be appreciably longer (up to 50%) than the
56  * corresponding Geodesic. For example the distance between London Heathrow
57  * and Tokyo Narita via the rhumb line is 11400 km which is 18% longer than
58  * the geodesic distance 9600 km.
59  *
60  * For more information on rhumb lines see \ref rhumb.
61  *
62  * Example of use:
63  * \include example-Rhumb.cpp
64  **********************************************************************/
65 
67  private:
68  typedef Math::real real;
69  friend class RhumbLine;
70  template <class T> friend class PolygonAreaT;
71  Ellipsoid _ell;
72  bool _exact;
73  real _c2;
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 inline real overflow() {
79  // Overflow value s.t. atan(overflow_) = pi/2
80  static const real
81  overflow = 1 / Math::sq(std::numeric_limits<real>::epsilon());
82  return overflow;
83  }
84  static inline real tano(real x) {
85  using std::abs; using std::tan;
86  return
87  2 * abs(x) == Math::pi() ? (x < 0 ? - overflow() : overflow()) :
88  tan(x);
89  }
90  static inline real gd(real x)
91  { using std::atan; using std::sinh; return atan(sinh(x)); }
92 
93  // Use divided differences to determine (mu2 - mu1) / (psi2 - psi1)
94  // accurately
95  //
96  // Definition: Df(x,y,d) = (f(x) - f(y)) / (x - y)
97  // See:
98  // W. M. Kahan and R. J. Fateman,
99  // Symbolic computation of divided differences,
100  // SIGSAM Bull. 33(3), 7-28 (1999)
101  // https://dx.doi.org/10.1145/334714.334716
102  // http://www.cs.berkeley.edu/~fateman/papers/divdiff.pdf
103 
104  static inline real Dlog(real x, real y) {
105  real t = x - y;
106  return t ? 2 * Math::atanh(t / (x + y)) / t : 1 / x;
107  }
108  static inline real Dtan(real x, real y) {
109  real d = x - y, tx = tano(x), ty = tano(y), txy = tx * ty;
110  return d ? (2 * txy > -1 ? (1 + txy) * tano(d) : tx - ty) / d :
111  1 + txy;
112  }
113  static inline real Datan(real x, real y) {
114  using std::atan;
115  real d = x - y, xy = x * y;
116  return d ? (2 * xy > -1 ? atan( d / (1 + xy) ) : atan(x) - atan(y)) / d :
117  1 / (1 + xy);
118  }
119  static inline real Dsin(real x, real y) {
120  using std::sin; using std::cos;
121  real d = (x - y) / 2;
122  return cos((x + y)/2) * (d ? sin(d) / d : 1);
123  }
124  static inline real Dsinh(real x, real y) {
125  using std::sinh; using std::cosh;
126  real d = (x - y) / 2;
127  return cosh((x + y) / 2) * (d ? sinh(d) / d : 1);
128  }
129  static inline real Dcosh(real x, real y) {
130  using std::sinh;
131  real d = (x - y) / 2;
132  return sinh((x + y) / 2) * (d ? sinh(d) / d : 1);
133  }
134  static inline real Dasinh(real x, real y) {
135  real d = x - y,
136  hx = Math::hypot(real(1), x), hy = Math::hypot(real(1), y);
137  return d ? Math::asinh(x*y > 0 ? d * (x + y) / (x*hy + y*hx) :
138  x*hy - y*hx) / d :
139  1 / hx;
140  }
141  static inline real Dgd(real x, real y) {
142  using std::sinh;
143  return Datan(sinh(x), sinh(y)) * Dsinh(x, y);
144  }
145  static inline real Dgdinv(real x, real y) {
146  return Dasinh(tano(x), tano(y)) * Dtan(x, y);
147  }
148  // Copied from LambertConformalConic...
149  // e * atanh(e * x) = log( ((1 + e*x)/(1 - e*x))^(e/2) ) if f >= 0
150  // - sqrt(-e2) * atan( sqrt(-e2) * x) if f < 0
151  inline real eatanhe(real x) const {
152  using std::atan;
153  return _ell._f >= 0 ? _ell._e * Math::atanh(_ell._e * x) :
154  - _ell._e * atan(_ell._e * x);
155  }
156  // Copied from LambertConformalConic...
157  // Deatanhe(x,y) = eatanhe((x-y)/(1-e^2*x*y))/(x-y)
158  inline real Deatanhe(real x, real y) const {
159  real t = x - y, d = 1 - _ell._e2 * x * y;
160  return t ? eatanhe(t / d) / t : _ell._e2 / d;
161  }
162  // (E(x) - E(y)) / (x - y) -- E = incomplete elliptic integral of 2nd kind
163  real DE(real x, real y) const;
164  // (mux - muy) / (phix - phiy) using elliptic integrals
165  real DRectifying(real latx, real laty) const;
166  // (psix - psiy) / (phix - phiy)
167  real DIsometric(real latx, real laty) const;
168 
169  // (sum(c[j]*sin(2*j*x),j=1..n) - sum(c[j]*sin(2*j*x),j=1..n)) / (x - y)
170  static real SinCosSeries(bool sinp,
171  real x, real y, const real c[], int n);
172  // (mux - muy) / (chix - chiy) using Krueger's series
173  real DConformalToRectifying(real chix, real chiy) const;
174  // (chix - chiy) / (mux - muy) using Krueger's series
175  real DRectifyingToConformal(real mux, real muy) const;
176 
177  // (mux - muy) / (psix - psiy)
178  real DIsometricToRectifying(real psix, real psiy) const;
179  // (psix - psiy) / (mux - muy)
180  real DRectifyingToIsometric(real mux, real muy) const;
181 
182  real MeanSinXi(real psi1, real psi2) const;
183 
184  // The following two functions (with lots of ignored arguments) mimic the
185  // interface to the corresponding Geodesic function. These are needed by
186  // PolygonAreaT.
187  void GenDirect(real lat1, real lon1, real azi12,
188  bool, real s12, unsigned outmask,
189  real& lat2, real& lon2, real&, real&, real&, real&, real&,
190  real& S12) const {
191  GenDirect(lat1, lon1, azi12, s12, outmask, lat2, lon2, S12);
192  }
193  void GenInverse(real lat1, real lon1, real lat2, real lon2,
194  unsigned outmask, real& s12, real& azi12,
195  real&, real& , real& , real& , real& S12) const {
196  GenInverse(lat1, lon1, lat2, lon2, outmask, s12, azi12, S12);
197  }
198  public:
199 
200  /**
201  * Bit masks for what calculations to do. They specify which results to
202  * return in the general routines Rhumb::GenDirect and Rhumb::GenInverse
203  * routines. RhumbLine::mask is a duplication of this enum.
204  **********************************************************************/
205  enum mask {
206  /**
207  * No output.
208  * @hideinitializer
209  **********************************************************************/
210  NONE = 0U,
211  /**
212  * Calculate latitude \e lat2.
213  * @hideinitializer
214  **********************************************************************/
215  LATITUDE = 1U<<7,
216  /**
217  * Calculate longitude \e lon2.
218  * @hideinitializer
219  **********************************************************************/
220  LONGITUDE = 1U<<8,
221  /**
222  * Calculate azimuth \e azi12.
223  * @hideinitializer
224  **********************************************************************/
225  AZIMUTH = 1U<<9,
226  /**
227  * Calculate distance \e s12.
228  * @hideinitializer
229  **********************************************************************/
230  DISTANCE = 1U<<10,
231  /**
232  * Calculate area \e S12.
233  * @hideinitializer
234  **********************************************************************/
235  AREA = 1U<<14,
236  /**
237  * Do not wrap the \e lon2 in the direct calculation.
238  * @hideinitializer
239  **********************************************************************/
240  LONG_NOWRAP = 1U<<15,
241  /**
242  * Calculate everything. (LONG_NOWRAP is not included in this mask.)
243  * @hideinitializer
244  **********************************************************************/
245  ALL = 0x7F80U,
246  };
247 
248  /**
249  * Constructor for a ellipsoid with
250  *
251  * @param[in] a equatorial radius (meters).
252  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
253  * Negative \e f gives a prolate ellipsoid. If \e f &gt; 1, set
254  * flattening to 1/\e f.
255  * @param[in] exact if true (the default) use an addition theorem for
256  * elliptic integrals to compute divided differences; otherwise use
257  * series expansion (accurate for |<i>f</i>| < 0.01).
258  * @exception GeographicErr if \e a or (1 &minus; \e f) \e a is not
259  * positive.
260  *
261  * See \ref rhumb, for a detailed description of the \e exact parameter.
262  **********************************************************************/
263  Rhumb(real a, real f, bool exact = true);
264 
265  /**
266  * Solve the direct rhumb problem returning also the area.
267  *
268  * @param[in] lat1 latitude of point 1 (degrees).
269  * @param[in] lon1 longitude of point 1 (degrees).
270  * @param[in] azi12 azimuth of the rhumb line (degrees).
271  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
272  * negative.
273  * @param[out] lat2 latitude of point 2 (degrees).
274  * @param[out] lon2 longitude of point 2 (degrees).
275  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
276  *
277  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]; \e lon1 and \e
278  * azi12 should be in the range [&minus;540&deg;, 540&deg;). The value of
279  * \e lon2 returned is in the range [&minus;180&deg;, 180&deg;).
280  *
281  * If point 1 is a pole, the cosine of its latitude is taken to be
282  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
283  * position, which is extremely close to the actual pole, allows the
284  * calculation to be carried out in finite terms. If \e s12 is large
285  * enough that the rhumb line crosses a pole, the longitude of point 2
286  * is indeterminate (a NaN is returned for \e lon2 and \e S12).
287  **********************************************************************/
288  void Direct(real lat1, real lon1, real azi12, real s12,
289  real& lat2, real& lon2, real& S12) const {
290  GenDirect(lat1, lon1, azi12, s12,
291  LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
292  }
293 
294  /**
295  * Solve the direct rhumb problem without the area.
296  **********************************************************************/
297  void Direct(real lat1, real lon1, real azi12, real s12,
298  real& lat2, real& lon2) const {
299  real t;
300  GenDirect(lat1, lon1, azi12, s12, LATITUDE | LONGITUDE, lat2, lon2, t);
301  }
302 
303  /**
304  * The general direct rhumb problem. Rhumb::Direct is defined in terms
305  * of this function.
306  *
307  * @param[in] lat1 latitude of point 1 (degrees).
308  * @param[in] lon1 longitude of point 1 (degrees).
309  * @param[in] azi12 azimuth of the rhumb line (degrees).
310  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
311  * negative.
312  * @param[in] outmask a bitor'ed combination of Rhumb::mask values
313  * specifying which of the following parameters should be set.
314  * @param[out] lat2 latitude of point 2 (degrees).
315  * @param[out] lon2 longitude of point 2 (degrees).
316  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
317  *
318  * The Rhumb::mask values possible for \e outmask are
319  * - \e outmask |= Rhumb::LATITUDE for the latitude \e lat2;
320  * - \e outmask |= Rhumb::LONGITUDE for the latitude \e lon2;
321  * - \e outmask |= Rhumb::AREA for the area \e S12;
322  * - \e outmask |= Rhumb::ALL for all of the above;
323  * - \e outmask |= Rhumb::LONG_NOWRAP stops the returned value of \e
324  * lon2 being wrapped into the range [&minus;180&deg;, 180&deg;).
325  * .
326  * With the LONG_NOWRAP bit set, the quantity \e lon2 &minus; \e lon1
327  * indicates how many times the rhumb line wrapped around the ellipsoid.
328  * Because \e lon2 might be outside the normal allowed range for
329  * longitudes, [&minus;540&deg;, 540&deg;), be sure to normalize it with
330  * Math::AngNormalize2 before using it in other GeographicLib calls.
331  **********************************************************************/
332  void GenDirect(real lat1, real lon1, real azi12, real s12, unsigned outmask,
333  real& lat2, real& lon2, real& S12) const;
334 
335  /**
336  * Solve the inverse rhumb problem returning also the area.
337  *
338  * @param[in] lat1 latitude of point 1 (degrees).
339  * @param[in] lon1 longitude of point 1 (degrees).
340  * @param[in] lat2 latitude of point 2 (degrees).
341  * @param[in] lon2 longitude of point 2 (degrees).
342  * @param[out] s12 rhumb distance between point 1 and point 2 (meters).
343  * @param[out] azi12 azimuth of the rhumb line (degrees).
344  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
345  *
346  * The shortest rhumb line is found. If the end points are on opposite
347  * meridians, there are two shortest rhumb lines and the east-going one is
348  * chosen. \e lat1 and \e lat2 should be in the range [&minus;90&deg;,
349  * 90&deg;]; \e lon1 and \e lon2 should be in the range [&minus;540&deg;,
350  * 540&deg;). The value of \e azi12 returned is in the range
351  * [&minus;180&deg;, 180&deg;).
352  *
353  * If either point is a pole, the cosine of its latitude is taken to be
354  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
355  * position, which is extremely close to the actual pole, allows the
356  * calculation to be carried out in finite terms.
357  **********************************************************************/
358  void Inverse(real lat1, real lon1, real lat2, real lon2,
359  real& s12, real& azi12, real& S12) const {
360  GenInverse(lat1, lon1, lat2, lon2,
361  DISTANCE | AZIMUTH | AREA, s12, azi12, S12);
362  }
363 
364  /**
365  * Solve the inverse rhumb problem without the area.
366  **********************************************************************/
367  void Inverse(real lat1, real lon1, real lat2, real lon2,
368  real& s12, real& azi12) const {
369  real t;
370  GenInverse(lat1, lon1, lat2, lon2, DISTANCE | AZIMUTH, s12, azi12, t);
371  }
372 
373  /**
374  * The general inverse rhumb problem. Rhumb::Inverse is defined in terms
375  * of this function.
376  *
377  * @param[in] lat1 latitude of point 1 (degrees).
378  * @param[in] lon1 longitude of point 1 (degrees).
379  * @param[in] lat2 latitude of point 2 (degrees).
380  * @param[in] lon2 longitude of point 2 (degrees).
381  * @param[in] outmask a bitor'ed combination of Rhumb::mask values
382  * specifying which of the following parameters should be set.
383  * @param[out] s12 rhumb distance between point 1 and point 2 (meters).
384  * @param[out] azi12 azimuth of the rhumb line (degrees).
385  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
386  *
387  * The Rhumb::mask values possible for \e outmask are
388  * - \e outmask |= Rhumb::DISTANCE for the latitude \e s12;
389  * - \e outmask |= Rhumb::AZIMUTH for the latitude \e azi12;
390  * - \e outmask |= Rhumb::AREA for the area \e S12;
391  * - \e outmask |= Rhumb::ALL for all of the above;
392  **********************************************************************/
393  void GenInverse(real lat1, real lon1, real lat2, real lon2,
394  unsigned outmask,
395  real& s12, real& azi12, real& S12) const;
396 
397  /**
398  * Set up to compute several points on a single rhumb line.
399  *
400  * @param[in] lat1 latitude of point 1 (degrees).
401  * @param[in] lon1 longitude of point 1 (degrees).
402  * @param[in] azi12 azimuth of the rhumb line (degrees).
403  * @return a RhumbLine object.
404  *
405  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]; \e lon1 and \e
406  * azi12 should be in the range [&minus;540&deg;, 540&deg;).
407  *
408  * If point 1 is a pole, the cosine of its latitude is taken to be
409  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
410  * position, which is extremely close to the actual pole, allows the
411  * calculation to be carried out in finite terms.
412  **********************************************************************/
413  RhumbLine Line(real lat1, real lon1, real azi12) const;
414 
415  /** \name Inspector functions.
416  **********************************************************************/
417  ///@{
418 
419  /**
420  * @return \e a the equatorial radius of the ellipsoid (meters). This is
421  * the value used in the constructor.
422  **********************************************************************/
423  Math::real MajorRadius() const { return _ell.MajorRadius(); }
424 
425  /**
426  * @return \e f the flattening of the ellipsoid. This is the
427  * value used in the constructor.
428  **********************************************************************/
429  Math::real Flattening() const { return _ell.Flattening(); }
430 
431  Math::real EllipsoidArea() const { return _ell.Area(); }
432 
433  /**
434  * A global instantiation of Rhumb with the parameters for the WGS84
435  * ellipsoid.
436  **********************************************************************/
437  static const Rhumb& WGS84();
438  };
439 
440  /**
441  * \brief Find a sequence of points on a single rhumb line.
442  *
443  * RhumbLine facilitates the determination of a series of points on a single
444  * rhumb line. The starting point (\e lat1, \e lon1) and the azimuth \e
445  * azi12 are specified in the call to Rhumb::Line which returns a RhumbLine
446  * object. RhumbLine.Position returns the location of point 2 (and,
447  * optionally, the corresponding area, \e S12) a distance \e s12 along the
448  * rhumb line.
449  *
450  * There is no public constructor for this class. (Use Rhumb::Line to create
451  * an instance.) The Rhumb object used to create a RhumbLine must stay in
452  * scope as long as the RhumbLine.
453  *
454  * Example of use:
455  * \include example-RhumbLine.cpp
456  **********************************************************************/
457 
459  private:
460  typedef Math::real real;
461  friend class Rhumb;
462  const Rhumb& _rh;
463  bool _exact;
464  real _lat1, _lon1, _azi12, _salp, _calp, _mu1, _psi1, _r1;
465  RhumbLine& operator=(const RhumbLine&); // copy assignment not allowed
466  RhumbLine(const Rhumb& rh, real lat1, real lon1, real azi12,
467  bool exact);
468  public:
469 
470  enum mask {
471  /**
472  * No output.
473  * @hideinitializer
474  **********************************************************************/
475  NONE = Rhumb::NONE,
476  /**
477  * Calculate latitude \e lat2.
478  * @hideinitializer
479  **********************************************************************/
480  LATITUDE = Rhumb::LATITUDE,
481  /**
482  * Calculate longitude \e lon2.
483  * @hideinitializer
484  **********************************************************************/
485  LONGITUDE = Rhumb::LONGITUDE,
486  /**
487  * Calculate azimuth \e azi12.
488  * @hideinitializer
489  **********************************************************************/
490  AZIMUTH = Rhumb::AZIMUTH,
491  /**
492  * Calculate distance \e s12.
493  * @hideinitializer
494  **********************************************************************/
495  DISTANCE = Rhumb::DISTANCE,
496  /**
497  * Calculate area \e S12.
498  * @hideinitializer
499  **********************************************************************/
500  AREA = Rhumb::AREA,
501  /**
502  * Do wrap the \e lon2 in the direct calculation.
503  * @hideinitializer
504  **********************************************************************/
505  LONG_NOWRAP = Rhumb::LONG_NOWRAP,
506  /**
507  * Calculate everything. (LONG_NOWRAP is not included in this mask.)
508  * @hideinitializer
509  **********************************************************************/
510  ALL = Rhumb::ALL,
511  };
512 
513  /**
514  * Compute the position of point 2 which is a distance \e s12 (meters) from
515  * point 1. The area is also computed.
516  *
517  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
518  * negative.
519  * @param[out] lat2 latitude of point 2 (degrees).
520  * @param[out] lon2 longitude of point 2 (degrees).
521  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
522  *
523  * The value of \e lon2 returned is in the range [&minus;180&deg;,
524  * 180&deg;).
525  *
526  * If \e s12 is large enough that the rhumb line crosses a pole, the
527  * longitude of point 2 is indeterminate (a NaN is returned for \e lon2 and
528  * \e S12).
529  **********************************************************************/
530  void Position(real s12, real& lat2, real& lon2, real& S12) const {
531  GenPosition(s12, LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
532  }
533 
534  /**
535  * Compute the position of point 2 which is a distance \e s12 (meters) from
536  * point 1. The area is not computed.
537  **********************************************************************/
538  void Position(real s12, real& lat2, real& lon2) const {
539  real t;
540  GenPosition(s12, LATITUDE | LONGITUDE, lat2, lon2, t);
541  }
542 
543  /**
544  * The general position routine. RhumbLine::Position is defined in term so
545  * this function.
546  *
547  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
548  * negative.
549  * @param[in] outmask a bitor'ed combination of Rhumb::mask values
550  * specifying which of the following parameters should be set.
551  * @param[out] lat2 latitude of point 2 (degrees).
552  * @param[out] lon2 longitude of point 2 (degrees).
553  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
554  *
555  * The Rhumb::mask values possible for \e outmask are
556  * - \e outmask |= Rhumb::LATITUDE for the latitude \e lat2;
557  * - \e outmask |= Rhumb::LONGITUDE for the latitude \e lon2;
558  * - \e outmask |= Rhumb::AREA for the area \e S12;
559  * - \e outmask |= Rhumb::ALL for all of the above;
560  * - \e outmask |= Rhumb::LONG_NOWRAP stops the returned value of \e
561  * lon2 being wrapped into the range [&minus;180&deg;, 180&deg;).
562  * .
563  * With the LONG_NOWRAP bit set, the quantity \e lon2 &minus; \e lon1
564  * indicates how many times the rhumb line wrapped around the ellipsoid.
565  * Because \e lon2 might be outside the normal allowed range for
566  * longitudes, [&minus;540&deg;, 540&deg;), be sure to normalize it with
567  * Math::AngNormalize2 before using it in other GeographicLib calls.
568  *
569  * If \e s12 is large enough that the rhumb line crosses a pole, the
570  * longitude of point 2 is indeterminate (a NaN is returned for \e lon2 and
571  * \e S12).
572  **********************************************************************/
573  void GenPosition(real s12, unsigned outmask,
574  real& lat2, real& lon2, real& S12) const;
575 
576  /** \name Inspector functions
577  **********************************************************************/
578  ///@{
579 
580  /**
581  * @return \e lat1 the latitude of point 1 (degrees).
582  **********************************************************************/
583  Math::real Latitude() const { return _lat1; }
584 
585  /**
586  * @return \e lon1 the longitude of point 1 (degrees).
587  **********************************************************************/
588  Math::real Longitude() const { return _lon1; }
589 
590  /**
591  * @return \e azi12 the azimuth of the rhumb line (degrees).
592  **********************************************************************/
593  Math::real Azimuth() const { return _azi12; }
594 
595  /**
596  * @return \e a the equatorial radius of the ellipsoid (meters). This is
597  * the value inherited from the Rhumb object used in the constructor.
598  **********************************************************************/
599  Math::real MajorRadius() const { return _rh.MajorRadius(); }
600 
601  /**
602  * @return \e f the flattening of the ellipsoid. This is the value
603  * inherited from the Rhumb object used in the constructor.
604  **********************************************************************/
605  Math::real Flattening() const { return _rh.Flattening(); }
606  };
607 
608 } // namespace GeographicLib
609 
610 #endif // GEOGRAPHICLIB_RHUMB_HPP
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12, real &S12) const
Definition: Rhumb.hpp:358
static T pi()
Definition: Math.hpp:214
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:69
GeographicLib::Math::real real
Definition: GeodSolve.cpp:32
void Position(real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:538
#define GEOGRAPHICLIB_RHUMBAREA_ORDER
Definition: Rhumb.hpp:21
static T atanh(T x)
Definition: Math.hpp:340
Math::real Latitude() const
Definition: Rhumb.hpp:583
Math::real MajorRadius() const
Definition: Rhumb.hpp:423
static T asinh(T x)
Definition: Math.hpp:323
Math::real EllipsoidArea() const
Definition: Rhumb.hpp:431
static T hypot(T x, T y)
Definition: Math.hpp:255
static T sq(T x)
Definition: Math.hpp:244
Math::real MajorRadius() const
Definition: Ellipsoid.hpp:91
Math::real Azimuth() const
Definition: Rhumb.hpp:593
Math::real Longitude() const
Definition: Rhumb.hpp:588
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
#define GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER
Header for GeographicLib::Ellipsoid class.
Math::real Flattening() const
Definition: Rhumb.hpp:429
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
Math::real MajorRadius() const
Definition: Rhumb.hpp:599
Math::real Area() const
Definition: Ellipsoid.cpp:40
Header for GeographicLib::Constants class.
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12) const
Definition: Rhumb.hpp:367
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:458
Math::real Flattening() const
Definition: Rhumb.hpp:605
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:297
Math::real Flattening() const
Definition: Ellipsoid.hpp:131
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:288
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:530