41 const double sin_lat = sin(def->
lla.
lat);
42 const double cos_lat = cos(def->
lla.
lat);
43 const double sin_lon = sin(def->
lla.
lon);
44 const double cos_lon = cos(def->
lla.
lon);
65 const double sin_lat = sin(def->
lla.
lat);
66 const double cos_lat = cos(def->
lla.
lat);
67 const double sin_lon = sin(def->
lla.
lon);
68 const double cos_lon = cos(def->
lla.
lon);
87 static const double a = 6378137.0;
88 static const double f = 1. / 298.257223563;
89 const double b = a * (1. - f);
90 const double b2 = b * b;
92 const double e2 = 2.*f - (f * f);
93 const double ep2 = f * (2. - f) / ((1. - f) * (1. - f));
94 const double E2 = a * a - b2;
97 const double z2 = ecef->
z * ecef->
z;
98 const double r2 = ecef->
x * ecef->
x + ecef->
y * ecef->
y;
99 const double r = sqrt(r2);
100 const double F = 54.*b2 * z2;
101 const double G = r2 + (1 - e2) * z2 - e2 * E2;
102 const double c = (e2 * e2 * F * r2) / (G * G * G);
103 const double s = pow((1 + c + sqrt(c * c + 2 * c)), 1. / 3.);
104 const double s1 = 1 + s + 1 / s;
105 const double P = F / (3 * s1 * s1 * G * G);
106 const double Q = sqrt(1 + 2 * e2 * e2 * P);
107 const double ro = -(e2 * P * r) / (1 + Q) + sqrt((a * a / 2) * (1 + 1 / Q) - ((1 - e2) * P * z2) / (Q *
108 (1 + Q)) - P * r2 / 2);
109 const double tmp = (r - e2 * ro) * (r - e2 * ro);
110 const double U = sqrt(tmp + z2);
111 const double V = sqrt(tmp + (1 - e2) * z2);
112 const double zo = (b2 * ecef->
z) / (a * V);
114 lla->
alt = U * (1 - b2 / (a * V));
115 lla->
lat = atan((ecef->
z + ep2 * zo) / r);
116 lla->
lon = atan2(ecef->
y, ecef->
x);
124 static const double a = 6378137.0;
125 static const double f = 1. / 298.257223563;
126 const double e2 = 2.*f - (f * f);
128 const double sin_lat = sin(lla->
lat);
129 const double cos_lat = cos(lla->
lat);
130 const double sin_lon = sin(lla->
lon);
131 const double cos_lon = cos(lla->
lon);
132 const double chi = sqrt(1. - e2 * sin_lat * sin_lat);
133 const double a_chi = a / chi;
135 ecef->
x = (a_chi + lla->
alt) * cos_lat * cos_lon;
136 ecef->
y = (a_chi + lla->
alt) * cos_lat * sin_lon;
137 ecef->
z = (a_chi * (1. - e2) + lla->
alt) * sin_lat;
212 const double a = 6378137.0;
213 const double f = 1. / 298.257223563;
214 const double c2 = (1. - f) * (1. - f);
216 double ls = atan(c2 * tan(gd_lat));
217 return atan2(hmsl * sin(gd_lat) + a * sin(ls), hmsl * cos(gd_lat) + a * cos(ls));
225 return log(tan(M_PI_4 + phi / 2.0)) - e / 2.0 * log((1.0 + e * sin(phi)) / (1.0 - e * sin(phi)));
230 return log(tan(M_PI_4 + phi / 2.0));
235 double exp_l = exp(lat);
236 double phi0 = 2 * atan(exp_l) - M_PI_2;
242 double sin_phi = e * sin(phi_);
243 phi0 = 2 * atan(pow((1 + sin_phi) / (1. - sin_phi), e / 2.) * exp_l) - M_PI_2;
245 }
while (max_iter && fabs(phi_ - phi0) > epsilon);
257 double e = exp(v.x);\
264 struct DoubleVect2 vstar = {-v.x, -v.y}; \
267 VECT2_SUB(v, vstar);\
268 VECT2_SMUL(v, v, -0.5); \
279 if (utm->
zone == 0) {
285 double dl = lla->
lon - lambda_c;
286 double phi_ = asin(sin(dl) / cosh(ll));
288 double lambda_ = atan(sinh(ll) / cos(dl));
292 for (k = 1; k < 3; k++) {
328 lla->
lon = lambda_c + atan(sinh(z.
y) / cos(z.
x));
329 double phi = asin(sin(z.
x) / cosh(z.
y));
#define VECT3_ADD(_a, _b)
vector in North East Down coordinates Units: meters
void ecef_of_ned_vect_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct NedCoor_d *ned)
position in UTM coordinates Units: meters
double gc_of_gd_lat_d(double gd_lat, double hmsl)
#define VECT3_COPY(_a, _b)
struct DoubleRMat ltp_of_ecef
rotation from ECEF to local frame
#define VECT3_DIFF(_c, _a, _b)
double alt
in meters above WGS84 reference ellipsoid
static double inverse_isometric_latitude_d(double lat, double e, double epsilon)
struct LlaCoor_d lla
origin of local frame in LLA
double alt
in meters (above WGS84 reference ellipsoid or above MSL)
vector in Latitude, Longitude and Altitude
void ecef_of_ned_point_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct NedCoor_d *ned)
#define VECT2_ADD(_a, _b)
void ecef_of_enu_point_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu)
#define ENU_OF_TO_NED(_po, _pi)
Paparazzi double-precision floating point math for geodetic calculations.
void enu_of_lla_point_d(struct EnuCoor_d *enu, struct LtpDef_d *def, struct LlaCoor_d *lla)
#define MAT33_VECT3_TRANSP_MUL(_vout, _mat, _vin)
vector in East North Up coordinates Units: meters
static const float serie_coeff_proj_mercator_inverse[5]
void enu_of_ecef_vect_d(struct EnuCoor_d *enu, struct LtpDef_d *def, struct EcefCoor_d *ecef)
static double isometric_latitude_fast_d(double phi)
static double isometric_latitude_d(double phi, double e)
definition of the local (flat earth) coordinate system
vector in EarthCenteredEarthFixed coordinates
void lla_of_ecef_d(struct LlaCoor_d *lla, struct EcefCoor_d *ecef)
void lla_of_utm_d(struct LlaCoor_d *lla, struct UtmCoor_d *utm)
#define LLA_COPY(_pos1, _pos2)
#define VECT2_SMUL(_vo, _vi, _s)
Constants UTM (Mercator) projections.
static const float scale[]
void ned_of_lla_point_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct LlaCoor_d *lla)
uint8_t zone
UTM zone number.
#define MAT33_VECT3_MUL(_vout, _mat, _vin)
void ltp_def_from_ecef_d(struct LtpDef_d *def, struct EcefCoor_d *ecef)
void ned_of_ecef_point_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef)
struct EcefCoor_d ecef
origin of local frame in ECEF
#define LambdaOfUtmZone(utm_zone)
static const float serie_coeff_proj_mercator[5]
void ecef_of_enu_vect_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu)
void utm_of_lla_d(struct UtmCoor_d *utm, struct LlaCoor_d *lla)
void ltp_def_from_lla_d(struct LtpDef_d *def, struct LlaCoor_d *lla)
void enu_of_ecef_point_d(struct EnuCoor_d *enu, struct LtpDef_d *def, struct EcefCoor_d *ecef)
void ecef_of_lla_d(struct EcefCoor_d *ecef, struct LlaCoor_d *lla)
void ned_of_ecef_vect_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef)
#define UtmZoneOfLlaLonRad(lla_lon)
#define VECT2_SUB(_a, _b)