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_p
float Longitude coordinate of the first point. Must be in radians.
- cosphi_p
float Cosine of the geocentric latitude coordinate of the first point.
- sinphi_p
float Sine of the geocentric latitude coordinate of the first point.
- radius_p
float Radial coordinate of the first point.
- longitude_q
float Longitude coordinate of the second point. Must be in radians.
- cosphi_q
float Cosine of the geocentric latitude coordinate of the second point.
- sinphi_q
float Sine of the geocentric latitude coordinate of the second point.
- radius_q
float Radial coordinate of the second point.
- longitude_p
- Returns:
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).\]