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

◆ project_point_on_plane()

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.

Definition at line 1524 of file measures3d.c.

1525{
1526 /*In our plane definition we have a point on the plane and a normal vector (pl.pv), perpendicular to the plane
1527 this vector will be parallel to the line between our inputted point above the plane and the point we are
1528 searching for on the plane. So, we already have a direction from p to find p0, but we don't know the distance.
1529 */
1530
1531 VECTOR3D v1;
1532 double f;
1533
1534 if (!get_3dvector_from_points(&(pl->pop), p, &v1))
1535 return 0.0;
1536
1537 f = DOT(pl->pv, v1);
1538 if (FP_IS_ZERO(f))
1539 {
1540 /* Point is in the plane */
1541 *p0 = *p;
1542 return 0;
1543 }
1544
1545 f = -f / DOT(pl->pv, pl->pv);
1546
1547 p0->x = p->x + pl->pv.x * f;
1548 p0->y = p->y + pl->pv.y * f;
1549 p0->z = p->z + pl->pv.z * f;
1550
1551 return f;
1552}
#define FP_IS_ZERO(A)
static int get_3dvector_from_points(POINT3DZ *p1, POINT3DZ *p2, VECTOR3D *v)
Definition measures3d.c:34
#define DOT(u, v)
Definition measures3d.h:31
POINT3DZ pop
Definition measures3d.h:57
VECTOR3D pv
Definition measures3d.h:58
double z
Definition liblwgeom.h:382
double x
Definition liblwgeom.h:382
double y
Definition liblwgeom.h:382
double z
Definition measures3d.h:52
double x
Definition measures3d.h:52
double y
Definition measures3d.h:52

References DOT, FP_IS_ZERO, get_3dvector_from_points(), PLANE3D::pop, PLANE3D::pv, POINT3DZ::x, VECTOR3D::x, POINT3DZ::y, VECTOR3D::y, POINT3DZ::z, and VECTOR3D::z.

Referenced by lw_dist3d_point_poly(), lw_dist3d_point_tri(), lw_dist3d_ptarray_poly(), and lw_dist3d_ptarray_tri().

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