matlab lla转Enu
时间: 2023-10-28 12:05:46 浏览: 473
matlab(XYZ坐标转ENU坐标)源码原创,ECEF空间坐标转测站坐标ENU
可以使用以下代码将LLA坐标转换为ENU坐标:
```
function [x,y,z] = lla2enu(lat,lon,alt,lat0,lon0,alt0)
% WGS84 ellipsoid constants
a = 6378137;
b = 6356752.314245;
f = (a - b) / a;
e_sq = f * (2-f);
% convert to radians
lat = deg2rad(lat);
lon = deg2rad(lon);
lat0 = deg2rad(lat0);
lon0 = deg2rad(lon0);
% intermediate calculation
N = a ./ sqrt(1 - e_sq .* sin(lat).^2);
% convert to ECEF
x = (N + alt) .* cos(lat) .* cos(lon);
y = (N + alt) .* cos(lat) .* sin(lon);
z = (N.*(1-e_sq) + alt) .* sin(lat);
% reference point in ECEF
xr = (N(lat0) + alt0) .* cos(lat0) .* cos(lon0);
yr = (N(lat0) + alt0) .* cos(lat0) .* sin(lon0);
zr = (N(lat0).*(1-e_sq) + alt0) .* sin(lat0);
% convert to ENU
dx = x - xr;
dy = y - yr;
dz = z - zr;
R = [-sin(lon0) cos(lon0) 0; ...
-cos(lon0)*sin(lat0) -sin(lat0)*sin(lon0) cos(lat0); ...
cos(lat0)*cos(lon0) cos(lat0)*sin(lon0) sin(lat0)];
enu = R * [dx; dy; dz];
x = enu(1);
y = enu(2);
z = enu(3);
end
```
其中,输入参数为:纬度(lat)、经度(lon)、高度(alt)、参考点的纬度(lat0)、经度(lon0)和高度(alt0)。输出参数为:东向距离(x)、北向距离(y)和天向距离(z)。
阅读全文