# choclo.utils.distance_spherical_core#

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_p (float) – Longitude coordinate of the first point. Must be in radians.

• cosphi_p (float) – Cosine of the latitude coordinate of the first point.

• sinphi_p (float) – Sine of the latitude coordinate of the first point.

• longitude_q (float) – Longitude coordinate of the second point. Must be in radians.

• cosphi_q (float) – Cosine of the latitude coordinate of the second point.

• sinphi_q (float) – Sine of the latitude coordinate of the second point.

Returns

• distance (float) – Distance between the two points.

• cospsi (float) – Cosine of the psi angle.

• coslambda (float) – 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.