我在https://gist.github.com/govert/1b373696c9a27ff4c72a找到了一些有用的坐标转换代码
但是,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条sin和cos行,并得到矩阵乘法-算法中有很多例子。但是我不清楚的是该部分
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;
我从所见过的任何算法中都看不到这一部分。它似乎有些偏移,但除此之外,我不清楚公式来自何处或这段代码究竟在做什么。有人可以请我启发一下这段代码在做什么吗?我只想了解我在看什么。
答案 0 :(得分:0)
它们是从大地坐标(lat,long,height)又名(phi,lambda,h0)到ecef笛卡尔坐标(x0,y0,z0)的转换,然后是从(x0,y0,n0 )至(x,y,z)。
对于第一部分,请注意,如果椭球是一个球体(e == 0),则第一部分将是从球形极向笛卡尔直角的转换