kfr2vertsCCvert.reg: The 'k' furthest points in a data set from vertices in each...

View source: R/AuxExtrema.R

kfr2vertsCCvert.regR Documentation

The k furthest points in a data set from vertices in each CC-vertex region in a triangle

Description

An object of class "Extrema". Returns the k furthest data points among the data set, Xp, in each CC-vertex region from the vertex in the triangle, tri=T(A,B,C), vertices are stacked row-wise. Vertex region labels/numbers correspond to the row number of the vertex in tri.

ch.all.intri is for checking whether all data points are inside tri (default is FALSE). If some of the data points are not inside tri and ch.all.intri=TRUE, then the function yields an error message. If some of the data points are not inside tri and ch.all.intri=FALSE, then the function yields the closest points to edges among the data points inside tri (yields NA if there are no data points inside tri).

In the extrema, ext, in the output, the first k entries are the k furthest points from vertex 1, second k entries are k furthest points are from vertex 2, and last k entries are the k furthest points from vertex 3. If data size does not allow, NA's are inserted for some or all of the k furthest points for each vertex.

Usage

kfr2vertsCCvert.reg(Xp, tri, k, ch.all.intri = FALSE)

Arguments

Xp

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

tri

A 3 \times 2 matrix with each row representing a vertex of the triangle.

k

A positive integer. k furthest data points in each CC-vertex region are to be found if exists, else NA are provided for (some of) the k furthest points.

ch.all.intri

A logical argument (default=FALSE) to check whether all data points are inside the triangle tri. So, if it is TRUE, the function checks if all data points are inside the closure of the triangle (i.e., interior and boundary combined) else it does not.

Value

A list with the elements

txt1

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

txt2

A shorter description of the distances as "Distances of k furthest points in the vertex regions to Vertices".

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, k furthest points from vertices in each CC-vertex region in the triangle tri.

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, it is tri for this function.

cent

The center point used for construction of vertex regions

ncent

Name of the center, cent, it is circumcenter "CC" for this function.

regions

Vertex regions inside the triangle, tri, provided as a list

region.names

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

region.centers

Centers of mass of the vertex regions inside T_b.

dist2ref

Distances from k furthest points in each vertex region to the corresponding vertex (each row representing a vertex in tri). Among the distances the first k entries are the distances from the k furthest points from vertex 1 to vertex 1, second k entries are distances from the k furthest points from vertex 2 to vertex 2, and the last k entries are the distances from the k furthest points from vertex 3 to vertex 3.

Author(s)

Elvan Ceyhan

See Also

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

Examples

## Not run: 
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
n<-10  #try also n<-20
k<-3

set.seed(1)
Xp<-runif.tri(n,Tr)$g

Ext<-kfr2vertsCCvert.reg(Xp,Tr,k)
Ext
summary(Ext)
plot(Ext)

Xp2<-rbind(Xp,c(.2,.4))
kfr2vertsCCvert.reg(Xp2,Tr,k)
#try also kfr2vertsCCvert.reg(Xp2,Tr,k,ch.all.intri = TRUE)

kf2v<-Ext

CC<-circumcenter.tri(Tr)  #the circumcenter
D1<-(B+C)/2; D2<-(A+C)/2; D3<-(A+B)/2;
Ds<-rbind(D1,D2,D3)

Xlim<-range(Tr[,1],Xp[,1])
Ylim<-range(Tr[,2],Xp[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]

plot(A,pch=".",asp=1,xlab="",ylab="",
main=paste(k," Furthest Points in CC-Vertex Regions \n from the Vertices",sep=""),
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
L<-matrix(rep(CC,3),ncol=2,byrow=TRUE); R<-Ds
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
points(Xp)
points(kf2v$ext,pch=4,col=2)

txt<-rbind(Tr,CC,Ds)
xc<-txt[,1]+c(-.06,.08,.05,.12,-.1,-.1,-.09)
yc<-txt[,2]+c(.02,-.02,.04,.0,.02,.06,-.04)
txt.str<-c("A","B","C","CC","D1","D2","D3")
text(xc,yc,txt.str)

## End(Not run)


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