forked from sglvladi/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathell2xyz.m
31 lines (28 loc) · 974 Bytes
/
ell2xyz.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
function [x,y,z]=ell2xyz(lat,lon,h,a,e2)
% ELL2XYZ Converts ellipsoidal coordinates to cartesian.
% Vectorized.
% Version: 2011-02-19
% Useage: [x,y,z]=ell2xyz(lat,lon,h,a,e2)
% [x,y,z]=ell2xyz(lat,lon,h)
% Input: lat - vector of ellipsoidal latitudes (radians)
% lon - vector of ellipsoidal E longitudes (radians)
% h - vector of ellipsoidal heights (m)
% a - ref. ellipsoid major semi-axis (m); default GRS80
% e2 - ref. ellipsoid eccentricity squared; default GRS80
% Output: x \
% y > vectors of cartesian coordinates in CT system (m)
% z /
% Copyright (c) 2011, Michael R. Craymer
% All rights reserved.
% Email: [email protected]
if nargin ~= 3 & nargin ~= 5
warning('Incorrect number of input arguments');
return
end
if nargin == 3
[a,b,e2]=refell('grs80');
end
v=a./sqrt(1-e2*sin(lat).*sin(lat));
x=(v+h).*cos(lat).*cos(lon);
y=(v+h).*cos(lat).*sin(lon);
z=(v.*(1-e2)+h).*sin(lat);