PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int edge_point_side ( const GEOGRAPHIC_EDGE e,

Returns -1 if the point is to the left of the plane formed by the edge, 1 if the point is to the right, and 0 if the point is on the plane.

Definition at line 643 of file lwgeodetic.c.

References dot_product(), GEOGRAPHIC_EDGE::end, FP_IS_ZERO, geog2cart(), LWDEBUG, LWDEBUGF, normalize(), robust_cross_product(), and GEOGRAPHIC_EDGE::start.

Referenced by edge_point_on_plane(), and sphere_signed_area().

644 {
645  POINT3D normal, pt;
646  double w;
647  /* Normal to the plane defined by e */
648  robust_cross_product(&(e->start), &(e->end), &normal);
649  normalize(&normal);
650  geog2cart(p, &pt);
651  /* We expect the dot product of with normal with any vector in the plane to be zero */
652  w = dot_product(&normal, &pt);
653  LWDEBUGF(4,"dot product %.9g",w);
654  if ( FP_IS_ZERO(w) )
655  {
656  LWDEBUG(4, "point is on plane (dot product is zero)");
657  return 0;
658  }
660  if ( w < 0 )
661  return -1;
662  else
663  return 1;
664 }
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.
Definition: lwgeodetic.c:583
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:564
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define FP_IS_ZERO(A)
static double dot_product(const POINT3D *p1, const POINT3D *p2)
Convert cartesion coordinates on unit sphere to lon/lat coordinates static void cart2ll(const POINT3D...
Definition: lwgeodetic.c:397
Definition: lwgeodetic.h:44
Definition: lwgeodetic.h:45
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesion coordinates on unit sphere.
Definition: lwgeodetic.c:355
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55

Here is the call graph for this function:

Here is the caller graph for this function: