我正在研究pArk Apple 示例代码,以及它是如何工作的。任何人都知道如何将纬度和经度转换为 ECEF 坐标,以及将 ECEF 转换为以给定纬度为中心的 ENU 坐标,经度函数有效吗?我只是想了解这个函数发生了什么!
谢谢。
void latLonToEcef(double lat, double lon, double alt, double *x, double *y, double *z)
{
double clat = cos(lat * DEGREES_TO_RADIANS);
double slat = sin(lat * DEGREES_TO_RADIANS);
double clon = cos(lon * DEGREES_TO_RADIANS);
double slon = sin(lon * DEGREES_TO_RADIANS);
double N = WGS84_A / sqrt(1.0 - WGS84_E * WGS84_E * slat * slat);
*x = (N + alt) * clat * clon;
*y = (N + alt) * clat * slon;
*z = (N * (1.0 - WGS84_E * WGS84_E) + alt) * slat;
}
// Coverts ECEF to ENU coordinates centered at given lat, lon
void ecefToEnu(double lat, double lon, double x, double y, double z, double xr, double yr, double zr, double *e, double *n, double *u)
{
double clat = cos(lat * DEGREES_TO_RADIANS);
double slat = sin(lat * DEGREES_TO_RADIANS);
double clon = cos(lon * DEGREES_TO_RADIANS);
double slon = sin(lon * DEGREES_TO_RADIANS);
double dx = x - xr;
double dy = y - yr;
double dz = z - zr;
*e = -slon*dx + clon*dy;
*n = -slat*clon*dx - slat*slon*dy + clat*dz;
*u = clat*clon*dx + clat*slon*dy + slat*dz;
}