PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ sphere_distance()

double sphere_distance ( const GEOGRAPHIC_POINT s,
const GEOGRAPHIC_POINT e 
)

Given two points on a unit sphere, calculate their distance apart in radians.

Definition at line 917 of file lwgeodetic.c.

References GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, and POW2.

Referenced by circ_internal_nodes_sort(), circ_node_internal_new(), circ_node_leaf_new(), circ_node_max_distance(), circ_node_min_distance(), circ_tree_distance_tree(), circ_tree_distance_tree_internal(), edge_calculate_gbox_slow(), edge_distance_to_point(), ptarray_distance_spheroid(), ptarray_length_spheroid(), ptarray_segmentize_sphere(), sphere_direction(), spheroid_distance(), test_sphere_direction(), and test_sphere_project().

918 {
919  double d_lon = e->lon - s->lon;
920  double cos_d_lon = cos(d_lon);
921  double cos_lat_e = cos(e->lat);
922  double sin_lat_e = sin(e->lat);
923  double cos_lat_s = cos(s->lat);
924  double sin_lat_s = sin(s->lat);
925 
926  double a1 = POW2(cos_lat_e * sin(d_lon));
927  double a2 = POW2(cos_lat_s * sin_lat_e - sin_lat_s * cos_lat_e * cos_d_lon);
928  double a = sqrt(a1 + a2);
929  double b = sin_lat_s * sin_lat_e + cos_lat_s * cos_lat_e * cos_d_lon;
930  return atan2(a, b);
931 }
#define POW2(x)
Definition: lwgeodetic.h:47
Here is the caller graph for this function: