OpenCPN Partial API docs
Loading...
Searching...
No Matches
geodesic.h
1#ifndef GEODESIC_H_
2#define GEODESIC_H_
3
4#define _USE_MATH_DEFINES
5//#include <cmath>
6//#include <math.h>
7
8#include <cstddef>
9
10#ifndef M_PI
11#define M_PI 3.1415926535897931160E0 /* pi */
12#endif
13
14#define GEODESIC_WGS84_SEMI_MAJORAXIS 6378137.0
15#define GEODESIC_WGS84_SEMI_MINORAXIS 6356752.3142
16#define GEODESIC_DEG2RAD(d) ((d) * (M_PI / 180.0))
17#define GEODESIC_RAD2DEG(r) ((r) * (180.0 / M_PI))
18#define GEODESIC_METERS2NM(m) ((m)*0.000539956803)
19#define GEODESIC_NM2METERS(nm) ((nm) / 0.000539956803)
20#define GEODESIC_METERS2FT(m) ((m)*3.2808399)
21#define GEODESIC_FT2METERS(ft) ((ft) / 3.2808399)
22#define GEODESIC_MPERS2KT(mpers) ((mpers)*1.9438445)
23#define GEODESIC_KT2MPERS(mpers) ((mpers) / 1.9438445)
24
25class Geodesic {
26 /* Find the distance (meters) and bearings between two Lon/Lat pairs (given in
27 * degrees) Results are in meters and degrees as appropriate
28 */
29public:
30 static double GreatCircleDistBear(double Lon1, double Lat1, double Lon2,
31 double Lat2, double *Dist = NULL,
32 double *Bear1 = NULL, double *Bear2 = NULL);
33 static void GreatCircleTravel(double Lon1, double Lat1, double Dist,
34 double Bear1, double *Lon2 = NULL,
35 double *Lat2 = NULL, double *Bear2 = NULL);
36};
37
38#endif /*GEODESIC_H_*/