| rel.edges.tri | R Documentation |
M-edge regions in a triangle
that contains the points in a give data setReturns the indices of the edges
whose regions contain the points in data set Xp in
a triangle tri=T(A,B,C)
and edge regions are based on the center M=(m_1,m_2)
in Cartesian coordinates or
M=(\alpha,\beta,\gamma) in barycentric coordinates
in the interior of the triangle tri
(see the plots in the example for illustrations).
The vertices of the triangle tri are labeled as
1=A, 2=B, and 3=C also
according to the row number the vertex is recorded in tri
and the corresponding edges are 1=BC, 2=AC, and 3=AB.
If a point in Xp is not inside tri,
then the function yields NA as output for that entry.
The corresponding edge region is the polygon
with the vertex, M,
and vertices other than the non-adjacent vertex,
i.e., edge region 1 is the triangle
T(B,M,C), edge region 2 is T(A,M,C)
and edge region 3 is T(A,B,M).
See also (\insertCiteceyhan:Phd-thesis,ceyhan:comp-geo-2010,ceyhan:mcap2012,ceyhan:arc-density-CS;textualpcds).
rel.edges.tri(Xp, tri, M)
Xp |
A set of 2D points representing the set of data points for which indices of the edge regions containing them are to be determined. |
tri |
A |
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 |
A list with the elements
re |
Indices (i.e., a |
tri |
The vertices of the triangle, where row number corresponds to the vertex index opposite to edge whose index is given in re. |
desc |
Description of the edge labels as
|
Elvan Ceyhan
rel.edges.triCM, rel.verts.tri,
and rel.verts.tri.nondegPE
## Not run:
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
M<-c(1.6,1.2)
P<-c(.4,.2)
rel.edges.tri(P,Tr,M)
n<-20 #try also n<-40
set.seed(1)
Xp<-runif.tri(n,Tr)$g
M<-as.numeric(runif.tri(1,Tr)$g) #try also M<-c(1.6,1.2)
(re<-rel.edges.tri(Xp,Tr,M))
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]
if (dimension(M)==3) {M<-bary2cart(M,Tr)}
#need to run this when M is given in barycentric coordinates
plot(Tr,pch=".",xlab="",ylab="",
main="Scatterplot of data points \n and the M-edge regions",axes=TRUE,
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
points(Xp,pch=".",col=1)
L<-Tr; R<-rbind(M,M,M)
segments(L[,1], L[,2], R[,1], R[,2], lty = 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(.05,.06,-.05,-.02)
yc<-txt[,2]+c(.03,.03,.05,-.08)
txt.str<-c("M","re=2","re=3","re=1")
text(xc,yc,txt.str)
text(Xp,labels=factor(re$re))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.