-
Notifications
You must be signed in to change notification settings - Fork 2
/
ell2xyz.py
27 lines (24 loc) · 928 Bytes
/
ell2xyz.py
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
import math
def 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]
v = a/math.sqrt(1-e2*math.sin(lat)*math.sin(lat))
x = (v+h)*math.cos(lat)*math.cos(lon)
y = (v+h)*math.cos(lat)*math.sin(lon)
z = (v*(1-e2)+h)*math.sin(lat)
return(x, y, z)