choclo.distance.distance_spherical_core

choclo.distance.distance_spherical_core#

choclo.distance.distance_spherical_core(longitude_p, cosphi_p, sinphi_p, radius_p, longitude_q, cosphi_q, sinphi_q, radius_q)[source]#

Core computation of distance between two points in spherical coordinates.

Computes the Euclidean distance between two points defined in spherical coordinates given precomputed quantities related to the coordinates of both points: the longitude in radians, the sine and cosine of the geocentric latitude, and the radius in meters. Precomputing this quantities may save computation time in some cases.

Important

All longitudinal angles must be in radians and radii in meters.

Parameters:
longitude_pfloat

Longitude coordinate of the first point. Must be in radians.

cosphi_pfloat

Cosine of the geocentric latitude coordinate of the first point.

sinphi_pfloat

Sine of the geocentric latitude coordinate of the first point.

radius_pfloat

Radial coordinate of the first point.

longitude_qfloat

Longitude coordinate of the second point. Must be in radians.

cosphi_qfloat

Cosine of the geocentric latitude coordinate of the second point.

sinphi_qfloat

Sine of the geocentric latitude coordinate of the second point.

radius_qfloat

Radial coordinate of the second point.

Returns:
distancefloat

Euclidean distance between point \(\mathbf{p}\) and point \(\mathbf{q}\) in meters.

cospsifloat

Cosine of the psi angle (see below).

coslambdafloat

Cosine of the difference between the longitudes of both points.

Notes

Consider two points \(\mathbf{p} = (\lambda_p, \phi_p, r_p)\) and \(\mathbf{q} = (\lambda_q, \phi_q, r_q)\). Both are defined on a geocentric spherical coordinate system (\(\lambda\) is the longitude, \(\phi\) is the geocentric latitude, and \(r\) is the radius). The Euclidean (L2) distance between them is:

\[d = \sqrt{ (r_p - r_q) ^ 2 + 2 r_p r_q (1 - \cos\psi)},\]

where

\[\cos\psi = \sin\phi_p \sin\phi_q + \cos\phi_p \cos\phi_q \cos(\lambda_p - \lambda_q).\]