choclo.utils.distance_spherical_core

choclo.utils.distance_spherical_core#

choclo.utils.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

Important

All longitudinal angles must be in degrees.

It 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 latitude, and the radius in meters. Precomputing this quantities may save computation time on some cases.

Parameters:
longitude_pfloat

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

cosphi_pfloat

Cosine of the latitude coordinate of the first point.

sinphi_pfloat

Sine of the 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 latitude coordinate of the second point.

sinphi_qfloat

Sine of the latitude coordinate of the second point.

radius_qfloat

Radial coordinate of the second point.

Returns:
distancefloat

Distance between the two points.

cospsifloat

Cosine of the psi angle.

coslambdafloat

Cosine of the diference between the longitudes of both points.

Notes

Given two points \(\mathbf{p} = (\lambda_p, \phi_p, r_p)\) and \(\mathbf{q} = (\lambda_q, \phi_q, r_q)\) defined in a spherical coordinate system \((\lambda, \phi, r)\), return the Euclidean (L2) distance between them:

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

the cosine of the \(\psi\) angle:

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

and the cosine of the difference between the longitude angles of the observation and source points:

\[\cos(\lambda_p - \lambda_q),\]

where \(\lambda\) is the longitude angle, \(\phi\) the spherical latitude angle an \(r\) is the radial coordinate.