13 #define _MATH_DEFINES_DEFINED 25 #define C_NEG_MG_DIV_KT0_F -1.18558314779367E-04f // - (M * g) / (K * T0) 26 #define C_NEG_KT0_DIV_MG_F -8.43466779922578000E+03f // - (K * T0) / (M * g) 36 #define POWA2 40680631590769.000 // = pow(6378137.0,2) 37 #define POWB2 40408299984661.453 // = pow(6356752.31424518,2) 38 #define POWA2_F 40680631590769.000f // = pow(6378137.0,2) 39 #define POWB2_F 40408299984661.453f // = pow(6356752.31424518,2) 41 #define ONE_MINUS_F 0.996647189335253 // (1 - f), where f = 1.0 / 298.257223563 is Earth flattening 42 #define E_SQ 0.006694379990141 // e2 = 1 - (1-f)*(1-f) - square of first eccentricity 43 #define REQ 6378137.0 // Re - Equatorial radius, m 44 #define REP 6356752.314245179 // Rp - Polar radius, m 45 #define E2xREQ 42697.67270717795 // e2 * Re 46 #define E2xREQdivIFE 42841.31151331153 // e2 * Re / (1 -f) 47 #define GEQ 9.7803253359 // Equatorial gravity 48 #define K_GRAV 0.00193185265241 // defined gravity constants 49 #define K3_GRAV 3.0877e-6 // 50 #define K4_GRAV 4.0e-9 // 51 #define K5_GRAV 7.2e-14 // 54 void ecef2lla(
const double *Pe,
double *LLA,
const int Niter)
57 double s, Rn, sinmu, beta;
65 LLA[1] = atan2(Pe[1], Pe[0]);
69 s = sqrt(Pe[0] * Pe[0] + Pe[1] * Pe[1]);
75 for (i = 0; i < Niter; i++) {
77 LLA[0] = atan2(Pe[2] +
E2xREQdivIFE * pow(sin(beta), 3), s -
E2xREQ * pow(cos(beta), 3));
83 Rn =
REQ / sqrt(1.0 -
E_SQ * sinmu * sinmu);
86 LLA[2] = s * cos(LLA[0]) + (Pe[2] +
E_SQ * Rn * sinmu) * sinmu - Rn;
94 double Rn, Smu, Cmu, Sl, Cl;
108 Rn =
REQ / sqrt(1.0 -
E_SQ * Smu * Smu);
110 Pe[0] = (Rn + LLA[2]) * Cmu * Cl;
111 Pe[1] = (Rn + LLA[2]) * Cmu * Sl;
126 deltaLLA[0] = lla[0] - llaRef[0];
127 deltaLLA[1] = lla[1] - llaRef[1];
128 deltaLLA[2] = lla[2] - llaRef[2];
135 result[1] = deltaLLA[1] * EARTH_RADIUS_F *
_COS( llaRef[0] );
136 result[2] = -deltaLLA[2];
150 deltaLLA[0] = (
f_t)(lla[0] - llaRef[0]);
151 deltaLLA[1] = (
f_t)(lla[1] - llaRef[1]);
152 deltaLLA[2] = (
f_t)(lla[2] - llaRef[2]);
159 result[1] = deltaLLA[1] * EARTH_RADIUS_F *
_COS( ((
f_t)llaRef[0]) );
160 result[2] = -deltaLLA[2];
173 deltaLLA[0] = (
f_t)(lla[0] - llaRef[0]);
174 deltaLLA[1] = (
f_t)(lla[1] - llaRef[1]);
175 deltaLLA[2] = (
f_t)(lla[2] - llaRef[2]);
182 result[1] = deltaLLA[1] * DEG2RAD_EARTH_RADIUS_F *
_COS( ((
f_t)llaRef[0]) *
C_DEG2RAD_F );
183 result[2] = -deltaLLA[2];
200 result[0] = llaRef[0] + deltaLLA[0];
201 result[1] = llaRef[1] + deltaLLA[1];
202 result[2] = llaRef[2] + deltaLLA[2];
219 result[0] = llaRef[0] + deltaLLA[0];
220 result[1] = llaRef[1] + deltaLLA[1];
221 result[2] = llaRef[2] + deltaLLA[2];
238 result[0] = llaRef[0] + deltaLLA[0];
239 result[1] = llaRef[1] + deltaLLA[1];
240 result[2] = llaRef[2] + deltaLLA[2];
271 return _SQRT( ned[0]*ned[0] + ned[1]*ned[1] + ned[2]*ned[2] );
285 return _SQRT( ned[0]*ned[0] + ned[1]*ned[1] + ned[2]*ned[2] );
291 deltaLLA[1] = ned[1] * INV_EARTH_RADIUS_F /
_COS(((
f_t)llaRef[0]));
292 deltaLLA[2] = -ned[2];
298 deltaLLA[1] = (double)( ned[1] * INV_EARTH_RADIUS_F /
_COS(((
f_t)llaRef[0])) );
299 deltaLLA[2] = (double)(-ned[2]);
306 deltaLLA[2] = (double)(-ned[2]);
339 if( (lla[0]<-90.0) || (lla[0]>90.0) ||
340 (lla[1]<-180.0) || (lla[1]>180.0) ||
341 (lla[2]<-10000.0) || (lla[2]>1000000.0) )
363 sinmu2 = sin(lat) * sin(lat);
364 g0 =
GEQ * (1.0 +
K_GRAV * sinmu2) / sqrt(1.0 -
E_SQ * sinmu2);
void ned2DeltaLla_d(ixVector3 ned, double llaRef[3], double deltaLLA[3])
f_t llaDegDistance(double lla1[3], double lla2[3])
void ned2llaDeg_d(ixVector3 ned, double llaRef[3], double result[3])
void ned2lla(ixVector3 ned, ixVector3 llaRef, ixVector3 result)
void lla_Deg2Rad_d2(double result[3], double lat, double lon, double alt)
void lla2ned(ixVector3 llaRef, ixVector3 lla, ixVector3 result)
int llaDegValid(double lla[3])
#define C_NEG_KT0_DIV_MG_F
void lla_Rad2Deg_d(double result[3], double lla[3])
void lla2ecef(const double *LLA, double *Pe)
void ned2DeltaLla(ixVector3 ned, ixVector3 llaRef, ixVector3 deltaLLA)
void lla_Deg2Rad_d(double result[3], double lla[3])
#define INV_EARTH_RADIUS_F
void lla2ned_d(double llaRef[3], double lla[3], ixVector3 result)
void llaDeg2ned_d(double llaRef[3], double lla[3], ixVector3 result)
#define DEG2RAD_EARTH_RADIUS_F
void ecef2lla(const double *Pe, double *LLA, const int Niter)
f_t llaRadDistance(double lla1[3], double lla2[3])
void ned2lla_d(ixVector3 ned, double llaRef[3], double result[3])
void ned2DeltaLlaDeg_d(ixVector3 ned, double llaRef[3], double deltaLLA[3])
float gravity_igf80(double lat, double alt)
#define UNWRAP_DEG_F32(x)