pt_in_ring_3d(): crossing number test for a point in a polygon input: p = a point, pa = vertex points of a ring V[n+1] with V[n]=V[0] plane=the plane that the vertex points are lying on returns: 0 = outside, 1 = inside
Our polygons have first and last point the same,
The difference in 3D variant is that we exclude the dimension that faces the plane least. That is the dimension with the highest number in pv
Definition at line 1573 of file measures3d.c.
1584 if (memcmp(&first, &last,
sizeof(
POINT3DZ)))
1586 lwerror(
"pt_in_ring_3d: V[n] != V[0] (%g %g %g!= %g %g %g)",
1596 LWDEBUGF(2,
"pt_in_ring_3d called with point: %g %g %g", p->
x, p->
y, p->
z);
1602 if (fabs(plane->
pv.
z) >= fabs(plane->
pv.
x) &&
1603 fabs(plane->
pv.
z) >= fabs(plane->
pv.
y))
1606 for (i = 0; i < ring->
npoints - 1; i++)
1614 ((v1.
y <= p->
y) && (v2.
y > p->
y))
1616 || ((v1.
y > p->
y) && (v2.
y <= p->
y)))
1619 vt = (double)(p->
y - v1.
y) / (v2.
y - v1.
y);
1622 if (p->
x < v1.
x + vt * (v2.
x - v1.
x))
1631 else if (fabs(plane->
pv.
y) >= fabs(plane->
pv.
x) &&
1632 fabs(plane->
pv.
y) >= fabs(plane->
pv.
z))
1635 for (i = 0; i < ring->
npoints - 1; i++)
1643 ((v1.
z <= p->
z) && (v2.
z > p->
z))
1645 || ((v1.
z > p->
z) && (v2.
z <= p->
z)))
1648 vt = (double)(p->
z - v1.
z) / (v2.
z - v1.
z);
1651 if (p->
x < v1.
x + vt * (v2.
x - v1.
x))
1662 for (i = 0; i < ring->
npoints - 1; i++)
1670 ((v1.
z <= p->
z) && (v2.
z > p->
z))
1672 || ((v1.
z > p->
z) && (v2.
z <= p->
z)))
1675 vt = (double)(p->
z - v1.
z) / (v2.
z - v1.
z);
1678 if (p->
y < v1.
y + vt * (v2.
y - v1.
y))
1687 LWDEBUGF(3,
"pt_in_ring_3d returning %d", cn & 1);
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
References getPoint3dz_p(), LW_FALSE, LWDEBUGF, lwerror(), POINTARRAY::npoints, PLANE3D::pv, POINT3DZ::x, VECTOR3D::x, POINT3DZ::y, VECTOR3D::y, POINT3DZ::z, and VECTOR3D::z.
Referenced by lw_dist3d_pt_poly(), lw_dist3d_pt_tri(), lw_dist3d_ptarray_poly(), and lw_dist3d_ptarray_tri().