proj_pt2p: Project coordinates onto a 3D plane

View source: R/geom_dist.R

proj_pt2pR Documentation

Project coordinates onto a 3D plane

Description

Orthogonally projects a set of coordinates onto a 3D plane, defined by 3 co-planar points, and computes signed distances to the plane (i.e. if a point is above the plane, the sign will be negative). If only plane equation coefficients are available, use the pc2pt function to obtain co-planar points.

Usage

proj_pt2p(coords, p)

Arguments

coords

An Nx3 matrix-like object with point coordinates, one per row.

p

A 3x3 matrix-like object with coordinates defining a plane, one per row.

Value

An Nx4 data.frame object containing projected coordinates (columns 1-3) and signed distances (column 4) for every input point (one per row).

Note

The Morpho::points2plane() function of the Morpho package provides similar, but not identical, functionality.

Examples

pts = data.frame(x=c(10, -10), y=c(33, -31) ,z=c(11, -7))
p = data.frame(x=c(1, 3, 4), y=c(0,2,1), z=c(3,4,5))
pts.proj = proj_pt2p(pts, p)
## Not run: 
library(rgl)
points3d(pts, color="red")
p.coefs = planeCoefs(p)
planes3d(p.coefs[1], p.coefs[2], p.coefs[3], p.coefs[4])
points3d(pts.proj[,1:3], color="green", size=5)

## End(Not run)

cornelmpop/Lithics3D documentation built on Feb. 10, 2024, 11:54 p.m.