dist.point2plane: The distance from a point to a plane spanned by three 3D...

View source: R/AuxGeometry.R

dist.point2planeR Documentation

The distance from a point to a plane spanned by three 3D points

Description

Returns the distance from a point p to the plane passing through points a, b, and c in 3D space.

Usage

dist.point2plane(p, a, b, c)

Arguments

p

A 3D point, distance from p to the plane passing through points a, b, and c are to be computed.

a, b, c

3D points that determine the plane (i.e., through which the plane is passing).

Value

A list with two elements

dis

Distance from point p to the plane spanned by 3D points a, b, and c

cl2pl

The closest point on the plane spanned by 3D points a, b, and c to the point p

Author(s)

Elvan Ceyhan

See Also

dist.point2line, dist.point2set, and Dist

Examples

## Not run: 
P<-c(5,2,40)
P1<-c(1,2,3); P2<-c(3,9,12); P3<-c(1,1,3);

dis<-dist.point2plane(P,P1,P2,P3);
dis
Pr<-dis$proj #projection on the plane

xseq<-seq(0,10,l=5)  #try also l=10, 20, or 100
yseq<-seq(0,10,l=5)  #try also l=10, 20, or 100

pl.grid<-Plane(P1,P2,P3,xseq,yseq)$z

plot3D::persp3D(z = pl.grid, x = xseq, y = yseq, theta =225, phi = 30,
ticktype = "detailed",
expand = 0.7, facets = FALSE, scale = TRUE,
main="Point P and its Orthogonal Projection \n on the Plane Defined by P1, P2, P3")
#plane spanned by points P1, P2, P3
#add the vertices of the tetrahedron
plot3D::points3D(P[1],P[2],P[3], add=TRUE)
plot3D::points3D(Pr[1],Pr[2],Pr[3], add=TRUE)
plot3D::segments3D(P[1], P[2], P[3], Pr[1], Pr[2],Pr[3], add=TRUE,lwd=2)

plot3D::text3D(P[1]-.5,P[2],P[3]+1, c("P"),add=TRUE)
plot3D::text3D(Pr[1]-.5,Pr[2],Pr[3]+2, c("Pr"),add=TRUE)

persp(xseq,yseq,pl.grid, xlab="x",ylab="y",zlab="z",theta = -30,
phi = 30, expand = 0.5, col = "lightblue",
      ltheta = 120, shade = 0.05, ticktype = "detailed")


## End(Not run)


elvanceyhan/pcds documentation built on June 29, 2023, 8:12 a.m.