Learn R Programming

pcds (version 0.1.4)

Gam1PEtetra: The indicator for a 3D point being a dominating point for Proportional Edge Proximity Catch Digraphs (PE-PCDs) - one tetrahedron case

Description

Returns \(I(\)p is a dominating point of the PE-PCD\()\) where the vertices of the PE-PCD are the 2D data set Dt in the tetrahedron th, that is, returns 1 if p is a dominating point of PE-PCD, returns 0 otherwise.

Point, p, is in the vertex region of vertex rv (default is NULL); vertices are labeled as 1,2,3,4 in the order they are stacked row-wise in th.

PE proximity region is constructed with respect to the tetrahedron th with expansion parameter \(r \ge 1\) and vertex regions are based on center of mass (M="CM") or circumcenter (M="CC") only. and vertex regions are based on center of mass \(CM\) (equivalent to circumcenter in this case).

ch.data.pnt is for checking whether point p is a data point in Dt or not (default is FALSE), so by default this function checks whether the point p would be a dominating point if it actually were in the data set.

See also (ceyhan:Phd-thesis,ceyhan:comp-geo-2010;textualpcds).

Usage

Gam1PEtetra(p, Dt, r, th, M = "CM", rv = NULL, ch.data.pnt = FALSE)

Value

\(I(\)p is a dominating point of the PE-PCD\()\) where the vertices of the PE-PCD are the 2D data set Dt, that is, returns 1 if p is a dominating point, returns 0 otherwise

Arguments

p

A 3D point that is to be tested for being a dominating point or not of the PE-PCD.

Dt

A set of 3D points which constitutes the vertices of the PE-PCD.

r

A positive real number which serves as the expansion parameter in PE proximity region; must be \(\ge 1\).

th

Four 3D points, stacked row-wise, each row representing a vertex of the tetrahedron.

M

The center to be used in the construction of the vertex regions in the tetrahedron, th. Currently it only takes "CC" for circumcenter and "CM" for center of mass; default="CM".

rv

Index of the vertex whose region contains point p, rv takes the vertex labels as 1,2,3,4 as in the row order of the vertices in standard tetrahedron, default is NULL.

ch.data.pnt

A logical argument for checking whether point p is a data point in Dt or not (default is FALSE).

Author

Elvan Ceyhan

References

See Also

Gam1PEstdTetra, Gam1PEtri and Gam1PEbastri

Examples

Run this code
A<-c(0,0,0); B<-c(1,0,0); C<-c(1/2,sqrt(3)/2,0); D<-c(1/2,sqrt(3)/6,sqrt(6)/3)
tetra<-rbind(A,B,C,D)
n<-20

dat<-runif.tetra(n,tetra)$g  #try also dat<-cbind(runif(n),runif(n),runif(n))

M<-"CM"; cent<-apply(tetra,2,mean)  #center of mass
#try also M<-"CC"; cent<-circ.cent.tetra(tetra)  #circumcenter

r<-2

P<-c(.4,.1,.2)
Gam1PEtetra(P,P,r,tetra,M)
Gam1PEtetra(dat[1,],dat,r,tetra,M)
Gam1PEtetra(P,dat,r,tetra,M)

Gam1PEtetra(dat[1,],dat,r,tetra,M)
Gam1PEtetra(dat[1,],dat[1,],r,tetra,M)

#or try
RV<-rv.tetraCC(dat[1,],tetra)$rv
Gam1PEtetra(dat[1,],dat,r,tetra,M,rv=RV)

Gam1PEtetra(c(-1,-1,-1),dat,r,tetra,M)
Gam1PEtetra(c(-1,-1,-1),c(-1,-1,-1),r,tetra,M)

gam.vec<-vector()
for (i in 1:n)
{gam.vec<-c(gam.vec,Gam1PEtetra(dat[i,],dat,r,tetra,M))}

ind.gam1<-which(gam.vec==1)
ind.gam1
g1.pts<-dat[ind.gam1,]

Xlim<-range(tetra[,1],dat[,1],cent[1])
Ylim<-range(tetra[,2],dat[,2],cent[2])
Zlim<-range(tetra[,3],dat[,3],cent[3])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
zd<-Zlim[2]-Zlim[1]

plot3D::scatter3D(dat[,1],dat[,2],dat[,3], phi =0,theta=40, bty = "g",
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05), zlim=Zlim+zd*c(-.05,.05),
         pch = 20, cex = 1, ticktype = "detailed")
#add the vertices of the tetrahedron
plot3D::points3D(tetra[,1],tetra[,2],tetra[,3], add=TRUE)
L<-rbind(A,A,A,B,B,C); R<-rbind(B,C,D,C,D,D)
plot3D::segments3D(L[,1], L[,2], L[,3], R[,1], R[,2],R[,3], add=TRUE,lwd=2)
if (length(g1.pts)!=0)
{plot3D::points3D(g1.pts[,1],g1.pts[,2],g1.pts[,3], pch=4,col="red", add=TRUE)}

plot3D::text3D(tetra[,1],tetra[,2],tetra[,3], labels=c("A","B","C","D"), add=TRUE)

D1<-(A+B)/2; D2<-(A+C)/2; D3<-(A+D)/2; D4<-(B+C)/2; D5<-(B+D)/2; D6<-(C+D)/2;
L<-rbind(D1,D2,D3,D4,D5,D6); R<-rbind(cent,cent,cent,cent,cent,cent)
plot3D::segments3D(L[,1], L[,2], L[,3], R[,1], R[,2],R[,3], add=TRUE,lty=2)

P<-c(.4,.1,.2)
Gam1PEtetra(P,dat,r,tetra,M)

dat.fr<-data.frame(a=dat)
Gam1PEtetra(P,dat.fr,r,tetra,M)

Gam1PEtetra(c(-1,-1,-1),dat,r,tetra,M,ch.data.pnt = FALSE)
#gives an error message if ch.data.pnt = TRUE since p is not a data point

Run the code above in your browser using DataLab