GeographicLib  2.0
GeodesicLineExact.hpp
Go to the documentation of this file.
1 /**
2  * \file GeodesicLineExact.hpp
3  * \brief Header for GeographicLib::GeodesicLineExact class
4  *
5  * Copyright (c) Charles Karney (2012-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_GEODESICLINEEXACT_HPP)
11 #define GEOGRAPHICLIB_GEODESICLINEEXACT_HPP 1
12 
16 
17 namespace GeographicLib {
18 
19  /**
20  * \brief An exact geodesic line
21  *
22  * GeodesicLineExact facilitates the determination of a series of points on a
23  * single geodesic. This is a companion to the GeodesicExact class. For
24  * additional information on this class see the documentation on the
25  * GeodesicLine class.
26  *
27  * Example of use:
28  * \include example-GeodesicLineExact.cpp
29  *
30  * <a href="GeodSolve.1.html">GeodSolve</a> is a command-line utility
31  * providing access to the functionality of GeodesicExact and
32  * GeodesicLineExact (via the -E option).
33  **********************************************************************/
34 
36  private:
37  typedef Math::real real;
38  friend class GeodesicExact;
39  static const int nC4_ = GeodesicExact::nC4_;
40 
41  real tiny_;
42  real _lat1, _lon1, _azi1;
43  real _a, _f, _b, _c2, _f1, _e2, _salp0, _calp0, _k2,
44  _salp1, _calp1, _ssig1, _csig1, _dn1, _stau1, _ctau1,
45  _somg1, _comg1, _cchi1,
46  _aA4, _bB41, _eE0, _dD0, _hH0, _eE1, _dD1, _hH1;
47  real _a13, _s13;
48  real _cC4a[nC4_]; // all the elements of _cC4a are used
49  EllipticFunction _eE;
50  unsigned _caps;
51 
52  void LineInit(const GeodesicExact& g,
53  real lat1, real lon1,
54  real azi1, real salp1, real calp1,
55  unsigned caps);
57  real lat1, real lon1,
58  real azi1, real salp1, real calp1,
59  unsigned caps, bool arcmode, real s13_a13);
60 
61  enum captype {
62  CAP_NONE = GeodesicExact::CAP_NONE,
63  CAP_E = GeodesicExact::CAP_E,
64  CAP_D = GeodesicExact::CAP_D,
65  CAP_H = GeodesicExact::CAP_H,
66  CAP_C4 = GeodesicExact::CAP_C4,
67  CAP_ALL = GeodesicExact::CAP_ALL,
68  CAP_MASK = GeodesicExact::CAP_MASK,
69  OUT_ALL = GeodesicExact::OUT_ALL,
70  OUT_MASK = GeodesicExact::OUT_MASK,
71  };
72  public:
73 
74  /**
75  * Bit masks for what calculations to do. They signify to the
76  * GeodesicLineExact::GeodesicLineExact constructor and to
77  * GeodesicExact::Line what capabilities should be included in the
78  * GeodesicLineExact object. This is merely a duplication of
79  * GeodesicExact::mask.
80  **********************************************************************/
81  enum mask {
82  /**
83  * No capabilities, no output.
84  * @hideinitializer
85  **********************************************************************/
87  /**
88  * Calculate latitude \e lat2. (It's not necessary to include this as a
89  * capability to GeodesicLineExact because this is included by default.)
90  * @hideinitializer
91  **********************************************************************/
93  /**
94  * Calculate longitude \e lon2.
95  * @hideinitializer
96  **********************************************************************/
98  /**
99  * Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
100  * include this as a capability to GeodesicLineExact because this is
101  * included by default.)
102  * @hideinitializer
103  **********************************************************************/
105  /**
106  * Calculate distance \e s12.
107  * @hideinitializer
108  **********************************************************************/
110  /**
111  * A combination of the common capabilities: GeodesicLineExact::LATITUDE,
112  * GeodesicLineExact::LONGITUDE, GeodesicLineExact::AZIMUTH,
113  * GeodesicLineExact::DISTANCE.
114  * @hideinitializer
115  **********************************************************************/
117  /**
118  * Allow distance \e s12 to be used as input in the direct geodesic
119  * problem.
120  * @hideinitializer
121  **********************************************************************/
123  /**
124  * Calculate reduced length \e m12.
125  * @hideinitializer
126  **********************************************************************/
128  /**
129  * Calculate geodesic scales \e M12 and \e M21.
130  * @hideinitializer
131  **********************************************************************/
133  /**
134  * Calculate area \e S12.
135  * @hideinitializer
136  **********************************************************************/
138  /**
139  * Unroll \e lon2 in the direct calculation.
140  * @hideinitializer
141  **********************************************************************/
143  /**
144  * All capabilities, calculate everything. (LONG_UNROLL is not
145  * included in this mask.)
146  * @hideinitializer
147  **********************************************************************/
149  };
150 
151  /** \name Constructors
152  **********************************************************************/
153  ///@{
154 
155  /**
156  * Constructor for a geodesic line staring at latitude \e lat1, longitude
157  * \e lon1, and azimuth \e azi1 (all in degrees).
158  *
159  * @param[in] g A GeodesicExact object used to compute the necessary
160  * information about the GeodesicLineExact.
161  * @param[in] lat1 latitude of point 1 (degrees).
162  * @param[in] lon1 longitude of point 1 (degrees).
163  * @param[in] azi1 azimuth at point 1 (degrees).
164  * @param[in] caps bitor'ed combination of GeodesicLineExact::mask values
165  * specifying the capabilities the GeodesicLineExact object should
166  * possess, i.e., which quantities can be returned in calls to
167  * GeodesicLine::Position.
168  *
169  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;].
170  *
171  * The GeodesicLineExact::mask values are
172  * - \e caps |= GeodesicLineExact::LATITUDE for the latitude \e lat2; this
173  * is added automatically;
174  * - \e caps |= GeodesicLineExact::LONGITUDE for the latitude \e lon2;
175  * - \e caps |= GeodesicLineExact::AZIMUTH for the latitude \e azi2; this
176  * is added automatically;
177  * - \e caps |= GeodesicLineExact::DISTANCE for the distance \e s12;
178  * - \e caps |= GeodesicLineExact::REDUCEDLENGTH for the reduced length \e
179  m12;
180  * - \e caps |= GeodesicLineExact::GEODESICSCALE for the geodesic scales \e
181  * M12 and \e M21;
182  * - \e caps |= GeodesicLineExact::AREA for the area \e S12;
183  * - \e caps |= GeodesicLineExact::DISTANCE_IN permits the length of the
184  * geodesic to be given in terms of \e s12; without this capability the
185  * length can only be specified in terms of arc length;
186  * - \e caps |= GeodesicLineExact::ALL for all of the above.
187  * .
188  * The default value of \e caps is GeodesicLineExact::ALL.
189  *
190  * If the point is at a pole, the azimuth is defined by keeping \e lon1
191  * fixed, writing \e lat1 = &plusmn;(90&deg; &minus; &epsilon;), and taking
192  * the limit &epsilon; &rarr; 0+.
193  **********************************************************************/
194  GeodesicLineExact(const GeodesicExact& g, real lat1, real lon1, real azi1,
195  unsigned caps = ALL);
196 
197  /**
198  * A default constructor. If GeodesicLineExact::Position is called on the
199  * resulting object, it returns immediately (without doing any
200  * calculations). The object can be set with a call to
201  * GeodesicExact::Line. Use Init() to test whether object is still in this
202  * uninitialized state.
203  **********************************************************************/
204  GeodesicLineExact() : _caps(0U) {}
205  ///@}
206 
207  /** \name Position in terms of distance
208  **********************************************************************/
209  ///@{
210 
211  /**
212  * Compute the position of point 2 which is a distance \e s12 (meters)
213  * from point 1.
214  *
215  * @param[in] s12 distance from point 1 to point 2 (meters); it can be
216  * signed.
217  * @param[out] lat2 latitude of point 2 (degrees).
218  * @param[out] lon2 longitude of point 2 (degrees); requires that the
219  * GeodesicLineExact object was constructed with \e caps |=
220  * GeodesicLineExact::LONGITUDE.
221  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
222  * @param[out] m12 reduced length of geodesic (meters); requires that the
223  * GeodesicLineExact object was constructed with \e caps |=
224  * GeodesicLineExact::REDUCEDLENGTH.
225  * @param[out] M12 geodesic scale of point 2 relative to point 1
226  * (dimensionless); requires that the GeodesicLineExact object was
227  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
228  * @param[out] M21 geodesic scale of point 1 relative to point 2
229  * (dimensionless); requires that the GeodesicLineExact object was
230  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
231  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
232  * that the GeodesicLineExact object was constructed with \e caps |=
233  * GeodesicLineExact::AREA.
234  * @return \e a12 arc length from point 1 to point 2 (degrees).
235  *
236  * The values of \e lon2 and \e azi2 returned are in the range
237  * [&minus;180&deg;, 180&deg;].
238  *
239  * The GeodesicLineExact object \e must have been constructed with \e caps
240  * |= GeodesicLineExact::DISTANCE_IN; otherwise Math::NaN() is returned and
241  * no parameters are set. Requesting a value which the GeodesicLineExact
242  * object is not capable of computing is not an error; the corresponding
243  * argument will not be altered.
244  *
245  * The following functions are overloaded versions of
246  * GeodesicLineExact::Position which omit some of the output parameters.
247  * Note, however, that the arc length is always computed and returned as
248  * the function value.
249  **********************************************************************/
251  real& lat2, real& lon2, real& azi2,
252  real& m12, real& M12, real& M21,
253  real& S12) const {
254  real t;
255  return GenPosition(false, s12,
256  LATITUDE | LONGITUDE | AZIMUTH |
257  REDUCEDLENGTH | GEODESICSCALE | AREA,
258  lat2, lon2, azi2, t, m12, M12, M21, S12);
259  }
260 
261  /**
262  * See the documentation for GeodesicLineExact::Position.
263  **********************************************************************/
264  Math::real Position(real s12, real& lat2, real& lon2) const {
265  real t;
266  return GenPosition(false, s12,
267  LATITUDE | LONGITUDE,
268  lat2, lon2, t, t, t, t, t, t);
269  }
270 
271  /**
272  * See the documentation for GeodesicLineExact::Position.
273  **********************************************************************/
274  Math::real Position(real s12, real& lat2, real& lon2,
275  real& azi2) const {
276  real t;
277  return GenPosition(false, s12,
278  LATITUDE | LONGITUDE | AZIMUTH,
279  lat2, lon2, azi2, t, t, t, t, t);
280  }
281 
282  /**
283  * See the documentation for GeodesicLineExact::Position.
284  **********************************************************************/
285  Math::real Position(real s12, real& lat2, real& lon2,
286  real& azi2, real& m12) const {
287  real t;
288  return GenPosition(false, s12,
289  LATITUDE | LONGITUDE |
290  AZIMUTH | REDUCEDLENGTH,
291  lat2, lon2, azi2, t, m12, t, t, t);
292  }
293 
294  /**
295  * See the documentation for GeodesicLineExact::Position.
296  **********************************************************************/
297  Math::real Position(real s12, real& lat2, real& lon2,
298  real& azi2, real& M12, real& M21)
299  const {
300  real t;
301  return GenPosition(false, s12,
302  LATITUDE | LONGITUDE |
303  AZIMUTH | GEODESICSCALE,
304  lat2, lon2, azi2, t, t, M12, M21, t);
305  }
306 
307  /**
308  * See the documentation for GeodesicLineExact::Position.
309  **********************************************************************/
311  real& lat2, real& lon2, real& azi2,
312  real& m12, real& M12, real& M21)
313  const {
314  real t;
315  return GenPosition(false, s12,
316  LATITUDE | LONGITUDE | AZIMUTH |
317  REDUCEDLENGTH | GEODESICSCALE,
318  lat2, lon2, azi2, t, m12, M12, M21, t);
319  }
320  ///@}
321 
322  /** \name Position in terms of arc length
323  **********************************************************************/
324  ///@{
325 
326  /**
327  * Compute the position of point 2 which is an arc length \e a12 (degrees)
328  * from point 1.
329  *
330  * @param[in] a12 arc length from point 1 to point 2 (degrees); it can
331  * be signed.
332  * @param[out] lat2 latitude of point 2 (degrees).
333  * @param[out] lon2 longitude of point 2 (degrees); requires that the
334  * GeodesicLineExact object was constructed with \e caps |=
335  * GeodesicLineExact::LONGITUDE.
336  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
337  * @param[out] s12 distance from point 1 to point 2 (meters); requires
338  * that the GeodesicLineExact object was constructed with \e caps |=
339  * GeodesicLineExact::DISTANCE.
340  * @param[out] m12 reduced length of geodesic (meters); requires that the
341  * GeodesicLineExact object was constructed with \e caps |=
342  * GeodesicLineExact::REDUCEDLENGTH.
343  * @param[out] M12 geodesic scale of point 2 relative to point 1
344  * (dimensionless); requires that the GeodesicLineExact object was
345  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
346  * @param[out] M21 geodesic scale of point 1 relative to point 2
347  * (dimensionless); requires that the GeodesicLineExact object was
348  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
349  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
350  * that the GeodesicLineExact object was constructed with \e caps |=
351  * GeodesicLineExact::AREA.
352  *
353  * The values of \e lon2 and \e azi2 returned are in the range
354  * [&minus;180&deg;, 180&deg;].
355  *
356  * Requesting a value which the GeodesicLineExact object is not capable of
357  * computing is not an error; the corresponding argument will not be
358  * altered.
359  *
360  * The following functions are overloaded versions of
361  * GeodesicLineExact::ArcPosition which omit some of the output parameters.
362  **********************************************************************/
363  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
364  real& s12, real& m12, real& M12, real& M21,
365  real& S12) const {
366  GenPosition(true, a12,
367  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
368  REDUCEDLENGTH | GEODESICSCALE | AREA,
369  lat2, lon2, azi2, s12, m12, M12, M21, S12);
370  }
371 
372  /**
373  * See the documentation for GeodesicLineExact::ArcPosition.
374  **********************************************************************/
375  void ArcPosition(real a12, real& lat2, real& lon2)
376  const {
377  real t;
378  GenPosition(true, a12,
379  LATITUDE | LONGITUDE,
380  lat2, lon2, t, t, t, t, t, t);
381  }
382 
383  /**
384  * See the documentation for GeodesicLineExact::ArcPosition.
385  **********************************************************************/
386  void ArcPosition(real a12,
387  real& lat2, real& lon2, real& azi2)
388  const {
389  real t;
390  GenPosition(true, a12,
391  LATITUDE | LONGITUDE | AZIMUTH,
392  lat2, lon2, azi2, t, t, t, t, t);
393  }
394 
395  /**
396  * See the documentation for GeodesicLineExact::ArcPosition.
397  **********************************************************************/
398  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
399  real& s12) const {
400  real t;
401  GenPosition(true, a12,
402  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE,
403  lat2, lon2, azi2, s12, t, t, t, t);
404  }
405 
406  /**
407  * See the documentation for GeodesicLineExact::ArcPosition.
408  **********************************************************************/
409  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
410  real& s12, real& m12) const {
411  real t;
412  GenPosition(true, a12,
413  LATITUDE | LONGITUDE | AZIMUTH |
414  DISTANCE | REDUCEDLENGTH,
415  lat2, lon2, azi2, s12, m12, t, t, t);
416  }
417 
418  /**
419  * See the documentation for GeodesicLineExact::ArcPosition.
420  **********************************************************************/
421  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
422  real& s12, real& M12, real& M21)
423  const {
424  real t;
425  GenPosition(true, a12,
426  LATITUDE | LONGITUDE | AZIMUTH |
427  DISTANCE | GEODESICSCALE,
428  lat2, lon2, azi2, s12, t, M12, M21, t);
429  }
430 
431  /**
432  * See the documentation for GeodesicLineExact::ArcPosition.
433  **********************************************************************/
434  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
435  real& s12, real& m12, real& M12, real& M21)
436  const {
437  real t;
438  GenPosition(true, a12,
439  LATITUDE | LONGITUDE | AZIMUTH |
440  DISTANCE | REDUCEDLENGTH | GEODESICSCALE,
441  lat2, lon2, azi2, s12, m12, M12, M21, t);
442  }
443  ///@}
444 
445  /** \name The general position function.
446  **********************************************************************/
447  ///@{
448 
449  /**
450  * The general position function. GeodesicLineExact::Position and
451  * GeodesicLineExact::ArcPosition are defined in terms of this function.
452  *
453  * @param[in] arcmode boolean flag determining the meaning of the second
454  * parameter; if \e arcmode is false, then the GeodesicLineExact object
455  * must have been constructed with \e caps |=
456  * GeodesicLineExact::DISTANCE_IN.
457  * @param[in] s12_a12 if \e arcmode is false, this is the distance between
458  * point 1 and point 2 (meters); otherwise it is the arc length between
459  * point 1 and point 2 (degrees); it can be signed.
460  * @param[in] outmask a bitor'ed combination of GeodesicLineExact::mask
461  * values specifying which of the following parameters should be set.
462  * @param[out] lat2 latitude of point 2 (degrees).
463  * @param[out] lon2 longitude of point 2 (degrees); requires that the
464  * GeodesicLineExact object was constructed with \e caps |=
465  * GeodesicLineExact::LONGITUDE.
466  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
467  * @param[out] s12 distance from point 1 to point 2 (meters); requires
468  * that the GeodesicLineExact object was constructed with \e caps |=
469  * GeodesicLineExact::DISTANCE.
470  * @param[out] m12 reduced length of geodesic (meters); requires that the
471  * GeodesicLineExact object was constructed with \e caps |=
472  * GeodesicLineExact::REDUCEDLENGTH.
473  * @param[out] M12 geodesic scale of point 2 relative to point 1
474  * (dimensionless); requires that the GeodesicLineExact object was
475  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
476  * @param[out] M21 geodesic scale of point 1 relative to point 2
477  * (dimensionless); requires that the GeodesicLineExact object was
478  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
479  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
480  * that the GeodesicLineExact object was constructed with \e caps |=
481  * GeodesicLineExact::AREA.
482  * @return \e a12 arc length from point 1 to point 2 (degrees).
483  *
484  * The GeodesicLineExact::mask values possible for \e outmask are
485  * - \e outmask |= GeodesicLineExact::LATITUDE for the latitude \e lat2;
486  * - \e outmask |= GeodesicLineExact::LONGITUDE for the latitude \e lon2;
487  * - \e outmask |= GeodesicLineExact::AZIMUTH for the latitude \e azi2;
488  * - \e outmask |= GeodesicLineExact::DISTANCE for the distance \e s12;
489  * - \e outmask |= GeodesicLineExact::REDUCEDLENGTH for the reduced length
490  * \e m12;
491  * - \e outmask |= GeodesicLineExact::GEODESICSCALE for the geodesic scales
492  * \e M12 and \e M21;
493  * - \e outmask |= GeodesicLineExact::AREA for the area \e S12;
494  * - \e outmask |= GeodesicLineExact::ALL for all of the above;
495  * - \e outmask |= GeodesicLineExact::LONG_UNROLL to unroll \e lon2 instead
496  * of wrapping it into the range [&minus;180&deg;, 180&deg;].
497  * .
498  * Requesting a value which the GeodesicLineExact object is not capable of
499  * computing is not an error; the corresponding argument will not be
500  * altered. Note, however, that the arc length is always computed and
501  * returned as the function value.
502  *
503  * With the GeodesicLineExact::LONG_UNROLL bit set, the quantity \e lon2
504  * &minus; \e lon1 indicates how many times and in what sense the geodesic
505  * encircles the ellipsoid.
506  **********************************************************************/
507  Math::real GenPosition(bool arcmode, real s12_a12, unsigned outmask,
508  real& lat2, real& lon2, real& azi2,
509  real& s12, real& m12, real& M12, real& M21,
510  real& S12) const;
511  ///@}
512 
513  /** \name Setting point 3
514  **********************************************************************/
515  ///@{
516 
517  /**
518  * Specify position of point 3 in terms of distance.
519  *
520  * @param[in] s13 the distance from point 1 to point 3 (meters); it
521  * can be negative.
522  *
523  * This is only useful if the GeodesicLineExact object has been constructed
524  * with \e caps |= GeodesicLineExact::DISTANCE_IN.
525  **********************************************************************/
526  void SetDistance(real s13);
527 
528  /**
529  * Specify position of point 3 in terms of arc length.
530  *
531  * @param[in] a13 the arc length from point 1 to point 3 (degrees); it
532  * can be negative.
533  *
534  * The distance \e s13 is only set if the GeodesicLineExact object has been
535  * constructed with \e caps |= GeodesicLineExact::DISTANCE.
536  **********************************************************************/
537  void SetArc(real a13);
538 
539  /**
540  * Specify position of point 3 in terms of either distance or arc length.
541  *
542  * @param[in] arcmode boolean flag determining the meaning of the second
543  * parameter; if \e arcmode is false, then the GeodesicLineExact object
544  * must have been constructed with \e caps |=
545  * GeodesicLineExact::DISTANCE_IN.
546  * @param[in] s13_a13 if \e arcmode is false, this is the distance from
547  * point 1 to point 3 (meters); otherwise it is the arc length from
548  * point 1 to point 3 (degrees); it can be negative.
549  **********************************************************************/
550  void GenSetDistance(bool arcmode, real s13_a13);
551 
552  /** \name Inspector functions
553  **********************************************************************/
554  ///@{
555 
556  /**
557  * @return true if the object has been initialized.
558  **********************************************************************/
559  bool Init() const { return _caps != 0U; }
560 
561  /**
562  * @return \e lat1 the latitude of point 1 (degrees).
563  **********************************************************************/
565  { return Init() ? _lat1 : Math::NaN(); }
566 
567  /**
568  * @return \e lon1 the longitude of point 1 (degrees).
569  **********************************************************************/
571  { return Init() ? _lon1 : Math::NaN(); }
572 
573  /**
574  * @return \e azi1 the azimuth (degrees) of the geodesic line at point 1.
575  **********************************************************************/
577  { return Init() ? _azi1 : Math::NaN(); }
578 
579  /**
580  * The sine and cosine of \e azi1.
581  *
582  * @param[out] sazi1 the sine of \e azi1.
583  * @param[out] cazi1 the cosine of \e azi1.
584  **********************************************************************/
585  void Azimuth(real& sazi1, real& cazi1) const
586  { if (Init()) { sazi1 = _salp1; cazi1 = _calp1; } }
587 
588  /**
589  * @return \e azi0 the azimuth (degrees) of the geodesic line as it crosses
590  * the equator in a northward direction.
591  *
592  * The result lies in [&minus;90&deg;, 90&deg;].
593  **********************************************************************/
595  { return Init() ? Math::atan2d(_salp0, _calp0) : Math::NaN(); }
596 
597  /**
598  * The sine and cosine of \e azi0.
599  *
600  * @param[out] sazi0 the sine of \e azi0.
601  * @param[out] cazi0 the cosine of \e azi0.
602  **********************************************************************/
603  void EquatorialAzimuth(real& sazi0, real& cazi0) const
604  { if (Init()) { sazi0 = _salp0; cazi0 = _calp0; } }
605 
606  /**
607  * @return \e a1 the arc length (degrees) between the northward equatorial
608  * crossing and point 1.
609  *
610  * The result lies in [&minus;180&deg;, 180&deg;].
611  **********************************************************************/
613  using std::atan2;
614  return Init() ? atan2(_ssig1, _csig1) / Math::degree() : Math::NaN();
615  }
616 
617  /**
618  * @return \e a the equatorial radius of the ellipsoid (meters). This is
619  * the value inherited from the GeodesicExact object used in the
620  * constructor.
621  **********************************************************************/
623  { return Init() ? _a : Math::NaN(); }
624 
625  /**
626  * @return \e f the flattening of the ellipsoid. This is the value
627  * inherited from the GeodesicExact object used in the constructor.
628  **********************************************************************/
630  { return Init() ? _f : Math::NaN(); }
631 
632  /**
633  * @return \e caps the computational capabilities that this object was
634  * constructed with. LATITUDE and AZIMUTH are always included.
635  **********************************************************************/
636  unsigned Capabilities() const { return _caps; }
637 
638  /**
639  * Test what capabilities are available.
640  *
641  * @param[in] testcaps a set of bitor'ed GeodesicLineExact::mask values.
642  * @return true if the GeodesicLineExact object has all these capabilities.
643  **********************************************************************/
644  bool Capabilities(unsigned testcaps) const {
645  testcaps &= OUT_ALL;
646  return (_caps & testcaps) == testcaps;
647  }
648 
649  /**
650  * The distance or arc length to point 3.
651  *
652  * @param[in] arcmode boolean flag determining the meaning of returned
653  * value.
654  * @return \e s13 if \e arcmode is false; \e a13 if \e arcmode is true.
655  **********************************************************************/
656  Math::real GenDistance(bool arcmode) const
657  { return Init() ? (arcmode ? _a13 : _s13) : Math::NaN(); }
658 
659  /**
660  * @return \e s13, the distance to point 3 (meters).
661  **********************************************************************/
662  Math::real Distance() const { return GenDistance(false); }
663 
664  /**
665  * @return \e a13, the arc length to point 3 (degrees).
666  **********************************************************************/
667  Math::real Arc() const { return GenDistance(true); }
668  ///@}
669 
670  };
671 
672 } // namespace GeographicLib
673 
674 #endif // GEOGRAPHICLIB_GEODESICLINEEXACT_HPP
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:67
Header for GeographicLib::EllipticFunction class.
GeographicLib::Math::real real
Definition: GeodSolve.cpp:31
Header for GeographicLib::GeodesicExact class.
Elliptic integrals and functions.
Exact geodesic calculations.
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2) const
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12) const
void EquatorialAzimuth(real &sazi0, real &cazi0) const
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &M12, real &M21) const
void ArcPosition(real a12, real &lat2, real &lon2) const
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &M12, real &M21) const
Math::real GenDistance(bool arcmode) const
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21) const
Math::real Position(real s12, real &lat2, real &lon2) const
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12) const
bool Capabilities(unsigned testcaps) const
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21) const
void Azimuth(real &sazi1, real &cazi1) const
Math::real Position(real s12, real &lat2, real &lon2, real &azi2) const
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12) const
static T degree()
Definition: Math.hpp:200
static T atan2d(T y, T x)
Definition: Math.cpp:183
static T NaN()
Definition: Math.cpp:250
Namespace for GeographicLib.
Definition: Accumulator.cpp:12