GeographicLib  1.44
GeodesicExact.hpp
Go to the documentation of this file.
1 /**
2  * \file GeodesicExact.hpp
3  * \brief Header for GeographicLib::GeodesicExact class
4  *
5  * Copyright (c) Charles Karney (2012-2015) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
10 #if !defined(GEOGRAPHICLIB_GEODESICEXACT_HPP)
11 #define GEOGRAPHICLIB_GEODESICEXACT_HPP 1
12 
15 
16 #if !defined(GEOGRAPHICLIB_GEODESICEXACT_ORDER)
17 /**
18  * The order of the expansions used by GeodesicExact.
19  **********************************************************************/
20 # define GEOGRAPHICLIB_GEODESICEXACT_ORDER 30
21 #endif
22 
23 namespace GeographicLib {
24 
25  class GeodesicLineExact;
26 
27  /**
28  * \brief Exact geodesic calculations
29  *
30  * The equations for geodesics on an ellipsoid can be expressed in terms of
31  * incomplete elliptic integrals. The Geodesic class expands these integrals
32  * in a series in the flattening \e f and this provides an accurate solution
33  * for \e f &isin; [-0.01, 0.01]. The GeodesicExact class computes the
34  * ellitpic integrals directly and so provides a solution which is valid for
35  * all \e f. However, in practice, its use should be limited to about
36  * <i>b</i>/\e a &isin; [0.01, 100] or \e f &isin; [-99, 0.99].
37  *
38  * For the WGS84 ellipsoid, these classes are 2--3 times \e slower than the
39  * series solution and 2--3 times \e less \e accurate (because it's less easy
40  * to control round-off errors with the elliptic integral formulation); i.e.,
41  * the error is about 40 nm (40 nanometers) instead of 15 nm. However the
42  * error in the series solution scales as <i>f</i><sup>7</sup> while the
43  * error in the elliptic integral solution depends weakly on \e f. If the
44  * quarter meridian distance is 10000 km and the ratio <i>b</i>/\e a = 1
45  * &minus; \e f is varied then the approximate maximum error (expressed as a
46  * distance) is <pre>
47  * 1 - f error (nm)
48  * 1/128 387
49  * 1/64 345
50  * 1/32 269
51  * 1/16 210
52  * 1/8 115
53  * 1/4 69
54  * 1/2 36
55  * 1 15
56  * 2 25
57  * 4 96
58  * 8 318
59  * 16 985
60  * 32 2352
61  * 64 6008
62  * 128 19024
63  * </pre>
64  *
65  * The computation of the area in these classes is via a 30th order series.
66  * This gives accurate results for <i>b</i>/\e a &isin; [1/2, 2]; the
67  * accuracy is about 8 decimal digits for <i>b</i>/\e a &isin; [1/4, 4].
68  *
69  * See \ref geodellip for the formulation. See the documentation on the
70  * Geodesic class for additional information on the geodesic problems.
71  *
72  * Example of use:
73  * \include example-GeodesicExact.cpp
74  *
75  * <a href="GeodSolve.1.html">GeodSolve</a> is a command-line utility
76  * providing access to the functionality of GeodesicExact and
77  * GeodesicLineExact (via the -E option).
78  **********************************************************************/
79 
81  private:
82  typedef Math::real real;
83  friend class GeodesicLineExact;
84  static const int nC4_ = GEOGRAPHICLIB_GEODESICEXACT_ORDER;
85  static const int nC4x_ = (nC4_ * (nC4_ + 1)) / 2;
86  static const unsigned maxit1_ = 20;
87  unsigned maxit2_;
88  real tiny_, tol0_, tol1_, tol2_, tolb_, xthresh_;
89 
90  enum captype {
91  CAP_NONE = 0U,
92  CAP_E = 1U<<0,
93  // Skip 1U<<1 for compatibility with Geodesic (not required)
94  CAP_D = 1U<<2,
95  CAP_H = 1U<<3,
96  CAP_C4 = 1U<<4,
97  CAP_ALL = 0x1FU,
98  CAP_MASK = CAP_ALL,
99  OUT_ALL = 0x7F80U,
100  OUT_MASK = 0xFF80U, // Includes LONG_UNROLL
101  };
102 
103  static real CosSeries(real sinx, real cosx, const real c[], int n);
104  static real Astroid(real x, real y);
105 
106  real _a, _f, _f1, _e2, _ep2, _n, _b, _c2, _etol2;
107  real _C4x[nC4x_];
108 
109  void Lengths(const EllipticFunction& E,
110  real sig12,
111  real ssig1, real csig1, real dn1,
112  real ssig2, real csig2, real dn2,
113  real cbet1, real cbet2, unsigned outmask,
114  real& s12s, real& m12a, real& m0,
115  real& M12, real& M21) const;
116  real InverseStart(EllipticFunction& E,
117  real sbet1, real cbet1, real dn1,
118  real sbet2, real cbet2, real dn2,
119  real lam12,
120  real& salp1, real& calp1,
121  real& salp2, real& calp2, real& dnm) const;
122  real Lambda12(real sbet1, real cbet1, real dn1,
123  real sbet2, real cbet2, real dn2,
124  real salp1, real calp1,
125  real& salp2, real& calp2, real& sig12,
126  real& ssig1, real& csig1, real& ssig2, real& csig2,
127  EllipticFunction& E,
128  real& omg12, bool diffp, real& dlam12) const;
129 
130  // These are Maxima generated functions to provide series approximations to
131  // the integrals for the area.
132  void C4coeff();
133  void C4f(real k2, real c[]) const;
134  // Large coefficients are split so that lo contains the low 52 bits and hi
135  // the rest. This choice avoids double rounding with doubles and higher
136  // precision types. float coefficients will suffer double rounding;
137  // however the accuracy is already lousy for floats.
138  static Math::real inline reale(long long hi, long long lo) {
139  using std::ldexp;
140  return ldexp(real(hi), 52) + lo;
141  }
142 
143  public:
144 
145  /**
146  * Bit masks for what calculations to do. These masks do double duty.
147  * They signify to the GeodesicLineExact::GeodesicLineExact constructor and
148  * to GeodesicExact::Line what capabilities should be included in the
149  * GeodesicLineExact object. They also specify which results to return in
150  * the general routines GeodesicExact::GenDirect and
151  * GeodesicExact::GenInverse routines. GeodesicLineExact::mask is a
152  * duplication of this enum.
153  **********************************************************************/
154  enum mask {
155  /**
156  * No capabilities, no output.
157  * @hideinitializer
158  **********************************************************************/
159  NONE = 0U,
160  /**
161  * Calculate latitude \e lat2. (It's not necessary to include this as a
162  * capability to GeodesicLineExact because this is included by default.)
163  * @hideinitializer
164  **********************************************************************/
165  LATITUDE = 1U<<7 | CAP_NONE,
166  /**
167  * Calculate longitude \e lon2.
168  * @hideinitializer
169  **********************************************************************/
170  LONGITUDE = 1U<<8 | CAP_H,
171  /**
172  * Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
173  * include this as a capability to GeodesicLineExact because this is
174  * included by default.)
175  * @hideinitializer
176  **********************************************************************/
177  AZIMUTH = 1U<<9 | CAP_NONE,
178  /**
179  * Calculate distance \e s12.
180  * @hideinitializer
181  **********************************************************************/
182  DISTANCE = 1U<<10 | CAP_E,
183  /**
184  * Allow distance \e s12 to be used as input in the direct geodesic
185  * problem.
186  * @hideinitializer
187  **********************************************************************/
188  DISTANCE_IN = 1U<<11 | CAP_E,
189  /**
190  * Calculate reduced length \e m12.
191  * @hideinitializer
192  **********************************************************************/
193  REDUCEDLENGTH = 1U<<12 | CAP_D,
194  /**
195  * Calculate geodesic scales \e M12 and \e M21.
196  * @hideinitializer
197  **********************************************************************/
198  GEODESICSCALE = 1U<<13 | CAP_D,
199  /**
200  * Calculate area \e S12.
201  * @hideinitializer
202  **********************************************************************/
203  AREA = 1U<<14 | CAP_C4,
204  /**
205  * Unroll \e lon2 in the direct calculation. (This flag used to be
206  * called LONG_NOWRAP.)
207  * @hideinitializer
208  **********************************************************************/
209  LONG_UNROLL = 1U<<15,
210  /// \cond SKIP
211  LONG_NOWRAP = LONG_UNROLL,
212  /// \endcond
213  /**
214  * All capabilities, calculate everything. (LONG_UNROLL is not
215  * included in this mask.)
216  * @hideinitializer
217  **********************************************************************/
218  ALL = OUT_ALL| CAP_ALL,
219  };
220 
221  /** \name Constructor
222  **********************************************************************/
223  ///@{
224  /**
225  * Constructor for a ellipsoid with
226  *
227  * @param[in] a equatorial radius (meters).
228  * @param[in] f flattening of ellipsoid. Setting \e f = 0 gives a sphere.
229  * Negative \e f gives a prolate ellipsoid. If \e f &gt; 1, set
230  * flattening to 1/\e f.
231  * @exception GeographicErr if \e a or (1 &minus; \e f) \e a is not
232  * positive.
233  **********************************************************************/
234  GeodesicExact(real a, real f);
235  ///@}
236 
237  /** \name Direct geodesic problem specified in terms of distance.
238  **********************************************************************/
239  ///@{
240  /**
241  * Perform the direct geodesic calculation where the length of the geodesic
242  * is specified in terms of distance.
243  *
244  * @param[in] lat1 latitude of point 1 (degrees).
245  * @param[in] lon1 longitude of point 1 (degrees).
246  * @param[in] azi1 azimuth at point 1 (degrees).
247  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
248  * signed.
249  * @param[out] lat2 latitude of point 2 (degrees).
250  * @param[out] lon2 longitude of point 2 (degrees).
251  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
252  * @param[out] m12 reduced length of geodesic (meters).
253  * @param[out] M12 geodesic scale of point 2 relative to point 1
254  * (dimensionless).
255  * @param[out] M21 geodesic scale of point 1 relative to point 2
256  * (dimensionless).
257  * @param[out] S12 area under the geodesic (meters<sup>2</sup>).
258  * @return \e a12 arc length of between point 1 and point 2 (degrees).
259  *
260  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The values of
261  * \e lon2 and \e azi2 returned are in the range [&minus;180&deg;,
262  * 180&deg;).
263  *
264  * If either point is at a pole, the azimuth is defined by keeping the
265  * longitude fixed, writing \e lat = &plusmn;(90&deg; &minus; &epsilon;),
266  * and taking the limit &epsilon; &rarr; 0+. An arc length greater that
267  * 180&deg; signifies a geodesic which is not a shortest path. (For a
268  * prolate ellipsoid, an additional condition is necessary for a shortest
269  * path: the longitudinal extent must not exceed of 180&deg;.)
270  *
271  * The following functions are overloaded versions of GeodesicExact::Direct
272  * which omit some of the output parameters. Note, however, that the arc
273  * length is always computed and returned as the function value.
274  **********************************************************************/
275  Math::real Direct(real lat1, real lon1, real azi1, real s12,
276  real& lat2, real& lon2, real& azi2,
277  real& m12, real& M12, real& M21, real& S12)
278  const {
279  real t;
280  return GenDirect(lat1, lon1, azi1, false, s12,
281  LATITUDE | LONGITUDE | AZIMUTH |
282  REDUCEDLENGTH | GEODESICSCALE | AREA,
283  lat2, lon2, azi2, t, m12, M12, M21, S12);
284  }
285 
286  /**
287  * See the documentation for GeodesicExact::Direct.
288  **********************************************************************/
289  Math::real Direct(real lat1, real lon1, real azi1, real s12,
290  real& lat2, real& lon2)
291  const {
292  real t;
293  return GenDirect(lat1, lon1, azi1, false, s12,
294  LATITUDE | LONGITUDE,
295  lat2, lon2, t, t, t, t, t, t);
296  }
297 
298  /**
299  * See the documentation for GeodesicExact::Direct.
300  **********************************************************************/
301  Math::real Direct(real lat1, real lon1, real azi1, real s12,
302  real& lat2, real& lon2, real& azi2)
303  const {
304  real t;
305  return GenDirect(lat1, lon1, azi1, false, s12,
306  LATITUDE | LONGITUDE | AZIMUTH,
307  lat2, lon2, azi2, t, t, t, t, t);
308  }
309 
310  /**
311  * See the documentation for GeodesicExact::Direct.
312  **********************************************************************/
313  Math::real Direct(real lat1, real lon1, real azi1, real s12,
314  real& lat2, real& lon2, real& azi2, real& m12)
315  const {
316  real t;
317  return GenDirect(lat1, lon1, azi1, false, s12,
318  LATITUDE | LONGITUDE | AZIMUTH | REDUCEDLENGTH,
319  lat2, lon2, azi2, t, m12, t, t, t);
320  }
321 
322  /**
323  * See the documentation for GeodesicExact::Direct.
324  **********************************************************************/
325  Math::real Direct(real lat1, real lon1, real azi1, real s12,
326  real& lat2, real& lon2, real& azi2,
327  real& M12, real& M21)
328  const {
329  real t;
330  return GenDirect(lat1, lon1, azi1, false, s12,
331  LATITUDE | LONGITUDE | AZIMUTH | GEODESICSCALE,
332  lat2, lon2, azi2, t, t, M12, M21, t);
333  }
334 
335  /**
336  * See the documentation for GeodesicExact::Direct.
337  **********************************************************************/
338  Math::real Direct(real lat1, real lon1, real azi1, real s12,
339  real& lat2, real& lon2, real& azi2,
340  real& m12, real& M12, real& M21)
341  const {
342  real t;
343  return GenDirect(lat1, lon1, azi1, false, s12,
344  LATITUDE | LONGITUDE | AZIMUTH |
345  REDUCEDLENGTH | GEODESICSCALE,
346  lat2, lon2, azi2, t, m12, M12, M21, t);
347  }
348  ///@}
349 
350  /** \name Direct geodesic problem specified in terms of arc length.
351  **********************************************************************/
352  ///@{
353  /**
354  * Perform the direct geodesic calculation where the length of the geodesic
355  * is specified in terms of arc length.
356  *
357  * @param[in] lat1 latitude of point 1 (degrees).
358  * @param[in] lon1 longitude of point 1 (degrees).
359  * @param[in] azi1 azimuth at point 1 (degrees).
360  * @param[in] a12 arc length between point 1 and point 2 (degrees); it can
361  * be signed.
362  * @param[out] lat2 latitude of point 2 (degrees).
363  * @param[out] lon2 longitude of point 2 (degrees).
364  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
365  * @param[out] s12 distance between point 1 and point 2 (meters).
366  * @param[out] m12 reduced length of geodesic (meters).
367  * @param[out] M12 geodesic scale of point 2 relative to point 1
368  * (dimensionless).
369  * @param[out] M21 geodesic scale of point 1 relative to point 2
370  * (dimensionless).
371  * @param[out] S12 area under the geodesic (meters<sup>2</sup>).
372  *
373  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The values of
374  * \e lon2 and \e azi2 returned are in the range [&minus;180&deg;,
375  * 180&deg;).
376  *
377  * If either point is at a pole, the azimuth is defined by keeping the
378  * longitude fixed, writing \e lat = &plusmn;(90&deg; &minus; &epsilon;),
379  * and taking the limit &epsilon; &rarr; 0+. An arc length greater that
380  * 180&deg; signifies a geodesic which is not a shortest path. (For a
381  * prolate ellipsoid, an additional condition is necessary for a shortest
382  * path: the longitudinal extent must not exceed of 180&deg;.)
383  *
384  * The following functions are overloaded versions of GeodesicExact::Direct
385  * which omit some of the output parameters.
386  **********************************************************************/
387  void ArcDirect(real lat1, real lon1, real azi1, real a12,
388  real& lat2, real& lon2, real& azi2, real& s12,
389  real& m12, real& M12, real& M21, real& S12)
390  const {
391  GenDirect(lat1, lon1, azi1, true, a12,
392  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
393  REDUCEDLENGTH | GEODESICSCALE | AREA,
394  lat2, lon2, azi2, s12, m12, M12, M21, S12);
395  }
396 
397  /**
398  * See the documentation for GeodesicExact::ArcDirect.
399  **********************************************************************/
400  void ArcDirect(real lat1, real lon1, real azi1, real a12,
401  real& lat2, real& lon2) const {
402  real t;
403  GenDirect(lat1, lon1, azi1, true, a12,
404  LATITUDE | LONGITUDE,
405  lat2, lon2, t, t, t, t, t, t);
406  }
407 
408  /**
409  * See the documentation for GeodesicExact::ArcDirect.
410  **********************************************************************/
411  void ArcDirect(real lat1, real lon1, real azi1, real a12,
412  real& lat2, real& lon2, real& azi2) const {
413  real t;
414  GenDirect(lat1, lon1, azi1, true, a12,
415  LATITUDE | LONGITUDE | AZIMUTH,
416  lat2, lon2, azi2, t, t, t, t, t);
417  }
418 
419  /**
420  * See the documentation for GeodesicExact::ArcDirect.
421  **********************************************************************/
422  void ArcDirect(real lat1, real lon1, real azi1, real a12,
423  real& lat2, real& lon2, real& azi2, real& s12)
424  const {
425  real t;
426  GenDirect(lat1, lon1, azi1, true, a12,
427  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE,
428  lat2, lon2, azi2, s12, t, t, t, t);
429  }
430 
431  /**
432  * See the documentation for GeodesicExact::ArcDirect.
433  **********************************************************************/
434  void ArcDirect(real lat1, real lon1, real azi1, real a12,
435  real& lat2, real& lon2, real& azi2,
436  real& s12, real& m12) const {
437  real t;
438  GenDirect(lat1, lon1, azi1, true, a12,
439  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
440  REDUCEDLENGTH,
441  lat2, lon2, azi2, s12, m12, t, t, t);
442  }
443 
444  /**
445  * See the documentation for GeodesicExact::ArcDirect.
446  **********************************************************************/
447  void ArcDirect(real lat1, real lon1, real azi1, real a12,
448  real& lat2, real& lon2, real& azi2, real& s12,
449  real& M12, real& M21) const {
450  real t;
451  GenDirect(lat1, lon1, azi1, true, a12,
452  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
453  GEODESICSCALE,
454  lat2, lon2, azi2, s12, t, M12, M21, t);
455  }
456 
457  /**
458  * See the documentation for GeodesicExact::ArcDirect.
459  **********************************************************************/
460  void ArcDirect(real lat1, real lon1, real azi1, real a12,
461  real& lat2, real& lon2, real& azi2, real& s12,
462  real& m12, real& M12, real& M21) const {
463  real t;
464  GenDirect(lat1, lon1, azi1, true, a12,
465  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
466  REDUCEDLENGTH | GEODESICSCALE,
467  lat2, lon2, azi2, s12, m12, M12, M21, t);
468  }
469  ///@}
470 
471  /** \name General version of the direct geodesic solution.
472  **********************************************************************/
473  ///@{
474 
475  /**
476  * The general direct geodesic calculation. GeodesicExact::Direct and
477  * GeodesicExact::ArcDirect are defined in terms of this function.
478  *
479  * @param[in] lat1 latitude of point 1 (degrees).
480  * @param[in] lon1 longitude of point 1 (degrees).
481  * @param[in] azi1 azimuth at point 1 (degrees).
482  * @param[in] arcmode boolean flag determining the meaning of the second
483  * parameter.
484  * @param[in] s12_a12 if \e arcmode is false, this is the distance between
485  * point 1 and point 2 (meters); otherwise it is the arc length between
486  * point 1 and point 2 (degrees); it can be signed.
487  * @param[in] outmask a bitor'ed combination of GeodesicExact::mask values
488  * specifying which of the following parameters should be set.
489  * @param[out] lat2 latitude of point 2 (degrees).
490  * @param[out] lon2 longitude of point 2 (degrees).
491  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
492  * @param[out] s12 distance between point 1 and point 2 (meters).
493  * @param[out] m12 reduced length of geodesic (meters).
494  * @param[out] M12 geodesic scale of point 2 relative to point 1
495  * (dimensionless).
496  * @param[out] M21 geodesic scale of point 1 relative to point 2
497  * (dimensionless).
498  * @param[out] S12 area under the geodesic (meters<sup>2</sup>).
499  * @return \e a12 arc length of between point 1 and point 2 (degrees).
500  *
501  * The GeodesicExact::mask values possible for \e outmask are
502  * - \e outmask |= GeodesicExact::LATITUDE for the latitude \e lat2;
503  * - \e outmask |= GeodesicExact::LONGITUDE for the latitude \e lon2;
504  * - \e outmask |= GeodesicExact::AZIMUTH for the latitude \e azi2;
505  * - \e outmask |= GeodesicExact::DISTANCE for the distance \e s12;
506  * - \e outmask |= GeodesicExact::REDUCEDLENGTH for the reduced length \e
507  * m12;
508  * - \e outmask |= GeodesicExact::GEODESICSCALE for the geodesic scales \e
509  * M12 and \e M21;
510  * - \e outmask |= GeodesicExact::AREA for the area \e S12;
511  * - \e outmask |= GeodesicExact::ALL for all of the above;
512  * - \e outmask |= GeodesicExact::LONG_UNROLL to unroll \e lon2 instead of
513  * wrapping it into the range [&minus;180&deg;, 180&deg;).
514  * .
515  * The function value \e a12 is always computed and returned and this
516  * equals \e s12_a12 is \e arcmode is true. If \e outmask includes
517  * GeodesicExact::DISTANCE and \e arcmode is false, then \e s12 = \e
518  * s12_a12. It is not necessary to include GeodesicExact::DISTANCE_IN in
519  * \e outmask; this is automatically included is \e arcmode is false.
520  *
521  * With the GeodesicExact::LONG_UNROLL bit set, the quantity \e lon2
522  * &minus; \e lon1 indicates how many times and in what sense the geodesic
523  * encircles the ellipsoid.
524  **********************************************************************/
525  Math::real GenDirect(real lat1, real lon1, real azi1,
526  bool arcmode, real s12_a12, unsigned outmask,
527  real& lat2, real& lon2, real& azi2,
528  real& s12, real& m12, real& M12, real& M21,
529  real& S12) const;
530  ///@}
531 
532  /** \name Inverse geodesic problem.
533  **********************************************************************/
534  ///@{
535  /**
536  * Perform the inverse geodesic calculation.
537  *
538  * @param[in] lat1 latitude of point 1 (degrees).
539  * @param[in] lon1 longitude of point 1 (degrees).
540  * @param[in] lat2 latitude of point 2 (degrees).
541  * @param[in] lon2 longitude of point 2 (degrees).
542  * @param[out] s12 distance between point 1 and point 2 (meters).
543  * @param[out] azi1 azimuth at point 1 (degrees).
544  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
545  * @param[out] m12 reduced length of geodesic (meters).
546  * @param[out] M12 geodesic scale of point 2 relative to point 1
547  * (dimensionless).
548  * @param[out] M21 geodesic scale of point 1 relative to point 2
549  * (dimensionless).
550  * @param[out] S12 area under the geodesic (meters<sup>2</sup>).
551  * @return \e a12 arc length of between point 1 and point 2 (degrees).
552  *
553  * \e lat1 and \e lat2 should be in the range [&minus;90&deg;, 90&deg;].
554  * The values of \e azi1 and \e azi2 returned are in the range
555  * [&minus;180&deg;, 180&deg;).
556  *
557  * If either point is at a pole, the azimuth is defined by keeping the
558  * longitude fixed, writing \e lat = &plusmn;(90&deg; &minus; &epsilon;),
559  * and taking the limit &epsilon; &rarr; 0+.
560  *
561  * The following functions are overloaded versions of GeodesicExact::Inverse
562  * which omit some of the output parameters. Note, however, that the arc
563  * length is always computed and returned as the function value.
564  **********************************************************************/
565  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
566  real& s12, real& azi1, real& azi2, real& m12,
567  real& M12, real& M21, real& S12) const {
568  return GenInverse(lat1, lon1, lat2, lon2,
569  DISTANCE | AZIMUTH |
570  REDUCEDLENGTH | GEODESICSCALE | AREA,
571  s12, azi1, azi2, m12, M12, M21, S12);
572  }
573 
574  /**
575  * See the documentation for GeodesicExact::Inverse.
576  **********************************************************************/
577  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
578  real& s12) const {
579  real t;
580  return GenInverse(lat1, lon1, lat2, lon2,
581  DISTANCE,
582  s12, t, t, t, t, t, t);
583  }
584 
585  /**
586  * See the documentation for GeodesicExact::Inverse.
587  **********************************************************************/
588  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
589  real& azi1, real& azi2) const {
590  real t;
591  return GenInverse(lat1, lon1, lat2, lon2,
592  AZIMUTH,
593  t, azi1, azi2, t, t, t, t);
594  }
595 
596  /**
597  * See the documentation for GeodesicExact::Inverse.
598  **********************************************************************/
599  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
600  real& s12, real& azi1, real& azi2)
601  const {
602  real t;
603  return GenInverse(lat1, lon1, lat2, lon2,
604  DISTANCE | AZIMUTH,
605  s12, azi1, azi2, t, t, t, t);
606  }
607 
608  /**
609  * See the documentation for GeodesicExact::Inverse.
610  **********************************************************************/
611  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
612  real& s12, real& azi1, real& azi2, real& m12)
613  const {
614  real t;
615  return GenInverse(lat1, lon1, lat2, lon2,
616  DISTANCE | AZIMUTH | REDUCEDLENGTH,
617  s12, azi1, azi2, m12, t, t, t);
618  }
619 
620  /**
621  * See the documentation for GeodesicExact::Inverse.
622  **********************************************************************/
623  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
624  real& s12, real& azi1, real& azi2,
625  real& M12, real& M21) const {
626  real t;
627  return GenInverse(lat1, lon1, lat2, lon2,
628  DISTANCE | AZIMUTH | GEODESICSCALE,
629  s12, azi1, azi2, t, M12, M21, t);
630  }
631 
632  /**
633  * See the documentation for GeodesicExact::Inverse.
634  **********************************************************************/
635  Math::real Inverse(real lat1, real lon1, real lat2, real lon2,
636  real& s12, real& azi1, real& azi2, real& m12,
637  real& M12, real& M21) const {
638  real t;
639  return GenInverse(lat1, lon1, lat2, lon2,
640  DISTANCE | AZIMUTH |
641  REDUCEDLENGTH | GEODESICSCALE,
642  s12, azi1, azi2, m12, M12, M21, t);
643  }
644  ///@}
645 
646  /** \name General version of inverse geodesic solution.
647  **********************************************************************/
648  ///@{
649  /**
650  * The general inverse geodesic calculation. GeodesicExact::Inverse is
651  * defined in terms of this function.
652  *
653  * @param[in] lat1 latitude of point 1 (degrees).
654  * @param[in] lon1 longitude of point 1 (degrees).
655  * @param[in] lat2 latitude of point 2 (degrees).
656  * @param[in] lon2 longitude of point 2 (degrees).
657  * @param[in] outmask a bitor'ed combination of GeodesicExact::mask values
658  * specifying which of the following parameters should be set.
659  * @param[out] s12 distance between point 1 and point 2 (meters).
660  * @param[out] azi1 azimuth at point 1 (degrees).
661  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
662  * @param[out] m12 reduced length of geodesic (meters).
663  * @param[out] M12 geodesic scale of point 2 relative to point 1
664  * (dimensionless).
665  * @param[out] M21 geodesic scale of point 1 relative to point 2
666  * (dimensionless).
667  * @param[out] S12 area under the geodesic (meters<sup>2</sup>).
668  * @return \e a12 arc length of between point 1 and point 2 (degrees).
669  *
670  * The GeodesicExact::mask values possible for \e outmask are
671  * - \e outmask |= GeodesicExact::DISTANCE for the distance \e s12;
672  * - \e outmask |= GeodesicExact::AZIMUTH for the latitude \e azi2;
673  * - \e outmask |= GeodesicExact::REDUCEDLENGTH for the reduced length \e
674  * m12;
675  * - \e outmask |= GeodesicExact::GEODESICSCALE for the geodesic scales \e
676  * M12 and \e M21;
677  * - \e outmask |= GeodesicExact::AREA for the area \e S12;
678  * - \e outmask |= GeodesicExact::ALL for all of the above.
679  * .
680  * The arc length is always computed and returned as the function value.
681  **********************************************************************/
682  Math::real GenInverse(real lat1, real lon1, real lat2, real lon2,
683  unsigned outmask,
684  real& s12, real& azi1, real& azi2,
685  real& m12, real& M12, real& M21, real& S12)
686  const;
687  ///@}
688 
689  /** \name Interface to GeodesicLineExact.
690  **********************************************************************/
691  ///@{
692 
693  /**
694  * Set up to compute several points on a single geodesic.
695  *
696  * @param[in] lat1 latitude of point 1 (degrees).
697  * @param[in] lon1 longitude of point 1 (degrees).
698  * @param[in] azi1 azimuth at point 1 (degrees).
699  * @param[in] caps bitor'ed combination of GeodesicExact::mask values
700  * specifying the capabilities the GeodesicLineExact object should
701  * possess, i.e., which quantities can be returned in calls to
702  * GeodesicLineExact::Position.
703  * @return a GeodesicLineExact object.
704  *
705  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;].
706  *
707  * The GeodesicExact::mask values are
708  * - \e caps |= GeodesicExact::LATITUDE for the latitude \e lat2; this is
709  * added automatically;
710  * - \e caps |= GeodesicExact::LONGITUDE for the latitude \e lon2;
711  * - \e caps |= GeodesicExact::AZIMUTH for the azimuth \e azi2; this is
712  * added automatically;
713  * - \e caps |= GeodesicExact::DISTANCE for the distance \e s12;
714  * - \e caps |= GeodesicExact::REDUCEDLENGTH for the reduced length \e m12;
715  * - \e caps |= GeodesicExact::GEODESICSCALE for the geodesic scales \e M12
716  * and \e M21;
717  * - \e caps |= GeodesicExact::AREA for the area \e S12;
718  * - \e caps |= GeodesicExact::DISTANCE_IN permits the length of the
719  * geodesic to be given in terms of \e s12; without this capability the
720  * length can only be specified in terms of arc length;
721  * - \e caps |= GeodesicExact::ALL for all of the above.
722  * .
723  * The default value of \e caps is GeodesicExact::ALL which turns on all
724  * the capabilities.
725  *
726  * If the point is at a pole, the azimuth is defined by keeping \e lon1
727  * fixed, writing \e lat1 = &plusmn;(90 &minus; &epsilon;), and taking the
728  * limit &epsilon; &rarr; 0+.
729  **********************************************************************/
730  GeodesicLineExact Line(real lat1, real lon1, real azi1, unsigned caps = ALL)
731  const;
732 
733  ///@}
734 
735  /** \name Inspector functions.
736  **********************************************************************/
737  ///@{
738 
739  /**
740  * @return \e a the equatorial radius of the ellipsoid (meters). This is
741  * the value used in the constructor.
742  **********************************************************************/
743  Math::real MajorRadius() const { return _a; }
744 
745  /**
746  * @return \e f the flattening of the ellipsoid. This is the
747  * value used in the constructor.
748  **********************************************************************/
749  Math::real Flattening() const { return _f; }
750 
751  /// \cond SKIP
752  /**
753  * <b>DEPRECATED</b>
754  * @return \e r the inverse flattening of the ellipsoid.
755  **********************************************************************/
756  Math::real InverseFlattening() const { return 1/_f; }
757  /// \endcond
758 
759  /**
760  * @return total area of ellipsoid in meters<sup>2</sup>. The area of a
761  * polygon encircling a pole can be found by adding
762  * GeodesicExact::EllipsoidArea()/2 to the sum of \e S12 for each side of
763  * the polygon.
764  **********************************************************************/
766  { return 4 * Math::pi() * _c2; }
767  ///@}
768 
769  /**
770  * A global instantiation of GeodesicExact with the parameters for the WGS84
771  * ellipsoid.
772  **********************************************************************/
773  static const GeodesicExact& WGS84();
774 
775  };
776 
777 } // namespace GeographicLib
778 
779 #endif // GEOGRAPHICLIB_GEODESICEXACT_HPP
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
static T pi()
Definition: Math.hpp:216
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:90
Math::real Flattening() const
Math::real EllipsoidArea() const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12, real &M12, real &M21) const
GeographicLib::Math::real real
Definition: GeodSolve.cpp:32
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2) const
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21) const
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2) const
Elliptic integrals and functions.
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &M12, real &M21) const
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2, real &s12) const
#define GEOGRAPHICLIB_GEODESICEXACT_ORDER
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2) const
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2, real &s12, real &M12, real &M21) const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &azi1, real &azi2) const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12) const
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &M12, real &M21) const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12) const
Header for GeographicLib::EllipticFunction class.
Exact geodesic calculations.
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2) const
Header for GeographicLib::Constants class.
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12) const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12) const
Math::real MajorRadius() const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2) const
void ArcDirect(real lat1, real lon1, real azi1, real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21) const
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12, real &M12, real &M21, real &S12) const