Learn R Programming

pcds (version 0.1.4)

cl2eVRcent: The closest points among a data set in the vertex regions to the respective edges in a triangle

Description

An object of class "Extrema". Returns the closest data points among the data set, Dt, to edge \(i\) in M-vertex region \(i\) for \(i=1,2,3\) in the triangle tri\(=T(A,B,C)\). Vertex labels are \(A=1\), \(B=2\), and \(C=3\), and corresponding edge labels are \(BC=1\), \(AC=2\), and \(AB=3\).

Vertex regions are based on center \(M=(m_1,m_2)\) in Cartesian coordinates or \(M=(\alpha,\beta,\gamma)\) in barycentric coordinates in the interior of the triangle tri or based on the circumcenter of tri.

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

Usage

cl2eVRcent(Dt, 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

Dt

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

References

See Also

cl2eTbVRcent, cl2eVRCM, and cl2edgesTe

Examples

Run this code
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);

Tr<-rbind(A,B,C);
n<-10  #try also n<-20

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

M<-as.numeric(runif.tri(1,Tr)$g)  #try also M<-c(1.6,1.0)

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

cl2eVRcent(dat[1,],Tr,M)
cl2e<-cl2eVRcent(dat,Tr,M)
cl2e

Ds<-cp2e.tri(Tr,M)

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

if (dimension(M)==3) {M<-bary2cart(M,Tr)}
#need to run this when M is given in barycentric coordinates

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,.05,-.02,-.01)
yc<-txt[,2]+c(-.03,.02,.08,-.07)
txt.str<-c("M","D1","D2","D3")
text(xc,yc,txt.str)

cl2eVRcent(dat,Tr,M)

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

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

Run the code above in your browser using DataLab