5.2.14. nvector.core.n_EA_E_and_n_EB_E2p_AB_E

n_EA_E_and_n_EB_E2p_AB_E(n_EA_E, n_EB_E, z_EA=0, z_EB=0, a=6378137, f=0.0033528106647474805, R_Ee=None)[source]

Returns the delta vector from position A to B decomposed in E.

Parameters
n_EA_E, n_EB_E: 3 x n array

n-vector(s) [no unit] of position A and B, decomposed in E.

z_EA, z_EB: 1 x n array

Depth(s) [m] of system A and B, relative to the ellipsoid. (z_EA = -height, z_EB = -height)

a: real scalar, default WGS-84 ellipsoid.

Semi-major axis of the Earth ellipsoid given in [m].

f: real scalar, default WGS-84 ellipsoid.

Flattening [no unit] of the Earth ellipsoid. If f==0 then spherical Earth with radius a is used in stead of WGS-84.

R_Ee3 x 3 array

rotation matrix defining the axes of the coordinate frame E.

Returns
p_AB_E: 3 x n array

Cartesian position vector(s) from A to B, decomposed in E.

Notes

The n-vectors for positions A (n_EA_E) and B (n_EB_E) are given. The output is the delta vector from A to B (p_AB_E). The calculation is excact, taking the ellipsity of the Earth into account. It is also non-singular as both n-vector and p-vector are non-singular (except for the center of the Earth). The default ellipsoid model used is WGS-84, but other ellipsoids/spheres might be specified.

Examples

Example 1: “A and B to delta”

https://raw.githubusercontent.com/pbrod/Nvector/master/docs/tutorials/images/ex1img.png

Given two positions, A and B as latitudes, longitudes and depths relative to Earth, E.

Find the exact vector between the two positions, given in meters north, east, and down, and find the direction (azimuth) to B, relative to north. Assume WGS-84 ellipsoid. The given depths are from the ellipsoid surface. Use position A to define north, east, and down directions. (Due to the curvature of Earth and different directions to the North Pole, the north, east, and down directions will change (relative to Earth) for different places. Position A must be outside the poles for the north and east directions to be defined.)

Solution:
>>> import numpy as np
>>> import nvector as nv
>>> from nvector import rad, deg
>>> lat_EA, lon_EA, z_EA = rad(1), rad(2), 3
>>> lat_EB, lon_EB, z_EB = rad(4), rad(5), 6
Step1: Convert to n-vectors:
>>> n_EA_E = nv.lat_lon2n_E(lat_EA, lon_EA)
>>> n_EB_E = nv.lat_lon2n_E(lat_EB, lon_EB)
Step2: Find p_AB_E (delta decomposed in E).WGS-84 ellipsoid is default:
>>> p_AB_E = nv.n_EA_E_and_n_EB_E2p_AB_E(n_EA_E, n_EB_E, z_EA, z_EB)
Step3: Find R_EN for position A:
>>> R_EN = nv.n_E2R_EN(n_EA_E)
Step4: Find p_AB_N (delta decomposed in N).
>>> p_AB_N = np.dot(R_EN.T, p_AB_E).ravel()
>>> x, y, z = p_AB_N
>>> 'Ex1: delta north, east, down = {0:8.2f}, {1:8.2f}, {2:8.2f}'.format(x, y, z)
'Ex1: delta north, east, down = 331730.23, 332997.87, 17404.27'
Step5: Also find the direction (azimuth) to B, relative to north:
>>> azimuth = np.arctan2(y, x)
>>> 'azimuth = {0:4.2f} deg'.format(deg(azimuth))
'azimuth = 45.11 deg'
>>> distance = np.linalg.norm(p_AB_N)
>>> elevation = np.arcsin(z / distance)
>>> 'elevation = {0:4.2f} deg'.format(deg(elevation))
'elevation = 2.12 deg'
>>> 'distance = {0:4.2f} m'.format(distance)
'distance = 470356.72 m'