PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lw_dist3d_pt_pt()

int lw_dist3d_pt_pt ( POINT3DZ thep1,
POINT3DZ thep2,
DISTPTS3D dl 
)

Compares incomming points and stores the points closest to each other or most far away from each other depending on dl->mode (max or min)

Definition at line 835 of file measures3d.c.

References DISTPTS3D::distance, LW_TRUE, LWDEBUGF, DISTPTS3D::mode, DISTPTS3D::p1, DISTPTS3D::p2, DISTPTS3D::twisted, POINT3DZ::x, POINT3DZ::y, and POINT3DZ::z.

Referenced by lw_dist3d_point_point(), lw_dist3d_pt_poly(), lw_dist3d_pt_seg(), lw_dist3d_ptarray_ptarray(), and lw_dist3d_seg_seg().

836 {
837  double dx = thep2->x - thep1->x;
838  double dy = thep2->y - thep1->y;
839  double dz = thep2->z - thep1->z;
840  double dist = sqrt ( dx*dx + dy*dy + dz*dz);
841  LWDEBUGF(2, "lw_dist3d_pt_pt called (with points: p1.x=%f, p1.y=%f,p1.z=%f,p2.x=%f, p2.y=%f,p2.z=%f)",thep1->x,thep1->y,thep1->z,thep2->x,thep2->y,thep2->z );
842 
843  if (((dl->distance - dist)*(dl->mode))>0) /*multiplication with mode to handle mindistance (mode=1) and maxdistance (mode = (-1)*/
844  {
845  dl->distance = dist;
846 
847  if (dl->twisted>0) /*To get the points in right order. twisted is updated between 1 and (-1) every time the order is changed earlier in the chain*/
848  {
849  dl->p1 = *thep1;
850  dl->p2 = *thep2;
851  }
852  else
853  {
854  dl->p1 = *thep2;
855  dl->p2 = *thep1;
856  }
857  }
858  return LW_TRUE;
859 }
double z
Definition: liblwgeom.h:334
double y
Definition: liblwgeom.h:334
double distance
Definition: measures3d.h:41
double x
Definition: liblwgeom.h:334
POINT3DZ p2
Definition: measures3d.h:43
POINT3DZ p1
Definition: measures3d.h:42
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
int twisted
Definition: measures3d.h:45
int mode
Definition: measures3d.h:44
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the caller graph for this function: