PostGIS  2.5.0dev-r@@SVN_REVISION@@
static int point_in_cone ( const POINT3D A1,
const POINT3D A2,
const POINT3D P 
)
static

Utility function for checking if P is within the cone defined by A1/A2.

Definition at line 3358 of file lwgeodetic.c.

References dot_product(), LW_FALSE, LW_TRUE, normalize(), and vector_sum().

Referenced by edge_intersects().

3359 {
3360  POINT3D AC; /* Center point of A1/A2 */
3361  double min_similarity, similarity;
3362 
3363  /* The normalized sum bisects the angle between start and end. */
3364  vector_sum(A1, A2, &AC);
3365  normalize(&AC);
3366 
3367  /* The projection of start onto the center defines the minimum similarity */
3368  min_similarity = dot_product(A1, &AC);
3369 
3370  /* The projection of candidate p onto the center */
3371  similarity = dot_product(P, &AC);
3372 
3373  /* If the point is more similar than the end, the point is in the cone */
3374  if ( similarity > min_similarity || fabs(similarity - min_similarity) < 2e-16 )
3375  {
3376  return LW_TRUE;
3377  }
3378  return LW_FALSE;
3379 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:580
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:411
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
void vector_sum(const POINT3D *a, const POINT3D *b, POINT3D *n)
Calculate the sum of two vectors.
Definition: lwgeodetic.c:430

Here is the call graph for this function:

Here is the caller graph for this function: