forked from kevinsan1/Lab-6-GNSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fGC2GL.m
executable file
·38 lines (31 loc) · 891 Bytes
/
fGC2GL.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
36
37
38
function [latb longb h] = fGC2GL(XYZ)
% This function takes a vector with ECEF cartesian coordinates and transform
% them into ellipsoidal coordinates (longitude,latitude and height).
%
% lolah=fGeoCen2GeoLat(XYZ)
%
% INPUT:
% XYZ - Cartesian coordinates
%
% OUTPUT:
% laloh - [Latitude (rad) Longitude (rad) Height (m)] on ellipsoid WGS 84
% help fGC2GL;
% Function written by Johan Vium Andersson
% Last updated 2005-02-22
% reference ellipsoid data WGS84
a=6378137;
f=1/298.257223563;
X = XYZ(1);
Y = XYZ(2);
Z = XYZ(3);
% Program
b=a-f*a;
ee=(a^2-b^2)/a^2;
p=sqrt(X^2+Y^2);
tata=atan(Z/(p*sqrt(1-ee)));
longb=atan(Y/X);
latb=atan((Z+((a*ee)/sqrt(1-ee))*sin(tata)^3)/(p-a*ee*(cos(tata))^3));
N=a/sqrt(1-ee*(sin(latb))^2);
% resultat
h = p/cos(latb)-N;
laloh =[latb longb h];