-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathned2ecef.m
More file actions
36 lines (27 loc) · 710 Bytes
/
ned2ecef.m
File metadata and controls
36 lines (27 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function ecef = ned2ecef(ned, llh_org)
% Ali Mohammadi_INS/GNSS
% ecef2ned: converts from ECEF coordinates to NED coordinates.
%
% INPUTS
% ned: Nx3 NED coordinates [X Y Z] (m, m, m)
% llh_org: 1x3 system origin [lat, lon, h] (rad, rad, m).
%
% OUTPUTS
% ecef: Nx3 ECEF coordinates [X Y Z] (m, m, m).
%%
lat = llh_org(1);
lon = llh_org(2);
ecef_org = llh2ecef(llh_org)';
slat = sin(lat);
clat = cos(lat);
slon = sin(lon);
clon = cos(lon);
R = [ -slat*clon -slat*slon clat; ...
-slon clon 0; ...
-clat*clon -clat*slon -slat];
[MAX, N] = size(ned);
ecef = zeros(MAX, N);
for i=1:MAX
ecef_t = ecef_org + R' * ned(i, :)';
ecef (i, :) = ecef_t';
end