PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ lw_dist2d_pt_pt()

int lw_dist2d_pt_pt ( const POINT2D thep1,
const POINT2D thep2,
DISTPTS dl 
)

Compares incoming 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 2308 of file measures.c.

2309 {
2310  double hside = thep2->x - thep1->x;
2311  double vside = thep2->y - thep1->y;
2312  double dist = sqrt(hside * hside + vside * vside);
2313 
2314  /*multiplication with mode to handle mindistance (mode=1) and maxdistance (mode = (-1)*/
2315  if (((dl->distance - dist) * (dl->mode)) > 0)
2316  {
2317  dl->distance = dist;
2318 
2319  /* To get the points in right order. twisted is updated between 1 and (-1) every time the order is
2320  * changed earlier in the chain*/
2321  if (dl->twisted > 0)
2322  {
2323  dl->p1 = *thep1;
2324  dl->p2 = *thep2;
2325  }
2326  else
2327  {
2328  dl->p1 = *thep2;
2329  dl->p2 = *thep1;
2330  }
2331  }
2332  return LW_TRUE;
2333 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
POINT2D p1
Definition: measures.h:52
POINT2D p2
Definition: measures.h:53
int twisted
Definition: measures.h:55
int mode
Definition: measures.h:54
double distance
Definition: measures.h:51
double y
Definition: liblwgeom.h:404
double x
Definition: liblwgeom.h:404

References DISTPTS::distance, LW_TRUE, DISTPTS::mode, DISTPTS::p1, DISTPTS::p2, DISTPTS::twisted, POINT2D::x, and POINT2D::y.

Referenced by lw_dist2d_arc_arc(), lw_dist2d_point_point(), lw_dist2d_pre_seg_seg(), lw_dist2d_pt_arc(), lw_dist2d_pt_ptarray(), lw_dist2d_pt_ptarrayarc(), lw_dist2d_pt_seg(), lw_dist2d_ptarray_ptarray(), lw_dist2d_seg_arc(), rect_leaf_node_distance(), and rect_leaf_node_intersects().

Here is the caller graph for this function: