PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ robust_cross_product()

void robust_cross_product ( const GEOGRAPHIC_POINT p,
const GEOGRAPHIC_POINT q,
POINT3D a 
)

Computes the cross product of two vectors using their lat, lng representations.

Good even for small distances between p and q.

Definition at line 630 of file lwgeodetic.c.

References GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by clairaut_geographic(), edge_distance_to_point(), edge_intersection(), edge_point_side(), sphere_angle(), and test_sphere_project().

631 {
632  double lon_qpp = (q->lon + p->lon) / -2.0;
633  double lon_qmp = (q->lon - p->lon) / 2.0;
634  double sin_p_lat_minus_q_lat = sin(p->lat-q->lat);
635  double sin_p_lat_plus_q_lat = sin(p->lat+q->lat);
636  double sin_lon_qpp = sin(lon_qpp);
637  double sin_lon_qmp = sin(lon_qmp);
638  double cos_lon_qpp = cos(lon_qpp);
639  double cos_lon_qmp = cos(lon_qmp);
640  a->x = sin_p_lat_minus_q_lat * sin_lon_qpp * cos_lon_qmp -
641  sin_p_lat_plus_q_lat * cos_lon_qpp * sin_lon_qmp;
642  a->y = sin_p_lat_minus_q_lat * cos_lon_qpp * cos_lon_qmp +
643  sin_p_lat_plus_q_lat * sin_lon_qpp * sin_lon_qmp;
644  a->z = cos(p->lat) * cos(q->lat) * sin(q->lon-p->lon);
645 }
double y
Definition: liblwgeom.h:340
double x
Definition: liblwgeom.h:340
double z
Definition: liblwgeom.h:340
Here is the caller graph for this function: