gmath.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. *
  3. * NMEA library
  4. * URL: http://nmea.sourceforge.net
  5. * Author: Tim (xtimor@gmail.com)
  6. * Licence: http://www.gnu.org/licenses/lgpl.html
  7. * $Id: gmath.h 17 2008-03-11 11:56:11Z xtimor $
  8. *
  9. */
  10. #ifndef __NMEA_GMATH_H__
  11. #define __NMEA_GMATH_H__
  12. #include "info.h"
  13. #define NMEA_PI (3.141592653589793) /**< PI value */
  14. #define NMEA_PI180 (NMEA_PI / 180) /**< PI division by 180 */
  15. #define NMEA_EARTHRADIUS_KM (6378) /**< Earth's mean radius in km */
  16. #define NMEA_EARTHRADIUS_M (NMEA_EARTHRADIUS_KM * 1000) /**< Earth's mean radius in m */
  17. #define NMEA_EARTH_SEMIMAJORAXIS_M (6378137.0) /**< Earth's semi-major axis in m according WGS84 */
  18. #define NMEA_EARTH_SEMIMAJORAXIS_KM (NMEA_EARTHMAJORAXIS_KM / 1000) /**< Earth's semi-major axis in km according WGS 84 */
  19. #define NMEA_EARTH_FLATTENING (1 / 298.257223563) /**< Earth's flattening according WGS 84 */
  20. #define NMEA_DOP_FACTOR (5) /**< Factor for translating DOP to meters */
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /*
  25. * degree VS radian
  26. */
  27. double nmea_degree2radian(double val);
  28. double nmea_radian2degree(double val);
  29. /*
  30. * NDEG (NMEA degree)
  31. */
  32. double nmea_ndeg2degree(double val);
  33. double nmea_degree2ndeg(double val);
  34. double nmea_ndeg2radian(double val);
  35. double nmea_radian2ndeg(double val);
  36. /*
  37. * DOP
  38. */
  39. double nmea_calc_pdop(double hdop, double vdop);
  40. double nmea_dop2meters(double dop);
  41. double nmea_meters2dop(double meters);
  42. /*
  43. * positions work
  44. */
  45. void nmea_info2pos(const nmeaINFO *info, nmeaPOS *pos);
  46. void nmea_pos2info(const nmeaPOS *pos, nmeaINFO *info);
  47. double nmea_distance(
  48. const nmeaPOS *from_pos,
  49. const nmeaPOS *to_pos
  50. );
  51. double nmea_distance_ellipsoid(
  52. const nmeaPOS *from_pos,
  53. const nmeaPOS *to_pos,
  54. double *from_azimuth,
  55. double *to_azimuth
  56. );
  57. int nmea_move_horz(
  58. const nmeaPOS *start_pos,
  59. nmeaPOS *end_pos,
  60. double azimuth,
  61. double distance
  62. );
  63. int nmea_move_horz_ellipsoid(
  64. const nmeaPOS *start_pos,
  65. nmeaPOS *end_pos,
  66. double azimuth,
  67. double distance,
  68. double *end_azimuth
  69. );
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif /* __NMEA_GMATH_H__ */