Computes pointarray to triangle distance.
1374{
1375 uint32_t i;
1376 double f, s1, s2;
1378 POINT3DZ p1, p2, projp1, projp2, intersectionp;
1379
1381
1382
1387
1388 for (i = 1; i < pa->
npoints; i++)
1389 {
1390 int intersects;
1396
1397
1398
1399
1400 if ((s1 * s2) < 0)
1401 {
1402
1403 f = fabs(s1) / (fabs(s1) + fabs(s2));
1405
1406
1407 intersectionp.
x = projp1.
x + f * projp1_projp2.
x;
1408 intersectionp.
y = projp1.
y + f * projp1_projp2.
y;
1409 intersectionp.
z = projp1.
z + f * projp1_projp2.
z;
1410
1411
1413
1415 {
1416 if (intersects)
1417 {
1419 dl->
p1.
x = intersectionp.
x;
1420 dl->
p1.
y = intersectionp.
y;
1421 dl->
p1.
z = intersectionp.
z;
1422
1423 dl->
p2.
x = intersectionp.
x;
1424 dl->
p2.
y = intersectionp.
y;
1425 dl->
p2.
z = intersectionp.
z;
1427 }
1428 }
1429 }
1430
1431 projp1 = projp2;
1432 s1 = s2;
1433 p1 = p2;
1434 }
1435
1436
1439}
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
#define LW_TRUE
Return types for functions with status returns.
int lw_dist3d_pt_tri(POINT3DZ *p, LWTRIANGLE *tri, PLANE3D *plane, POINT3DZ *projp, DISTPTS3D *dl)
int pt_in_ring_3d(const POINT3DZ *p, const POINTARRAY *ring, PLANE3D *plane)
pt_in_ring_3d(): crossing number test for a point in a polygon input: p = a point,...
static int get_3dvector_from_points(POINT3DZ *p1, POINT3DZ *p2, VECTOR3D *v)
double project_point_on_plane(POINT3DZ *p, PLANE3D *pl, POINT3DZ *p0)
Finds a point on a plane from where the original point is perpendicular to the plane.
int lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinations of segments between two pointarrays.