PostGIS  2.1.10dev-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 3043 of file lwgeodetic.c.

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

Referenced by edge_intersects().

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

Here is the call graph for this function:

Here is the caller graph for this function: