GeographicLib  2.1.1
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 (2014-2022) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * https://geographiclib.sourceforge.io/
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 an 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  // _rR[0] unused
77  real _rR[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(2), 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  using std::sqrt; using std::asinh;
94  real t = x - y;
95  // Change
96  //
97  // atanh(t / (x + y))
98  //
99  // to
100  //
101  // asinh(t / (2 * sqrt(x*y)))
102  //
103  // to avoid taking atanh(1) when x is large and y is 1. N.B., this
104  // routine is invoked with positive x and y, so no need to guard against
105  // taking the sqrt of a negative quantity. This fixes bogus results for
106  // the area being returning when an endpoint is at a pole.
107  return t != 0 ? 2 * asinh(t / (2 * sqrt(x*y))) / t : 1 / x;
108  }
109  // N.B., x and y are in degrees
110  static real Dtan(real x, real y) {
111  real d = x - y, tx = Math::tand(x), ty = Math::tand(y), txy = tx * ty;
112  return d != 0 ?
113  (2 * txy > -1 ? (1 + txy) * Math::tand(d) : tx - ty) /
114  (d * Math::degree()) :
115  1 + txy;
116  }
117  static real Datan(real x, real y) {
118  using std::atan;
119  real d = x - y, xy = x * y;
120  return d != 0 ?
121  (2 * xy > -1 ? atan( d / (1 + xy) ) : atan(x) - atan(y)) / d :
122  1 / (1 + xy);
123  }
124  static real Dsin(real x, real y) {
125  using std::sin; using std::cos;
126  real d = (x - y) / 2;
127  return cos((x + y)/2) * (d != 0 ? sin(d) / d : 1);
128  }
129  static real Dsinh(real x, real y) {
130  using std::sinh; using std::cosh;
131  real d = (x - y) / 2;
132  return cosh((x + y) / 2) * (d != 0 ? sinh(d) / d : 1);
133  }
134  static real Dcosh(real x, real y) {
135  using std::sinh;
136  real d = (x - y) / 2;
137  return sinh((x + y) / 2) * (d != 0 ? sinh(d) / d : 1);
138  }
139  static real Dasinh(real x, real y) {
140  using std::asinh; using std::hypot;
141  real d = x - y,
142  hx = hypot(real(1), x), hy = hypot(real(1), y);
143  return d != 0 ?
144  asinh(x*y > 0 ? d * (x + y) / (x*hy + y*hx) : x*hy - y*hx) / d :
145  1 / hx;
146  }
147  static real Dgd(real x, real y) {
148  using std::sinh;
149  return Datan(sinh(x), sinh(y)) * Dsinh(x, y);
150  }
151  // N.B., x and y are the tangents of the angles
152  static real Dgdinv(real x, real y)
153  { return Dasinh(x, y) / Datan(x, y); }
154  // Copied from LambertConformalConic...
155  // Deatanhe(x,y) = eatanhe((x-y)/(1-e^2*x*y))/(x-y)
156  real Deatanhe(real x, real y) const {
157  real t = x - y, d = 1 - _ell._e2 * x * y;
158  return t != 0 ? Math::eatanhe(t / d, _ell._es) / t : _ell._e2 / d;
159  }
160  // (E(x) - E(y)) / (x - y) -- E = incomplete elliptic integral of 2nd kind
161  real DE(real x, real y) const;
162  // (mux - muy) / (phix - phiy) using elliptic integrals
163  real DRectifying(real latx, real laty) const;
164  // (psix - psiy) / (phix - phiy)
165  real DIsometric(real latx, real laty) const;
166 
167  // (sum(c[j]*sin(2*j*x),j=1..n) - sum(c[j]*sin(2*j*x),j=1..n)) / (x - y)
168  static real SinCosSeries(bool sinp,
169  real x, real y, const real c[], int n);
170  // (mux - muy) / (chix - chiy) using Krueger's series
171  real DConformalToRectifying(real chix, real chiy) const;
172  // (chix - chiy) / (mux - muy) using Krueger's series
173  real DRectifyingToConformal(real mux, real muy) const;
174 
175  // (mux - muy) / (psix - psiy)
176  // N.B., psix and psiy are in degrees
177  real DIsometricToRectifying(real psix, real psiy) const;
178  // (psix - psiy) / (mux - muy)
179  real DRectifyingToIsometric(real mux, real muy) const;
180 
181  real MeanSinXi(real psi1, real psi2) const;
182 
183  // The following two functions (with lots of ignored arguments) mimic the
184  // interface to the corresponding Geodesic function. These are needed by
185  // PolygonAreaT.
186  void GenDirect(real lat1, real lon1, real azi12,
187  bool, real s12, unsigned outmask,
188  real& lat2, real& lon2, real&, real&, real&, real&, real&,
189  real& S12) const {
190  GenDirect(lat1, lon1, azi12, s12, outmask, lat2, lon2, S12);
191  }
192  void GenInverse(real lat1, real lon1, real lat2, real lon2,
193  unsigned outmask, real& s12, real& azi12,
194  real&, real& , real& , real& , real& S12) const {
195  GenInverse(lat1, lon1, lat2, lon2, outmask, s12, azi12, S12);
196  }
197  public:
198 
199  /**
200  * Bit masks for what calculations to do. They specify which results to
201  * return in the general routines Rhumb::GenDirect and Rhumb::GenInverse
202  * routines. RhumbLine::mask is a duplication of this enum.
203  **********************************************************************/
204  enum mask {
205  /**
206  * No output.
207  * @hideinitializer
208  **********************************************************************/
209  NONE = 0U,
210  /**
211  * Calculate latitude \e lat2.
212  * @hideinitializer
213  **********************************************************************/
214  LATITUDE = 1U<<7,
215  /**
216  * Calculate longitude \e lon2.
217  * @hideinitializer
218  **********************************************************************/
219  LONGITUDE = 1U<<8,
220  /**
221  * Calculate azimuth \e azi12.
222  * @hideinitializer
223  **********************************************************************/
224  AZIMUTH = 1U<<9,
225  /**
226  * Calculate distance \e s12.
227  * @hideinitializer
228  **********************************************************************/
229  DISTANCE = 1U<<10,
230  /**
231  * Calculate area \e S12.
232  * @hideinitializer
233  **********************************************************************/
234  AREA = 1U<<14,
235  /**
236  * Unroll \e lon2 in the direct calculation.
237  * @hideinitializer
238  **********************************************************************/
239  LONG_UNROLL = 1U<<15,
240  /**
241  * Calculate everything. (LONG_UNROLL is not included in this mask.)
242  * @hideinitializer
243  **********************************************************************/
244  ALL = 0x7F80U,
245  };
246 
247  /**
248  * Constructor for an ellipsoid with
249  *
250  * @param[in] a equatorial radius (meters).
251  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
252  * Negative \e f gives a prolate ellipsoid.
253  * @param[in] exact if true (the default) use an addition theorem for
254  * elliptic integrals to compute divided differences; otherwise use
255  * series expansion (accurate for |<i>f</i>| < 0.01).
256  * @exception GeographicErr if \e a or (1 &minus; \e f) \e a is not
257  * positive.
258  *
259  * See \ref rhumb, for a detailed description of the \e exact parameter.
260  **********************************************************************/
261  Rhumb(real a, real f, bool exact = true);
262 
263  /**
264  * Solve the direct rhumb problem returning also the area.
265  *
266  * @param[in] lat1 latitude of point 1 (degrees).
267  * @param[in] lon1 longitude of point 1 (degrees).
268  * @param[in] azi12 azimuth of the rhumb line (degrees).
269  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
270  * negative.
271  * @param[out] lat2 latitude of point 2 (degrees).
272  * @param[out] lon2 longitude of point 2 (degrees).
273  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
274  *
275  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The value of
276  * \e lon2 returned is in the range [&minus;180&deg;, 180&deg;].
277  *
278  * If point 1 is a pole, the cosine of its latitude is taken to be
279  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
280  * position, which is extremely close to the actual pole, allows the
281  * calculation to be carried out in finite terms. If \e s12 is large
282  * enough that the rhumb line crosses a pole, the longitude of point 2
283  * is indeterminate (a NaN is returned for \e lon2 and \e S12).
284  **********************************************************************/
285  void Direct(real lat1, real lon1, real azi12, real s12,
286  real& lat2, real& lon2, real& S12) const {
287  GenDirect(lat1, lon1, azi12, s12,
288  LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
289  }
290 
291  /**
292  * Solve the direct rhumb problem without the area.
293  **********************************************************************/
294  void Direct(real lat1, real lon1, real azi12, real s12,
295  real& lat2, real& lon2) const {
296  real t;
297  GenDirect(lat1, lon1, azi12, s12, LATITUDE | LONGITUDE, lat2, lon2, t);
298  }
299 
300  /**
301  * The general direct rhumb problem. Rhumb::Direct is defined in terms
302  * of this function.
303  *
304  * @param[in] lat1 latitude of point 1 (degrees).
305  * @param[in] lon1 longitude of point 1 (degrees).
306  * @param[in] azi12 azimuth of the rhumb line (degrees).
307  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
308  * negative.
309  * @param[in] outmask a bitor'ed combination of Rhumb::mask values
310  * specifying which of the following parameters should be set.
311  * @param[out] lat2 latitude of point 2 (degrees).
312  * @param[out] lon2 longitude of point 2 (degrees).
313  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
314  *
315  * The Rhumb::mask values possible for \e outmask are
316  * - \e outmask |= Rhumb::LATITUDE for the latitude \e lat2;
317  * - \e outmask |= Rhumb::LONGITUDE for the latitude \e lon2;
318  * - \e outmask |= Rhumb::AREA for the area \e S12;
319  * - \e outmask |= Rhumb::ALL for all of the above;
320  * - \e outmask |= Rhumb::LONG_UNROLL to unroll \e lon2 instead of wrapping
321  * it into the range [&minus;180&deg;, 180&deg;].
322  * .
323  * With the Rhumb::LONG_UNROLL bit set, the quantity \e lon2 &minus;
324  * \e lon1 indicates how many times and in what sense the rhumb line
325  * encircles the ellipsoid.
326  **********************************************************************/
327  void GenDirect(real lat1, real lon1, real azi12, real s12,
328  unsigned outmask, real& lat2, real& lon2, real& S12) const;
329 
330  /**
331  * Solve the inverse rhumb problem returning also the area.
332  *
333  * @param[in] lat1 latitude of point 1 (degrees).
334  * @param[in] lon1 longitude of point 1 (degrees).
335  * @param[in] lat2 latitude of point 2 (degrees).
336  * @param[in] lon2 longitude of point 2 (degrees).
337  * @param[out] s12 rhumb distance between point 1 and point 2 (meters).
338  * @param[out] azi12 azimuth of the rhumb line (degrees).
339  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
340  *
341  * The shortest rhumb line is found. If the end points are on opposite
342  * meridians, there are two shortest rhumb lines and the east-going one is
343  * chosen. \e lat1 and \e lat2 should be in the range [&minus;90&deg;,
344  * 90&deg;]. The value of \e azi12 returned is in the range
345  * [&minus;180&deg;, 180&deg;].
346  *
347  * If either point is a pole, the cosine of its latitude is taken to be
348  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
349  * position, which is extremely close to the actual pole, allows the
350  * calculation to be carried out in finite terms.
351  **********************************************************************/
352  void Inverse(real lat1, real lon1, real lat2, real lon2,
353  real& s12, real& azi12, real& S12) const {
354  GenInverse(lat1, lon1, lat2, lon2,
355  DISTANCE | AZIMUTH | AREA, s12, azi12, S12);
356  }
357 
358  /**
359  * Solve the inverse rhumb problem without the area.
360  **********************************************************************/
361  void Inverse(real lat1, real lon1, real lat2, real lon2,
362  real& s12, real& azi12) const {
363  real t;
364  GenInverse(lat1, lon1, lat2, lon2, DISTANCE | AZIMUTH, s12, azi12, t);
365  }
366 
367  /**
368  * The general inverse rhumb problem. Rhumb::Inverse is defined in terms
369  * of this function.
370  *
371  * @param[in] lat1 latitude of point 1 (degrees).
372  * @param[in] lon1 longitude of point 1 (degrees).
373  * @param[in] lat2 latitude of point 2 (degrees).
374  * @param[in] lon2 longitude of point 2 (degrees).
375  * @param[in] outmask a bitor'ed combination of Rhumb::mask values
376  * specifying which of the following parameters should be set.
377  * @param[out] s12 rhumb distance between point 1 and point 2 (meters).
378  * @param[out] azi12 azimuth of the rhumb line (degrees).
379  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
380  *
381  * The Rhumb::mask values possible for \e outmask are
382  * - \e outmask |= Rhumb::DISTANCE for the latitude \e s12;
383  * - \e outmask |= Rhumb::AZIMUTH for the latitude \e azi12;
384  * - \e outmask |= Rhumb::AREA for the area \e S12;
385  * - \e outmask |= Rhumb::ALL for all of the above;
386  **********************************************************************/
387  void GenInverse(real lat1, real lon1, real lat2, real lon2,
388  unsigned outmask,
389  real& s12, real& azi12, real& S12) const;
390 
391  /**
392  * Set up to compute several points on a single rhumb line.
393  *
394  * @param[in] lat1 latitude of point 1 (degrees).
395  * @param[in] lon1 longitude of point 1 (degrees).
396  * @param[in] azi12 azimuth of the rhumb line (degrees).
397  * @return a RhumbLine object.
398  *
399  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;].
400  *
401  * If point 1 is a pole, the cosine of its latitude is taken to be
402  * 1/&epsilon;<sup>2</sup> (where &epsilon; is 2<sup>-52</sup>). This
403  * position, which is extremely close to the actual pole, allows the
404  * calculation to be carried out in finite terms.
405  **********************************************************************/
406  RhumbLine Line(real lat1, real lon1, real azi12) const;
407 
408  /** \name Inspector functions.
409  **********************************************************************/
410  ///@{
411 
412  /**
413  * @return \e a the equatorial radius of the ellipsoid (meters). This is
414  * the value used in the constructor.
415  **********************************************************************/
416  Math::real EquatorialRadius() const { return _ell.EquatorialRadius(); }
417 
418  /**
419  * @return \e f the flattening of the ellipsoid. This is the
420  * value used in the constructor.
421  **********************************************************************/
422  Math::real Flattening() const { return _ell.Flattening(); }
423 
424  /**
425  * @return total area of ellipsoid in meters<sup>2</sup>. The area of a
426  * polygon encircling a pole can be found by adding
427  * Geodesic::EllipsoidArea()/2 to the sum of \e S12 for each side of the
428  * polygon.
429  **********************************************************************/
430  Math::real EllipsoidArea() const { return _ell.Area(); }
431  ///@}
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  real _lat1, _lon1, _azi12, _salp, _calp, _mu1, _psi1, _r1;
464  // copy assignment not allowed
465  RhumbLine& operator=(const RhumbLine&) = delete;
466  RhumbLine(const Rhumb& rh, real lat1, real lon1, real azi12);
467  public:
468  /**
469  * Construction is via default copy constructor.
470  **********************************************************************/
471  RhumbLine(const RhumbLine&) = default;
472  /**
473  * This is a duplication of Rhumb::mask.
474  **********************************************************************/
475  enum mask {
476  /**
477  * No output.
478  * @hideinitializer
479  **********************************************************************/
480  NONE = Rhumb::NONE,
481  /**
482  * Calculate latitude \e lat2.
483  * @hideinitializer
484  **********************************************************************/
485  LATITUDE = Rhumb::LATITUDE,
486  /**
487  * Calculate longitude \e lon2.
488  * @hideinitializer
489  **********************************************************************/
490  LONGITUDE = Rhumb::LONGITUDE,
491  /**
492  * Calculate azimuth \e azi12.
493  * @hideinitializer
494  **********************************************************************/
495  AZIMUTH = Rhumb::AZIMUTH,
496  /**
497  * Calculate distance \e s12.
498  * @hideinitializer
499  **********************************************************************/
500  DISTANCE = Rhumb::DISTANCE,
501  /**
502  * Calculate area \e S12.
503  * @hideinitializer
504  **********************************************************************/
505  AREA = Rhumb::AREA,
506  /**
507  * Unroll \e lon2 in the direct calculation.
508  * @hideinitializer
509  **********************************************************************/
510  LONG_UNROLL = Rhumb::LONG_UNROLL,
511  /**
512  * Calculate everything. (LONG_UNROLL is not included in this mask.)
513  * @hideinitializer
514  **********************************************************************/
515  ALL = Rhumb::ALL,
516  };
517 
518  /**
519  * Compute the position of point 2 which is a distance \e s12 (meters) from
520  * point 1. The area is also computed.
521  *
522  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
523  * negative.
524  * @param[out] lat2 latitude of point 2 (degrees).
525  * @param[out] lon2 longitude of point 2 (degrees).
526  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
527  *
528  * The value of \e lon2 returned is in the range [&minus;180&deg;,
529  * 180&deg;].
530  *
531  * If \e s12 is large enough that the rhumb line crosses a pole, the
532  * longitude of point 2 is indeterminate (a NaN is returned for \e lon2 and
533  * \e S12).
534  **********************************************************************/
535  void Position(real s12, real& lat2, real& lon2, real& S12) const {
536  GenPosition(s12, LATITUDE | LONGITUDE | AREA, lat2, lon2, S12);
537  }
538 
539  /**
540  * Compute the position of point 2 which is a distance \e s12 (meters) from
541  * point 1. The area is not computed.
542  **********************************************************************/
543  void Position(real s12, real& lat2, real& lon2) const {
544  real t;
545  GenPosition(s12, LATITUDE | LONGITUDE, lat2, lon2, t);
546  }
547 
548  /**
549  * The general position routine. RhumbLine::Position is defined in term so
550  * this function.
551  *
552  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
553  * negative.
554  * @param[in] outmask a bitor'ed combination of RhumbLine::mask values
555  * specifying which of the following parameters should be set.
556  * @param[out] lat2 latitude of point 2 (degrees).
557  * @param[out] lon2 longitude of point 2 (degrees).
558  * @param[out] S12 area under the rhumb line (meters<sup>2</sup>).
559  *
560  * The RhumbLine::mask values possible for \e outmask are
561  * - \e outmask |= RhumbLine::LATITUDE for the latitude \e lat2;
562  * - \e outmask |= RhumbLine::LONGITUDE for the latitude \e lon2;
563  * - \e outmask |= RhumbLine::AREA for the area \e S12;
564  * - \e outmask |= RhumbLine::ALL for all of the above;
565  * - \e outmask |= RhumbLine::LONG_UNROLL to unroll \e lon2 instead of
566  * wrapping it into the range [&minus;180&deg;, 180&deg;].
567  * .
568  * With the RhumbLine::LONG_UNROLL bit set, the quantity \e lon2 &minus; \e
569  * lon1 indicates how many times and in what sense the rhumb line encircles
570  * the ellipsoid.
571  *
572  * If \e s12 is large enough that the rhumb line crosses a pole, the
573  * longitude of point 2 is indeterminate (a NaN is returned for \e lon2 and
574  * \e S12).
575  **********************************************************************/
576  void GenPosition(real s12, unsigned outmask,
577  real& lat2, real& lon2, real& S12) const;
578 
579  /** \name Inspector functions
580  **********************************************************************/
581  ///@{
582 
583  /**
584  * @return \e lat1 the latitude of point 1 (degrees).
585  **********************************************************************/
586  Math::real Latitude() const { return _lat1; }
587 
588  /**
589  * @return \e lon1 the longitude of point 1 (degrees).
590  **********************************************************************/
591  Math::real Longitude() const { return _lon1; }
592 
593  /**
594  * @return \e azi12 the azimuth of the rhumb line (degrees).
595  **********************************************************************/
596  Math::real Azimuth() const { return _azi12; }
597 
598  /**
599  * @return \e a the equatorial radius of the ellipsoid (meters). This is
600  * the value inherited from the Rhumb object used in the constructor.
601  **********************************************************************/
602  Math::real EquatorialRadius() const { return _rh.EquatorialRadius(); }
603 
604  /**
605  * @return \e f the flattening of the ellipsoid. This is the value
606  * inherited from the Rhumb object used in the constructor.
607  **********************************************************************/
608  Math::real Flattening() const { return _rh.Flattening(); }
609  };
610 
611 } // namespace GeographicLib
612 
613 #endif // GEOGRAPHICLIB_RHUMB_HPP
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:67
Header for GeographicLib::Ellipsoid class.
GeographicLib::Math::real real
Definition: GeodSolve.cpp:31
#define GEOGRAPHICLIB_RHUMBAREA_ORDER
Definition: Rhumb.hpp:21
#define GEOGRAPHICLIB_TRANSVERSEMERCATOR_ORDER
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
Math::real Area() const
Definition: Ellipsoid.cpp:45
Math::real Flattening() const
Definition: Ellipsoid.hpp:120
Math::real EquatorialRadius() const
Definition: Ellipsoid.hpp:80
static T tand(T x)
Definition: Math.cpp:172
static T eatanhe(T x, T es)
Definition: Math.cpp:205
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:458
void Position(real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:543
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:535
RhumbLine(const RhumbLine &)=default
Math::real EquatorialRadius() const
Definition: Rhumb.hpp:602
Math::real Latitude() const
Definition: Rhumb.hpp:586
Math::real Azimuth() const
Definition: Rhumb.hpp:596
Math::real Flattening() const
Definition: Rhumb.hpp:608
Math::real Longitude() const
Definition: Rhumb.hpp:591
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
Math::real Flattening() const
Definition: Rhumb.hpp:422
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:285
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12, real &S12) const
Definition: Rhumb.hpp:352
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12) const
Definition: Rhumb.hpp:361
void Direct(real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2) const
Definition: Rhumb.hpp:294
Math::real EquatorialRadius() const
Definition: Rhumb.hpp:416
Math::real EllipsoidArea() const
Definition: Rhumb.hpp:430
Namespace for GeographicLib.
Definition: Accumulator.cpp:12