-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathllh2ecef.m
More file actions
35 lines (26 loc) · 640 Bytes
/
llh2ecef.m
File metadata and controls
35 lines (26 loc) · 640 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 = llh2ecef(llh)
% Ali Mohammadi_INS/GNSS
% llh2ecef: converts from navigation coordinates (latitude, longitude and
% altitude) to ECEF coordinates.
%
% INPUTS
% llh: Nx3 LLH coordinates [lat, lon, h] (rad, rad, m).
%
% OUTPUTS
% ned: Nx3 NED coordinates [X Y Z] (m, m, m).
%%
% Preallocate
ecef = zeros(size(llh));
lat = llh(:,1);
lon = llh(:,2);
h = llh(:,3);
[~,RN] = radius(lat);
e = 0.0818191908426; % Eccentricity
slat = sin(lat);
clat = cos(lat);
clon = cos(lon);
slon = sin(lon);
ecef(:,1) = (RN + h) .* clat .* clon;
ecef(:,2) = (RN + h) .* clat .* slon;
ecef(:,3) = (RN *(1-e^2) + h) .* slat;
end