cl2faces.vert.reg.tetra: The closest points among a data set in the vertex regions to...

View source: R/AuxExtrema.R

cl2faces.vert.reg.tetraR Documentation

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, Xp, 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

cl2faces.vert.reg.tetra(Xp, th, M = "CM")

Arguments

Xp

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

th

A 4 \times 3 matrix with 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 (correspond 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.

ind.ext

The data indices of extrema points, ext.

X

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

num.points

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

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.

Author(s)

Elvan Ceyhan

See Also

fr2vertsCCvert.reg, fr2edgesCMedge.reg.std.tri, fr2vertsCCvert.reg.basic.tri and kfr2vertsCCvert.reg

Examples

## 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)
set.seed(1)
tetra<-rbind(A,B,C,D)+matrix(runif(12,-.25,.25),ncol=3)
n<-10  #try also n<-20
Cent<-"CC"  #try also "CM"

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

Ext<-cl2faces.vert.reg.tetra(Xp,tetra,Cent)
Ext
summary(Ext)
plot(Ext)

clf<-Ext$ext

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

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

plot3D::scatter3D(Xp[,1],Xp[,2],Xp[,3], phi =0,theta=40, bty = "g",
main="Closest Pointsin CC-Vertex Regions \n to the Opposite Faces",
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)

## End(Not run)


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