Skip to content

Commit 2512c97

Browse files
niwhsa9scivision
authored andcommitted
enu2ecefv
1 parent 0bb4350 commit 2512c97

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/pymap3d/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
uvw2enu,
4545
)
4646
from .ellipsoid import Ellipsoid
47-
from .enu import aer2enu, enu2aer, enu2geodetic, geodetic2enu
47+
from .enu import aer2enu, enu2aer, enu2geodetic, geodetic2enu, enu2ecefv
4848
from .ned import (
4949
aer2ned,
5050
ecef2ned,
@@ -76,6 +76,7 @@
7676
"aer2enu",
7777
"enu2aer",
7878
"enu2geodetic",
79+
"enu2ecefv",
7980
"geodetic2enu",
8081
"aer2ned",
8182
"ecef2ned",

src/pymap3d/enu.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .ellipsoid import Ellipsoid
1313
from .mathfun import atan2, cos, degrees, hypot, radians, sin
1414

15-
__all__ = ["enu2aer", "aer2enu", "enu2geodetic", "geodetic2enu"]
15+
__all__ = ["enu2aer", "aer2enu", "enu2geodetic", "geodetic2enu", "enu2ecefv"]
1616

1717
ELL = Ellipsoid.from_name("wgs84")
1818

@@ -202,3 +202,43 @@ def geodetic2enu(
202202
x2, y2, z2 = geodetic2ecef(lat0, lon0, h0, ell, deg=deg)
203203

204204
return uvw2enu(x1 - x2, y1 - y2, z1 - z2, lat0, lon0, deg=deg)
205+
206+
207+
def enu2ecefv(e, n, u, lat0, lon0, deg: bool = True) -> tuple:
208+
"""
209+
VECTOR from observer to target ENU => ECEF
210+
211+
Parameters
212+
----------
213+
e
214+
target e ENU coordinate
215+
n
216+
target n ENU coordinate
217+
u
218+
target u ENU coordinate
219+
lat0
220+
Observer geodetic latitude
221+
lon0
222+
Observer geodetic longitude
223+
deg : bool, optional
224+
degrees input/output (False: radians in/out)
225+
226+
Returns
227+
-------
228+
x
229+
target x ECEF coordinate
230+
y
231+
target y ECEF coordinate
232+
z
233+
target z ECEF coordinate
234+
235+
"""
236+
if deg:
237+
lat0 = radians(lat0)
238+
lon0 = radians(lon0)
239+
240+
x = -sin(lon0) * e - sin(lat0) * cos(lon0) * n + cos(lat0) * cos(lon0) * u
241+
y = cos(lon0) * e - sin(lat0) * sin(lon0) * n + cos(lat0) * sin(lon0) * u
242+
z = cos(lat0) * n + sin(lat0) * u
243+
244+
return x, y, z

src/pymap3d/tests/test_ned.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_enuv_nedv():
2424
vx, vy, vz = (5, 3, 2)
2525
ve, vn, vu = (5.368859646588048, 3.008520763668120, -0.352347711524077)
2626
assert pm.ecef2enuv(vx, vy, vz, *lla0[:2]) == approx((ve, vn, vu))
27+
assert pm.enu2ecefv(ve, vn, vu, *lla0[:2]) == approx((vx, vy, vz))
2728

2829
assert pm.ecef2nedv(vx, vy, vz, *lla0[:2]) == approx((vn, ve, -vu))
2930

0 commit comments

Comments
 (0)