Learn R Programming

pcds (version 0.1.4)

cl2eVRcent.alt: An alternative function to the function cl2eVRcent which finds the closest points among a data set in the vertex regions to the respective edges in a triangle

Description

An object of class "Extrema". An alternative function to the function cl2eVRcent

Usage

cl2eVRcent.alt(dat, tri, M)

Value

A list with the elements

txt1

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

txt2

A short description of the distances as "Distances to Edges in the Respective \eqn{M}-Vertex Regions".

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 edges 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 tri

cent

The center point used for construction of vertex regions

ncent

Name of the center, cent, it is "M" or "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 tri

dist2ref

Distances of closest points in the M-vertex regions to corresponding edges.

Arguments

dat

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

tri

Three 2D points, stacked row-wise, each row representing a vertex of the triangle.

M

A 2D point in Cartesian coordinates or a 3D point in barycentric coordinates which serves as a center in the interior of the triangle tri or the circumcenter of tri.

Author

Elvan Ceyhan

See Also

cl2eVRcent

Examples

Run this code
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
M<-c(1.6,1.0)  #try also M<-c(1.3,1.3)

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

Ext<-cl2eVRcent.alt(dat,Tr,M)
Ext
summary(Ext)
plot(Ext)

cl2eVRcent.alt(dat[1,],Tr,M)

cl2e<-cl2eVRcent.alt(dat,Tr,M)
cl2e

Ds<-cp2e.tri(Tr,M)

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

plot(Tr,pch=".",xlab="",ylab="",axes=TRUE,
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
points(dat,pch=1,col=1)
L<-rbind(M,M,M); R<-Ds
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
points(cl2e$ext,pch=3,col=2)

xc<-Tr[,1]+c(-.02,.03,.02)
yc<-Tr[,2]+c(.02,.02,.04)
txt.str<-c("A","B","C")
text(xc,yc,txt.str)

txt<-rbind(M,Ds)
xc<-txt[,1]+c(.02,.04,-.03,0)
yc<-txt[,2]+c(.07,.04,.06,-.08)
txt.str<-c("M","D1","D2","D3")
text(xc,yc,txt.str)

dat.fr<-data.frame(a=dat)
cl2eVRcent.alt(dat.fr,Tr,M)

dat.fr<-data.frame(a=Tr)
cl2eVRcent.alt(dat,dat.fr,M)

Run the code above in your browser using DataLab