Algorithm 需要解释ecef到enu算法吗

Algorithm 需要解释ecef到enu算法吗,algorithm,gps,coordinates,Algorithm,Gps,Coordinates,我在网站上找到了一些有用的坐标转换代码 然而,在EcefToEnu函数中有一点我并不清楚 // Converts the Earth-Centered Earth-Fixed (ECEF) coordinates (x, y, z) to // East-North-Up coordinates in a Local Tangent Plane that is centered at the // (WGS-84) Geodetic point (lat0, lon0, h0). publi

我在网站上找到了一些有用的坐标转换代码

然而,在EcefToEnu函数中有一点我并不清楚

// Converts the Earth-Centered Earth-Fixed (ECEF) coordinates (x, y, z) to 
// East-North-Up coordinates in a Local Tangent Plane that is centered at the 
// (WGS-84) Geodetic point (lat0, lon0, h0).
public static void EcefToEnu(double x, double y, double z,
                                double lat0, double lon0, double h0,
                                out double xEast, out double yNorth, out double zUp)
{
    // Convert to radians in notation consistent with the paper:
    var lambda = DegreesToRadians(lat0);
    var phi = DegreesToRadians(lon0);
    var s = Sin(lambda);
    var N = a / Sqrt(1 - e_sq * s * s);

    var sin_lambda = Sin(lambda);
    var cos_lambda = Cos(lambda);
    var cos_phi = Cos(phi);
    var sin_phi = Sin(phi);

    double x0 = (h0 + N) * cos_lambda * cos_phi;
    double y0 = (h0 + N) * cos_lambda * sin_phi;
    double z0 = (h0 + (1 - e_sq) * N) * sin_lambda;

    double xd, yd, zd;
    xd = x - x0;
    yd = y - y0;
    zd = z - z0;

    // This is the matrix multiplication
    xEast = -sin_phi * xd + cos_phi * yd;
    yNorth = -cos_phi * sin_lambda * xd - sin_lambda * sin_phi * yd + cos_lambda * zd;
    zUp = cos_lambda * cos_phi * xd + cos_lambda * sin_phi * yd + sin_lambda * zd;
}
我得到了输入,前4条转换线,4条正弦波和余弦波,我得到了矩阵乘法——算法中有很多这样的例子。但我不清楚的是

    double x0 = (h0 + N) * cos_lambda * cos_phi;
    double y0 = (h0 + N) * cos_lambda * sin_phi;
    double z0 = (h0 + (1 - e_sq) * N) * sin_lambda;

    double xd, yd, zd;
    xd = x - x0;
    yd = y - y0;
    zd = z - z0;

我从我见过的任何算法中都看不出这一部分。这似乎是某种补偿,但除此之外,我不清楚公式来自何处,或者这段代码到底在做什么。有人能告诉我这段代码在做什么吗?我只是想了解我在看什么。

它们是从大地坐标(纬度,长,高)aka(φ,λ,h0)到ecef笛卡尔坐标(x0,y0,z0)的转换,然后计算ecef向量从(x0,y0,n0)到(x,y,z)

对于第一部分,请注意,如果椭球体是一个球体(e==0),那么第一部分将是从球面极到笛卡尔极的转换