PostGIS  2.2.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 3046 of file lwgeodetic.c.

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

Referenced by edge_intersects().

3047 {
3048  POINT3D AC; /* Center point of A1/A2 */
3049  double min_similarity, similarity;
3050 
3051  /* The normalized sum bisects the angle between start and end. */
3052  vector_sum(A1, A2, &AC);
3053  normalize(&AC);
3054 
3055  /* The projection of start onto the center defines the minimum similarity */
3056  min_similarity = dot_product(A1, &AC);
3057 
3058  /* The projection of candidate p onto the center */
3059  similarity = dot_product(P, &AC);
3060 
3061  /* If the point is more similar than the end, the point is in the cone */
3062  if ( similarity > min_similarity || fabs(similarity - min_similarity) < 2e-16 )
3063  {
3064  return LW_TRUE;
3065  }
3066  return LW_FALSE;
3067 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:565
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:396
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
void vector_sum(const POINT3D *a, const POINT3D *b, POINT3D *n)
Calculate the sum of two vectors.
Definition: lwgeodetic.c:415
Here is the call graph for this function:
Here is the caller graph for this function: