PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ sphere_signed_area()

static double sphere_signed_area ( const GEOGRAPHIC_POINT a,
const GEOGRAPHIC_POINT b,
const GEOGRAPHIC_POINT c 
)
static

Computes the spherical area of a triangle.

If C is to the left of A/B, the area is negative. If C is to the right of A/B, the area is positive.

Parameters
aThe first triangle vertex.
bThe second triangle vertex.
cThe last triangle vertex.
Returns
the signed area in radians.

Definition at line 741 of file lwgeodetic.c.

742 {
743  double angle_a, angle_b, angle_c;
744  double area_radians = 0.0;
745  int side;
746  GEOGRAPHIC_EDGE e;
747 
748  angle_a = sphere_angle(b,a,c);
749  angle_b = sphere_angle(a,b,c);
750  angle_c = sphere_angle(b,c,a);
751 
752  area_radians = angle_a + angle_b + angle_c - M_PI;
753 
754  /* What's the direction of the B/C edge? */
755  e.start = *a;
756  e.end = *b;
757  side = edge_point_side(&e, c);
758 
759  /* Co-linear points implies no area */
760  if ( side == 0 )
761  return 0.0;
762 
763  /* Add the sign to the area */
764  return side * area_radians;
765 }
static int edge_point_side(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
Returns -1 if the point is to the left of the plane formed by the edge, 1 if the point is to the righ...
Definition: lwgeodetic.c:694
static double sphere_angle(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const GEOGRAPHIC_POINT *c)
Returns the angle in radians at point B of the triangle formed by A-B-C.
Definition: lwgeodetic.c:721
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:63
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:64
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:62

References edge_point_side(), GEOGRAPHIC_EDGE::end, sphere_angle(), and GEOGRAPHIC_EDGE::start.

Referenced by ptarray_area_sphere().

Here is the call graph for this function:
Here is the caller graph for this function: