GeodesicLineExact.hpp 28 KB

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