Algorithm.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef ALGORITHM_H
  2. #define ALGORITHM_H
  3. //==============================================================================
  4. //
  5. // Algorithm - the gpx algorithm module
  6. //
  7. // Copyright (C) 2018 Dick van Oudheusden
  8. //
  9. // This library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Lesser General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 3 of the License, or (at your option) any later version.
  13. //
  14. // This library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. // Lesser General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU Lesser General Public
  20. // License along with this library; if not, write to the Free
  21. // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. //
  23. //==============================================================================
  24. #include <string>
  25. namespace gpx
  26. {
  27. ///
  28. /// @module Algorithm
  29. ///
  30. /// @brief The gpx algorithm module.
  31. ///
  32. ///
  33. /// Convert degrees to radians
  34. ///
  35. /// @param deg the degrees
  36. ///
  37. /// @return the radians
  38. ///
  39. double deg2rad(double deg);
  40. ///
  41. /// Convert radians to degrees
  42. ///
  43. /// @param rad the radians
  44. ///
  45. /// @return the degrees
  46. ///
  47. double rad2deg(double rad);
  48. ///
  49. /// Calculate the distance between two lat,long coordinates
  50. ///
  51. /// @param lat1deg the latitude of the first coordinate
  52. /// @param lon1deg the longitude of the first coordinate
  53. /// @param lat2deg the latitude of the second coordinate
  54. /// @param lon2deg the longitude of the second coordinate
  55. ///
  56. /// @return the distance in metres
  57. ///
  58. double calcDistance(double lat1deg, double lon1deg, double lat2deg, double lon2deg);
  59. ///
  60. /// Calculate the bearing between two lat,long coordinates
  61. ///
  62. /// @param lat1deg the latitude of the first coordinate
  63. /// @param lon1deg the longitude of the first coordinate
  64. /// @param lat2deg the latitude of the second coordinate
  65. /// @param lon2deg the longitude of the second coordinate
  66. ///
  67. /// @return the bearing in radians
  68. ///
  69. double calcBearing(double lat1deg, double lon1deg, double lat2deg, double lon2deg);
  70. ///
  71. /// Calculate the bearing between two lat,long coordinates
  72. ///
  73. /// @param lat1deg the latitude of the first coordinate
  74. /// @param lon1deg the longitude of the first coordinate
  75. /// @param lat2deg the latitude of the second coordinate
  76. /// @param lon2deg the longitude of the second coordinate
  77. ///
  78. /// @return the bearing in degrees
  79. ///
  80. double calcBearingInDeg(double lat1deg, double lon1deg, double lat2deg, double lon2deg);
  81. ///
  82. /// Calculate the crosstrack distance from the third coordinate to the line of the first two coordinates
  83. ///
  84. /// @param lat1deg the latitude of the first coordinate of the line
  85. /// @param lon1deg the longitude of the first coordinate of the line
  86. /// @param lat2deg the latitude of the second coordinate of the line
  87. /// @param lon2deg the longitude of the second coordinate of the line
  88. /// @param lat3deg the latitude of the third coordinate
  89. /// @param lon3deg the longitude of the third coordinate
  90. ///
  91. /// @return the crosstrack distance in metres
  92. ///
  93. double calcCrosstrack(double lat1deg, double lon1deg, double lat2deg, double lon2deg, double lat3deg, double lon3deg);
  94. }
  95. #endif