PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lw_dist3d_pt_pt()

int lw_dist3d_pt_pt ( const POINT3DZ thep1,
const POINT3DZ thep2,
DISTPTS3D 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 1082 of file measures3d.c.

1083{
1084 double dx = thep2->x - thep1->x;
1085 double dy = thep2->y - thep1->y;
1086 double dz = thep2->z - thep1->z;
1087 double dist = sqrt(dx * dx + dy * dy + dz * dz);
1088 LWDEBUGF(2,
1089 "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)",
1090 thep1->x,
1091 thep1->y,
1092 thep1->z,
1093 thep2->x,
1094 thep2->y,
1095 thep2->z);
1096
1097 if (((dl->distance - dist) * (dl->mode)) >
1098 0) /*multiplication with mode to handle mindistance (mode=1) and maxdistance (mode = (-1)*/
1099 {
1100 dl->distance = dist;
1101
1102 if (dl->twisted > 0) /*To get the points in right order. twisted is updated between 1 and (-1) every
1103 time the order is changed earlier in the chain*/
1104 {
1105 dl->p1 = *thep1;
1106 dl->p2 = *thep2;
1107 }
1108 else
1109 {
1110 dl->p1 = *thep2;
1111 dl->p2 = *thep1;
1112 }
1113 }
1114 return LW_TRUE;
1115}
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
POINT3DZ p2
Definition measures3d.h:42
int twisted
Definition measures3d.h:45
POINT3DZ p1
Definition measures3d.h:41
double distance
Definition measures3d.h:40
double z
Definition liblwgeom.h:396
double x
Definition liblwgeom.h:396
double y
Definition liblwgeom.h:396

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_pt_tri(), lw_dist3d_ptarray_ptarray(), and lw_dist3d_seg_seg().

Here is the caller graph for this function: