GeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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) <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_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  _A4, _B41, _E0, _D0, _H0, _E1, _D1, _H1;
47  real _C4a[nC4_]; // all the elements of _C4a are used
49  unsigned _caps;
50 
51  enum captype {
52  CAP_NONE = GeodesicExact::CAP_NONE,
53  CAP_E = GeodesicExact::CAP_E,
54  CAP_D = GeodesicExact::CAP_D,
55  CAP_H = GeodesicExact::CAP_H,
56  CAP_C4 = GeodesicExact::CAP_C4,
57  CAP_ALL = GeodesicExact::CAP_ALL,
58  OUT_ALL = GeodesicExact::OUT_ALL,
59  };
60  public:
61 
62  /**
63  * Bit masks for what calculations to do. They signify to the
64  * GeodesicLineExact::GeodesicLineExact constructor and to
65  * GeodesicExact::Line what capabilities should be included in the
66  * GeodesicLineExact object. This is merely a duplication of
67  * GeodesicExact::mask.
68  **********************************************************************/
69  enum mask {
70  /**
71  * No capabilities, no output.
72  * @hideinitializer
73  **********************************************************************/
75  /**
76  * Calculate latitude \e lat2. (It's not necessary to include this as a
77  * capability to GeodesicLineExact because this is included by default.)
78  * @hideinitializer
79  **********************************************************************/
81  /**
82  * Calculate longitude \e lon2.
83  * @hideinitializer
84  **********************************************************************/
86  /**
87  * Calculate azimuths \e azi1 and \e azi2. (It's not necessary to
88  * include this as a capability to GeodesicLineExact because this is
89  * included by default.)
90  * @hideinitializer
91  **********************************************************************/
93  /**
94  * Calculate distance \e s12.
95  * @hideinitializer
96  **********************************************************************/
98  /**
99  * Allow distance \e s12 to be used as input in the direct geodesic
100  * problem.
101  * @hideinitializer
102  **********************************************************************/
104  /**
105  * Calculate reduced length \e m12.
106  * @hideinitializer
107  **********************************************************************/
109  /**
110  * Calculate geodesic scales \e M12 and \e M21.
111  * @hideinitializer
112  **********************************************************************/
114  /**
115  * Calculate area \e S12.
116  * @hideinitializer
117  **********************************************************************/
119  /**
120  * All capabilities, calculate everything.
121  * @hideinitializer
122  **********************************************************************/
124  };
125 
126  /** \name Constructors
127  **********************************************************************/
128  ///@{
129 
130  /**
131  * Constructor for a geodesic line staring at latitude \e lat1, longitude
132  * \e lon1, and azimuth \e azi1 (all in degrees).
133  *
134  * @param[in] g A GeodesicExact object used to compute the necessary
135  * information about the GeodesicLineExact.
136  * @param[in] lat1 latitude of point 1 (degrees).
137  * @param[in] lon1 longitude of point 1 (degrees).
138  * @param[in] azi1 azimuth at point 1 (degrees).
139  * @param[in] caps bitor'ed combination of GeodesicLineExact::mask values
140  * specifying the capabilities the GeodesicLineExact object should
141  * possess, i.e., which quantities can be returned in calls to
142  * GeodesicLine::Position.
143  *
144  * \e lat1 should be in the range [&minus;90&deg;, 90&deg;]; \e lon1 and \e
145  * azi1 should be in the range [&minus;540&deg;, 540&deg;).
146  *
147  * The GeodesicLineExact::mask values are
148  * - \e caps |= GeodesicLineExact::LATITUDE for the latitude \e lat2; this
149  * is added automatically;
150  * - \e caps |= GeodesicLineExact::LONGITUDE for the latitude \e lon2;
151  * - \e caps |= GeodesicLineExact::AZIMUTH for the latitude \e azi2; this is
152  * added automatically;
153  * - \e caps |= GeodesicLineExact::DISTANCE for the distance \e s12;
154  * - \e caps |= GeodesicLineExact::REDUCEDLENGTH for the reduced length \e
155  m12;
156  * - \e caps |= GeodesicLineExact::GEODESICSCALE for the geodesic scales \e
157  * M12 and \e M21;
158  * - \e caps |= GeodesicLineExact::AREA for the area \e S12;
159  * - \e caps |= GeodesicLineExact::DISTANCE_IN permits the length of the
160  * geodesic to be given in terms of \e s12; without this capability the
161  * length can only be specified in terms of arc length;
162  * - \e caps |= GeodesicLineExact::ALL for all of the above.
163  * .
164  * The default value of \e caps is GeodesicLineExact::ALL.
165  *
166  * If the point is at a pole, the azimuth is defined by keeping \e lon1
167  * fixed, writing \e lat1 = &plusmn;(90&deg; &minus; &epsilon;), and taking
168  * the limit &epsilon; &rarr; 0+.
169  **********************************************************************/
170  GeodesicLineExact(const GeodesicExact& g, real lat1, real lon1, real azi1,
171  unsigned caps = ALL);
172 
173  /**
174  * A default constructor. If GeodesicLineExact::Position is called on the
175  * resulting object, it returns immediately (without doing any
176  * calculations). The object can be set with a call to
177  * GeodesicExact::Line. Use Init() to test whether object is still in this
178  * uninitialized state.
179  **********************************************************************/
180  GeodesicLineExact() : _caps(0U) {}
181  ///@}
182 
183  /** \name Position in terms of distance
184  **********************************************************************/
185  ///@{
186 
187  /**
188  * Compute the position of point 2 which is a distance \e s12 (meters)
189  * from point 1.
190  *
191  * @param[in] s12 distance between point 1 and point 2 (meters); it can be
192  * signed.
193  * @param[out] lat2 latitude of point 2 (degrees).
194  * @param[out] lon2 longitude of point 2 (degrees); requires that the
195  * GeodesicLineExact object was constructed with \e caps |=
196  * GeodesicLineExact::LONGITUDE.
197  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
198  * @param[out] m12 reduced length of geodesic (meters); requires that the
199  * GeodesicLineExact object was constructed with \e caps |=
200  * GeodesicLineExact::REDUCEDLENGTH.
201  * @param[out] M12 geodesic scale of point 2 relative to point 1
202  * (dimensionless); requires that the GeodesicLineExact object was
203  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
204  * @param[out] M21 geodesic scale of point 1 relative to point 2
205  * (dimensionless); requires that the GeodesicLineExact object was
206  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
207  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
208  * that the GeodesicLineExact object was constructed with \e caps |=
209  * GeodesicLineExact::AREA.
210  * @return \e a12 arc length of between point 1 and point 2 (degrees).
211  *
212  * The values of \e lon2 and \e azi2 returned are in the range
213  * [&minus;180&deg;, 180&deg;).
214  *
215  * The GeodesicLineExact object \e must have been constructed with \e caps
216  * |= GeodesicLineExact::DISTANCE_IN; otherwise Math::NaN() is returned and
217  * no parameters are set. Requesting a value which the GeodesicLineExact
218  * object is not capable of computing is not an error; the corresponding
219  * argument will not be altered.
220  *
221  * The following functions are overloaded versions of
222  * GeodesicLineExact::Position which omit some of the output parameters.
223  * Note, however, that the arc length is always computed and returned as
224  * the function value.
225  **********************************************************************/
227  real& lat2, real& lon2, real& azi2,
228  real& m12, real& M12, real& M21,
229  real& S12) const {
230  real t;
231  return GenPosition(false, s12,
232  LATITUDE | LONGITUDE | AZIMUTH |
233  REDUCEDLENGTH | GEODESICSCALE | AREA,
234  lat2, lon2, azi2, t, m12, M12, M21, S12);
235  }
236 
237  /**
238  * See the documentation for GeodesicLineExact::Position.
239  **********************************************************************/
240  Math::real Position(real s12, real& lat2, real& lon2) const {
241  real t;
242  return GenPosition(false, s12,
243  LATITUDE | LONGITUDE,
244  lat2, lon2, t, t, t, t, t, t);
245  }
246 
247  /**
248  * See the documentation for GeodesicLineExact::Position.
249  **********************************************************************/
250  Math::real Position(real s12, real& lat2, real& lon2,
251  real& azi2) const {
252  real t;
253  return GenPosition(false, s12,
254  LATITUDE | LONGITUDE | AZIMUTH,
255  lat2, lon2, azi2, t, t, t, t, t);
256  }
257 
258  /**
259  * See the documentation for GeodesicLineExact::Position.
260  **********************************************************************/
261  Math::real Position(real s12, real& lat2, real& lon2,
262  real& azi2, real& m12) const {
263  real t;
264  return GenPosition(false, s12,
265  LATITUDE | LONGITUDE |
266  AZIMUTH | REDUCEDLENGTH,
267  lat2, lon2, azi2, t, m12, t, t, t);
268  }
269 
270  /**
271  * See the documentation for GeodesicLineExact::Position.
272  **********************************************************************/
273  Math::real Position(real s12, real& lat2, real& lon2,
274  real& azi2, real& M12, real& M21)
275  const {
276  real t;
277  return GenPosition(false, s12,
278  LATITUDE | LONGITUDE |
279  AZIMUTH | GEODESICSCALE,
280  lat2, lon2, azi2, t, t, M12, M21, t);
281  }
282 
283  /**
284  * See the documentation for GeodesicLineExact::Position.
285  **********************************************************************/
287  real& lat2, real& lon2, real& azi2,
288  real& m12, real& M12, real& M21)
289  const {
290  real t;
291  return GenPosition(false, s12,
292  LATITUDE | LONGITUDE | AZIMUTH |
293  REDUCEDLENGTH | GEODESICSCALE,
294  lat2, lon2, azi2, t, m12, M12, M21, t);
295  }
296 
297  ///@}
298 
299  /** \name Position in terms of arc length
300  **********************************************************************/
301  ///@{
302 
303  /**
304  * Compute the position of point 2 which is an arc length \e a12 (degrees)
305  * from point 1.
306  *
307  * @param[in] a12 arc length between point 1 and point 2 (degrees); it can
308  * be signed.
309  * @param[out] lat2 latitude of point 2 (degrees).
310  * @param[out] lon2 longitude of point 2 (degrees); requires that the
311  * GeodesicLineExact object was constructed with \e caps |=
312  * GeodesicLineExact::LONGITUDE.
313  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
314  * @param[out] s12 distance between point 1 and point 2 (meters); requires
315  * that the GeodesicLineExact object was constructed with \e caps |=
316  * GeodesicLineExact::DISTANCE.
317  * @param[out] m12 reduced length of geodesic (meters); requires that the
318  * GeodesicLineExact object was constructed with \e caps |=
319  * GeodesicLineExact::REDUCEDLENGTH.
320  * @param[out] M12 geodesic scale of point 2 relative to point 1
321  * (dimensionless); requires that the GeodesicLineExact object was
322  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
323  * @param[out] M21 geodesic scale of point 1 relative to point 2
324  * (dimensionless); requires that the GeodesicLineExact object was
325  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
326  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
327  * that the GeodesicLineExact object was constructed with \e caps |=
328  * GeodesicLineExact::AREA.
329  *
330  * The values of \e lon2 and \e azi2 returned are in the range
331  * [&minus;180&deg;, 180&deg;).
332  *
333  * Requesting a value which the GeodesicLineExact object is not capable of
334  * computing is not an error; the corresponding argument will not be
335  * altered.
336  *
337  * The following functions are overloaded versions of
338  * GeodesicLineExact::ArcPosition which omit some of the output parameters.
339  **********************************************************************/
340  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
341  real& s12, real& m12, real& M12, real& M21,
342  real& S12) const {
343  GenPosition(true, a12,
344  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE |
345  REDUCEDLENGTH | GEODESICSCALE | AREA,
346  lat2, lon2, azi2, s12, m12, M12, M21, S12);
347  }
348 
349  /**
350  * See the documentation for GeodesicLineExact::ArcPosition.
351  **********************************************************************/
352  void ArcPosition(real a12, real& lat2, real& lon2)
353  const {
354  real t;
355  GenPosition(true, a12,
356  LATITUDE | LONGITUDE,
357  lat2, lon2, t, t, t, t, t, t);
358  }
359 
360  /**
361  * See the documentation for GeodesicLineExact::ArcPosition.
362  **********************************************************************/
363  void ArcPosition(real a12,
364  real& lat2, real& lon2, real& azi2)
365  const {
366  real t;
367  GenPosition(true, a12,
368  LATITUDE | LONGITUDE | AZIMUTH,
369  lat2, lon2, azi2, t, t, t, t, t);
370  }
371 
372  /**
373  * See the documentation for GeodesicLineExact::ArcPosition.
374  **********************************************************************/
375  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
376  real& s12) const {
377  real t;
378  GenPosition(true, a12,
379  LATITUDE | LONGITUDE | AZIMUTH | DISTANCE,
380  lat2, lon2, azi2, s12, t, t, t, t);
381  }
382 
383  /**
384  * See the documentation for GeodesicLineExact::ArcPosition.
385  **********************************************************************/
386  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
387  real& s12, real& m12) const {
388  real t;
389  GenPosition(true, a12,
390  LATITUDE | LONGITUDE | AZIMUTH |
391  DISTANCE | REDUCEDLENGTH,
392  lat2, lon2, azi2, s12, m12, 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, real& M12, real& M21)
400  const {
401  real t;
402  GenPosition(true, a12,
403  LATITUDE | LONGITUDE | AZIMUTH |
404  DISTANCE | GEODESICSCALE,
405  lat2, lon2, azi2, s12, t, M12, M21, t);
406  }
407 
408  /**
409  * See the documentation for GeodesicLineExact::ArcPosition.
410  **********************************************************************/
411  void ArcPosition(real a12, real& lat2, real& lon2, real& azi2,
412  real& s12, real& m12, real& M12, real& M21)
413  const {
414  real t;
415  GenPosition(true, a12,
416  LATITUDE | LONGITUDE | AZIMUTH |
417  DISTANCE | REDUCEDLENGTH | GEODESICSCALE,
418  lat2, lon2, azi2, s12, m12, M12, M21, t);
419  }
420  ///@}
421 
422  /** \name The general position function.
423  **********************************************************************/
424  ///@{
425 
426  /**
427  * The general position function. GeodesicLineExact::Position and
428  * GeodesicLineExact::ArcPosition are defined in terms of this function.
429  *
430  * @param[in] arcmode boolean flag determining the meaning of the second
431  * parameter; if arcmode is false, then the GeodesicLineExact object must
432  * have been constructed with \e caps |= GeodesicLineExact::DISTANCE_IN.
433  * @param[in] s12_a12 if \e arcmode is false, this is the distance between
434  * point 1 and point 2 (meters); otherwise it is the arc length between
435  * point 1 and point 2 (degrees); it can be signed.
436  * @param[in] outmask a bitor'ed combination of GeodesicLineExact::mask
437  * values specifying which of the following parameters should be set.
438  * @param[out] lat2 latitude of point 2 (degrees).
439  * @param[out] lon2 longitude of point 2 (degrees); requires that the
440  * GeodesicLineExact object was constructed with \e caps |=
441  * GeodesicLineExact::LONGITUDE.
442  * @param[out] azi2 (forward) azimuth at point 2 (degrees).
443  * @param[out] s12 distance between point 1 and point 2 (meters); requires
444  * that the GeodesicLineExact object was constructed with \e caps |=
445  * GeodesicLineExact::DISTANCE.
446  * @param[out] m12 reduced length of geodesic (meters); requires that the
447  * GeodesicLineExact object was constructed with \e caps |=
448  * GeodesicLineExact::REDUCEDLENGTH.
449  * @param[out] M12 geodesic scale of point 2 relative to point 1
450  * (dimensionless); requires that the GeodesicLineExact object was
451  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
452  * @param[out] M21 geodesic scale of point 1 relative to point 2
453  * (dimensionless); requires that the GeodesicLineExact object was
454  * constructed with \e caps |= GeodesicLineExact::GEODESICSCALE.
455  * @param[out] S12 area under the geodesic (meters<sup>2</sup>); requires
456  * that the GeodesicLineExact object was constructed with \e caps |=
457  * GeodesicLineExact::AREA.
458  * @return \e a12 arc length of between point 1 and point 2 (degrees).
459  *
460  * The GeodesicLineExact::mask values possible for \e outmask are
461  * - \e outmask |= GeodesicLineExact::LATITUDE for the latitude \e lat2;
462  * - \e outmask |= GeodesicLineExact::LONGITUDE for the latitude \e lon2;
463  * - \e outmask |= GeodesicLineExact::AZIMUTH for the latitude \e azi2;
464  * - \e outmask |= GeodesicLineExact::DISTANCE for the distance \e s12;
465  * - \e outmask |= GeodesicLineExact::REDUCEDLENGTH for the reduced length
466  * \e m12;
467  * - \e outmask |= GeodesicLineExact::GEODESICSCALE for the geodesic scales
468  * \e M12 and \e M21;
469  * - \e outmask |= GeodesicLineExact::AREA for the area \e S12;
470  * - \e outmask |= GeodesicLine::ALL for all of the above.
471  * .
472  * Requesting a value which the GeodesicLineExact object is not capable of
473  * computing is not an error; the corresponding argument will not be
474  * altered. Note, however, that the arc length is always computed and
475  * returned as the function value.
476  **********************************************************************/
477  Math::real GenPosition(bool arcmode, real s12_a12, unsigned outmask,
478  real& lat2, real& lon2, real& azi2,
479  real& s12, real& m12, real& M12, real& M21,
480  real& S12) const;
481 
482  ///@}
483 
484  /** \name Inspector functions
485  **********************************************************************/
486  ///@{
487 
488  /**
489  * @return true if the object has been initialized.
490  **********************************************************************/
491  bool Init() const { return _caps != 0U; }
492 
493  /**
494  * @return \e lat1 the latitude of point 1 (degrees).
495  **********************************************************************/
497  { return Init() ? _lat1 : Math::NaN(); }
498 
499  /**
500  * @return \e lon1 the longitude of point 1 (degrees).
501  **********************************************************************/
503  { return Init() ? _lon1 : Math::NaN(); }
504 
505  /**
506  * @return \e azi1 the azimuth (degrees) of the geodesic line at point 1.
507  **********************************************************************/
509  { return Init() ? _azi1 : Math::NaN(); }
510 
511  /**
512  * @return \e azi0 the azimuth (degrees) of the geodesic line as it crosses
513  * the equator in a northward direction.
514  **********************************************************************/
516  using std::atan2;
517  return Init() ?
518  atan2(_salp0, _calp0) / Math::degree() : Math::NaN();
519  }
520 
521  /**
522  * @return \e a1 the arc length (degrees) between the northward equatorial
523  * crossing and point 1.
524  **********************************************************************/
526  using std::atan2;
527  return Init() ?
528  atan2(_ssig1, _csig1) / Math::degree() : Math::NaN();
529  }
530 
531  /**
532  * @return \e a the equatorial radius of the ellipsoid (meters). This is
533  * the value inherited from the GeodesicExact object used in the
534  * constructor.
535  **********************************************************************/
537  { return Init() ? _a : Math::NaN(); }
538 
539  /**
540  * @return \e f the flattening of the ellipsoid. This is the value
541  * inherited from the GeodesicExact object used in the constructor.
542  **********************************************************************/
544  { return Init() ? _f : Math::NaN(); }
545 
546  /// \cond SKIP
547  /**
548  * <b>DEPRECATED</b>
549  * @return \e r the inverse flattening of the ellipsoid.
550  **********************************************************************/
551  Math::real InverseFlattening() const
552  { return Init() ? 1/_f : Math::NaN(); }
553  /// \endcond
554 
555  /**
556  * @return \e caps the computational capabilities that this object was
557  * constructed with. LATITUDE and AZIMUTH are always included.
558  **********************************************************************/
559  unsigned Capabilities() const { return _caps; }
560 
561  /**
562  * @param[in] testcaps a set of bitor'ed GeodesicLineExact::mask values.
563  * @return true if the GeodesicLineExact object has all these capabilities.
564  **********************************************************************/
565  bool Capabilities(unsigned testcaps) const {
566  testcaps &= OUT_ALL;
567  return (_caps & testcaps) == testcaps;
568  }
569  ///@}
570 
571  };
572 
573 } // namespace GeographicLib
574 
575 #endif // GEOGRAPHICLIB_GEODESICLINEEXACT_HPP
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2) const
static T NaN()
Definition: Math.hpp:460
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12) const
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:70
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &M12, real &M21) const
Elliptic integrals and functions.
void ArcPosition(real a12, real &lat2, real &lon2) 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
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21) const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
Header for GeographicLib::EllipticFunction class.
Math::real Position(real s12, real &lat2, real &lon2, real &azi2) const
static T degree()
Definition: Math.hpp:227
Exact geodesic calculations.
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &M12, real &M21) const
Header for GeographicLib::GeodesicExact class.
Header for GeographicLib::Constants class.
bool Capabilities(unsigned testcaps) 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) const