PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lw_dist3d_ptarray_ptarray()

int lw_dist3d_ptarray_ptarray ( const POINTARRAY l1,
const POINTARRAY l2,
DISTPTS3D dl 
)

Finds all combinations of segments between two pointarrays.

Definition at line 1122 of file measures3d.c.

1123 {
1124  uint32_t t, u;
1125  POINT3DZ start, end;
1126  POINT3DZ start2, end2;
1127  int twist = dl->twisted;
1128  LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)", l1->npoints, l2->npoints);
1129 
1130  if (dl->mode == DIST_MAX) /*If we are searching for maxdistance we go straight to point-point calculation since
1131  the maxdistance have to be between two vertices*/
1132  {
1133  for (t = 0; t < l1->npoints; t++) /*for each segment in L1 */
1134  {
1135  getPoint3dz_p(l1, t, &start);
1136  for (u = 0; u < l2->npoints; u++) /*for each segment in L2 */
1137  {
1138  getPoint3dz_p(l2, u, &start2);
1139  lw_dist3d_pt_pt(&start, &start2, dl);
1140  }
1141  }
1142  }
1143  else
1144  {
1145  getPoint3dz_p(l1, 0, &start);
1146  for (t = 1; t < l1->npoints; t++) /*for each segment in L1 */
1147  {
1148  getPoint3dz_p(l1, t, &end);
1149  getPoint3dz_p(l2, 0, &start2);
1150  for (u = 1; u < l2->npoints; u++) /*for each segment in L2 */
1151  {
1152  getPoint3dz_p(l2, u, &end2);
1153  dl->twisted = twist;
1154  lw_dist3d_seg_seg(&start, &end, &start2, &end2, dl);
1155  LWDEBUGF(
1156  4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n", t, u, dl->distance);
1157  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f", t, u, dl->distance, dl->tolerance);
1158  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1159  return LW_TRUE; /*just a check if the answer is already given*/
1160  start2 = end2;
1161  }
1162  start = end;
1163  }
1164  }
1165  return LW_TRUE;
1166 }
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:106
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...
Definition: measures3d.c:1082
int lw_dist3d_seg_seg(const POINT3DZ *s1p1, const POINT3DZ *s1p2, const POINT3DZ *s2p1, const POINT3DZ *s2p2, DISTPTS3D *dl)
Finds the two closest points on two linesegments.
Definition: measures3d.c:1173
#define DIST_MIN
Definition: measures.h:44
#define DIST_MAX
Definition: measures.h:43
int twisted
Definition: measures3d.h:45
double distance
Definition: measures3d.h:40
int mode
Definition: measures3d.h:43
double tolerance
Definition: measures3d.h:47
uint32_t npoints
Definition: liblwgeom.h:427

References DIST_MAX, DIST_MIN, DISTPTS3D::distance, getPoint3dz_p(), lw_dist3d_pt_pt(), lw_dist3d_seg_seg(), LW_TRUE, LWDEBUGF, DISTPTS3D::mode, POINTARRAY::npoints, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_line_line(), lw_dist3d_line_poly(), lw_dist3d_line_tri(), lw_dist3d_poly_poly(), lw_dist3d_poly_tri(), lw_dist3d_ptarray_poly(), lw_dist3d_ptarray_tri(), and lw_dist3d_tri_tri().

Here is the call graph for this function:
Here is the caller graph for this function: