5.2.15. nvector.core.n_EA_E_and_p_AB_E2n_EB_E

n_EA_E_and_p_AB_E2n_EB_E(n_EA_E, p_AB_E, z_EA=0, a=6378137, f=0.0033528106647474805, R_Ee=None)[source]

Returns position B from position A and delta E vector.

Parameters
n_EA_E: 3 x n array

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

p_AB_E: 3 x n array

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

z_EA: 1 x n array

Depth(s) [m] of system A, relative to the ellipsoid. (z_EA = -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
n_EB_E: 3 x n array

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

z_EB: 1 x n array

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

Notes

The n-vector for position A (n_EA_E) and the position-vector from position A to position B (p_AB_E) are given. The output is the n-vector of position B (n_EB_E) and depth of B (z_EB). 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.

Example 2: “B and delta to C”

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

A radar or sonar attached to a vehicle B (Body coordinate frame) measures the distance and direction to an object C. We assume that the distance and two angles (typically bearing and elevation relative to B) are already combined to the vector p_BC_B (i.e. the vector from B to C, decomposed in B). The position of B is given as n_EB_E and z_EB, and the orientation (attitude) of B is given as R_NB (this rotation matrix can be found from roll/pitch/yaw by using zyx2R).

Find the exact position of object C as n-vector and depth ( n_EC_E and z_EC ), assuming Earth ellipsoid with semi-major axis a and flattening f. For WGS-72, use a = 6 378 135 m and f = 1/298.26.

Solution:
>>> import numpy as np
>>> import nvector as nv
>>> from nvector import rad, deg
A custom reference ellipsoid is given (replacing WGS-84):
>>> wgs72 = dict(a=6378135, f=1.0/298.26)
Step 1 Position and orientation of B is 400m above E:
>>> n_EB_E = nv.unit([[1], [2], [3]])  # unit to get unit length of vector
>>> z_EB = -400
>>> yaw, pitch, roll = rad(10), rad(20), rad(30)
>>> R_NB = nv.zyx2R(yaw, pitch, roll)
Step 2: Delta BC decomposed in B
>>> p_BC_B = np.r_[3000, 2000, 100].reshape((-1, 1))
Step 3: Find R_EN:
>>> R_EN = nv.n_E2R_EN(n_EB_E)
Step 4: Find R_EB, from R_EN and R_NB:
>>> R_EB = np.dot(R_EN, R_NB)  # Note: closest frames cancel
Step 5: Decompose the delta BC vector in E:
>>> p_BC_E = np.dot(R_EB, p_BC_B)
Step 6: Find the position of C, using the functions that goes from one
>>> n_EC_E, z_EC = nv.n_EA_E_and_p_AB_E2n_EB_E(n_EB_E, p_BC_E, z_EB, **wgs72)
>>> lat_EC, lon_EC = nv.n_E2lat_lon(n_EC_E)
>>> lat, lon, z = deg(lat_EC), deg(lon_EC), z_EC
>>> msg = 'Ex2: PosC: lat, lon = {:4.4f}, {:4.4f} deg,  height = {:4.2f} m'
>>> msg.format(lat[0], lon[0], -z[0])
'Ex2: PosC: lat, lon = 53.3264, 63.4681 deg,  height = 406.01 m'