9 double coordsToMeter(
double lat1,
double lon1,
double lat2,
double lon2)
11 double dLat = (lat2 - lat1) * (M_PI / 180.0);
12 double dLon = (lon2 - lon1) * (M_PI / 180.0);
13 lat1 = lat1 * (M_PI/180.0);
14 lat2 = lat2 * (M_PI/180.0);
15 double a = sin(dLat/2.0) * sin(dLat/2.0) +
16 cos(lat1) * cos(lat2) * sin(dLon/2.0) * sin(dLon/2.0);
17 double c = 2.0 * atan2(sqrt(a), sqrt(1.0-a));
22 void coordAfterMotion(
double lat1,
double lon1,
double d,
double a,
double &newLat,
double &newLon)
28 lat1 = lat1 * (M_PI/180.0);
29 lon1 = lon1 * (M_PI/180.0);
30 newLat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(a));
34 newLon=fmod(lon1-asin(sin(a)*sin(d)/cos(newLat))+M_PI,2.0*M_PI)-M_PI;
35 newLat = newLat * (180.0/M_PI);
36 newLon = newLon * (180.0/M_PI);
42 void coordsToMetricXY(
double lat1,
double lon1,
double lat2,
double lon2,
double &dX,
double &dY)
44 dX = std::copysign(1.0, lon2-lon1) *
coordsToMeter(lat1, lon1, lat1, lon2);
45 dY = std::copysign(1.0, lat2-lat1) *
coordsToMeter(lat1, lon1, lat2, lon1);
constexpr double EARTHRADIUS_KM
void coordsToMetricXY(double lat1, double lon1, double lat2, double lon2, double &dX, double &dY)
Takes two GPS coordinates and outputs X and Y displacements.
double coordsToMeter(double lat1, double lon1, double lat2, double lon2)
void coordAfterMotion(double lat1, double lon1, double d, double a, double &newLat, double &newLon)