PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lw_dist3d_tri_tri()

int lw_dist3d_tri_tri ( const LWTRIANGLE tri1,
const LWTRIANGLE tri2,
DISTPTS3D dl 
)

triangle to triangle calculation

Definition at line 952 of file measures3d.c.

953 {
954  PLANE3D plane1, plane2;
955  int planedef1, planedef2;
956 
957  if (dl->mode == DIST_MAX)
958  return lw_dist3d_ptarray_ptarray(tri1->points, tri2->points, dl);
959 
960  planedef1 = define_plane(tri1->points, &plane1);
961  planedef2 = define_plane(tri2->points, &plane2);
962 
963  if (!planedef1 || !planedef2)
964  {
965  /* Neither define a plane: Return distance line to line */
966  if (!planedef1 && !planedef2)
967  return lw_dist3d_ptarray_ptarray(tri1->points, tri2->points, dl);
968 
969  /* Only tri defines a plane: Return distance from line (tri1) to tri2 */
970  else if (!planedef1)
971  return lw_dist3d_ptarray_tri(tri1->points, tri2, &plane2, dl);
972 
973  /* Only poly defines a plane: Return distance from line (tri2) to tri1 */
974  else
975  return lw_dist3d_ptarray_tri(tri2->points, tri1, &plane1, dl);
976  }
977 
978  /* What we do here is to compare the boundary of one polygon with the other polygon
979  and then take the second boundary comparing with the first polygon */
980  dl->twisted = 1;
981  if (!lw_dist3d_ptarray_tri(tri1->points, tri2, &plane2, dl))
982  return LW_FALSE;
983  if (dl->distance < dl->tolerance) /* Just check if the answer already is given*/
984  return LW_TRUE;
985 
986  dl->twisted = -1; /* because we switch the order of geometries we switch "twisted" to -1 which will give the
987  right order of points in shortest line. */
988  return lw_dist3d_ptarray_tri(tri2->points, tri1, &plane1, dl);
989 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
int lw_dist3d_ptarray_ptarray(const POINTARRAY *l1, const POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinations of segments between two pointarrays.
Definition: measures3d.c:1122
int define_plane(const POINTARRAY *pa, PLANE3D *pl)
Definition: measures3d.c:1491
int lw_dist3d_ptarray_tri(const POINTARRAY *pa, const LWTRIANGLE *tri, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to triangle distance.
Definition: measures3d.c:1413
#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
POINTARRAY * points
Definition: liblwgeom.h:495

References define_plane(), DIST_MAX, DISTPTS3D::distance, lw_dist3d_ptarray_ptarray(), lw_dist3d_ptarray_tri(), LW_FALSE, LW_TRUE, DISTPTS3D::mode, LWTRIANGLE::points, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_distribute_bruteforce().

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