Learn R Programming

pcds (version 0.1.2)

cl2fVRth: The closest points among a data set in the vertex regions to the respective faces in a tetrahedron

Description

An object of class "Extrema". Returns the closest data points among the data set, Dt, to face \(i\) in M-vertex region \(i\) for \(i=1,2,3,4\) in the tetrahedron \(th=T(A,B,C,D)\). Vertex labels are \(A=1\), \(B=2\), \(C=3\), and \(D=4\) and corresponding face labels are \(BCD=1\), \(ACD=2\), \(ABD=3\), and \(ABC=4\).

Vertex regions are based on center M which can be the center of mass ("CM") or circumcenter ("CC") of th.

Usage

cl2fVRth(Dt, th, M = "CM")

Arguments

Dt

A set of 3D points representing the set of data points.

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".

Value

A list with the elements

txt1

Vertex labels are \(A=1\), \(B=2\), \(C=3\), and \(D=4\) (corresponds to row number in Extremum Points).

txt2

A short description of the distances as "Distances from Closest Points to Faces ...".

type

Type of the extrema points

desc

A short description of the extrema points

mtitle

The "main" title for the plot of the extrema

ext

The extrema points, here, closest points to faces in the respective vertex region.

X

The input data, Dt, can be a matrix or data frame

num.points

The number of data points, i.e., size of Dt

supp

Support of the data points, here, it is th

cent

The center point used for construction of vertex regions, it is circumcenter of center of mass for this function

ncent

Name of the center, it is circumcenter "CC" or center of mass "CM" for this function.

regions

Vertex regions inside the tetrahedron th provided as a list.

region.names

Names of the vertex regions as "vr=1","vr=2","vr=3","vr=4"

region.centers

Centers of mass of the vertex regions inside th.

dist2ref

Distances from closest points in each vertex region to the corresponding face.

See Also

fr2vVRCC, fr2eTeER, Kfr2vTbVRCC and Kfr2vVRCC

Examples

Run this code
# NOT RUN {
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)
Cent<-"CC"  #try also "CM"

n<-10  #try also n<-20
Dt<-runif.tetra(n,tetra)$g  #try also Dt<-cbind(runif(n),runif(n),runif(n))

Ext<-cl2fVRth(Dt,tetra,Cent)
Ext
summary(Ext)
plot(Ext)

cl2fVRth(c(.5,.5,.5),tetra,Cent)

cl2fVRth(Dt,tetra,Cent)
clf<-cl2fVRth(Dt,tetra,Cent)$ext
clf

if (Cent=="CC") {M<-circ.cent.tetra(tetra)}
if (Cent=="CM") {M<-apply(tetra,2,mean)}

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

plot3D::scatter3D(Dt[,1],Dt[,2],Dt[,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)
plot3D::points3D(clf[,1],clf[,2],clf[,3], pch=4,col="red", add=TRUE)

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

#for center of mass use #Cent<-apply(tetra,2,mean)
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(M,M,M,M,M,M)
plot3D::segments3D(L[,1], L[,2], L[,3], R[,1], R[,2],R[,3], add=TRUE,lty=2)

cl2fVRth(Dt,tetra,Cent)

P<-c(.1,.1,.1)
cl2fVRth(P,tetra,Cent)

dat.fr<-data.frame(a=Dt)
cl2fVRth(dat.fr,tetra,Cent)

dat.fr<-data.frame(a=tetra)
cl2fVRth(Dt,dat.fr,Cent)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab