forked from QIJINCHEN/IMA-estimation
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathblh2xyz.m
35 lines (33 loc) · 1.17 KB
/
blh2xyz.m
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 xyz = blh2xyz(e2, Rn, blh)
% -------------------------------------------------------------------------
%BLH2XYZ Convert from latitude, longitude and height
% to Earth-centered, Earth-fixed (ECEF) cartesian coordinates.
% xyz = blh2xyz(e2, Rn, blh)
%
%INPUTS:
% 1. e2 = square of the ellipticity of the reference Earth ellipse.
% 2. blh = position vector
% blh(1) = latitude in radians
% blh(2) = longitude in radians
% blh(3) = height above ellipsoid in meters
% 3. Rn = the radii of curvature along lines of constant latitude, in
% meters
%OUTPUTS:
% xyz(1) = ECEF x-coordinate in meters
% xyz(2) = ECEF y-coordinate in meters
% xyz(3) = ECEF z-coordinate in meters
% -------------------------------------------------------------------------
% Author:
% Qijin Chen, GNSS Research Center, Wuhan University, China.;
% Nov. 2019;
% -------------------------------------------------------------------------
c_lat = cos(blh(1));
s_lat = sin(blh(1));
c_lon = cos(blh(2));
s_lon = sin(blh(2));
Rn_h = Rn + blh(3);
xyz = [Rn_h*c_lat*c_lon;
Rn_h * c_lat * s_lon;
(Rn*(1-e2)+blh(3))*s_lat];
end