PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ point_in_cone()

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 3057 of file lwgeodetic.c.

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

Referenced by edge_intersects().

3058 {
3059  POINT3D AC; /* Center point of A1/A2 */
3060  double min_similarity, similarity;
3061 
3062  /* The normalized sum bisects the angle between start and end. */
3063  vector_sum(A1, A2, &AC);
3064  normalize(&AC);
3065 
3066  /* The projection of start onto the center defines the minimum similarity */
3067  min_similarity = dot_product(A1, &AC);
3068 
3069  /* The projection of candidate p onto the center */
3070  similarity = dot_product(P, &AC);
3071 
3072  /* If the point is more similar than the end, the point is in the cone */
3073  if ( similarity > min_similarity || fabs(similarity - min_similarity) < 2e-16 )
3074  {
3075  return LW_TRUE;
3076  }
3077  return LW_FALSE;
3078 }
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: