5.2.3. nvector.core.euclidean_distance¶
-
euclidean_distance
(n_EA_E, n_EB_E, radius=6371009.0)[source]¶ Returns Euclidean distance between positions A and B
- Parameters
- n_EA_E, n_EB_E: 3 x n array
n-vector(s) [no unit] of position A and B, decomposed in E.
- radius: real scalar
radius of sphere.
Examples
Example 5: “Surface distance”
Find the surface distance sAB (i.e. great circle distance) between two positions A and B. The heights of A and B are ignored, i.e. if they don’t have zero height, we seek the distance between the points that are at the surface of the Earth, directly above/below A and B. The Euclidean distance (chord length) dAB should also be found. Use Earth radius 6371e3 m. Compare the results with exact calculations for the WGS-84 ellipsoid.
- Solution for a sphere:
>>> import numpy as np >>> import nvector as nv >>> from nvector import rad
>>> n_EA_E = nv.lat_lon2n_E(rad(88), rad(0)) >>> n_EB_E = nv.lat_lon2n_E(rad(89), rad(-170))
>>> r_Earth = 6371e3 # m, mean Earth radius >>> s_AB = nv.great_circle_distance(n_EA_E, n_EB_E, radius=r_Earth)[0] >>> d_AB = nv.euclidean_distance(n_EA_E, n_EB_E, radius=r_Earth)[0]
>>> msg = 'Ex5: Great circle and Euclidean distance = {}' >>> msg = msg.format('{:5.2f} km, {:5.2f} km') >>> msg.format(s_AB / 1000, d_AB / 1000) 'Ex5: Great circle and Euclidean distance = 332.46 km, 332.42 km'
- Exact solution for the WGS84 ellipsoid:
>>> wgs84 = nv.FrameE(name='WGS84') >>> point1 = wgs84.GeoPoint(latitude=88, longitude=0, degrees=True) >>> point2 = wgs84.GeoPoint(latitude=89, longitude=-170, degrees=True) >>> s_12, _azi1, _azi2 = point1.distance_and_azimuth(point2)
>>> p_12_E = point2.to_ecef_vector() - point1.to_ecef_vector() >>> d_12 = p_12_E.length >>> msg = 'Ellipsoidal and Euclidean distance = {:5.2f} km, {:5.2f} km' >>> msg.format(s_12 / 1000, d_12 / 1000) 'Ellipsoidal and Euclidean distance = 333.95 km, 333.91 km'