# \donttest{
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
P<-c(1.4,1.2)
M<-as.numeric(runif.tri(1,Tr)$g) #try also M<-c(1.6,1.2)
rel.edge.tri(P,Tr,M)
n<-20 #try also n<-40
Xp<-runif.tri(n,Tr)$g
re<-vector()
for (i in 1:n)
re<-c(re,rel.edge.tri(Xp[i,],Tr,M)$re)
re
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)}
plot(Tr,xlab="",ylab="",axes=TRUE,pch=".",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
points(Xp,pch=".")
L<-Tr; R<-rbind(M,M,M)
segments(L[,1], L[,2], R[,1], R[,2], lty = 2)
text(Xp,labels=factor(re))
txt<-rbind(Tr,M)
xc<-txt[,1]
yc<-txt[,2]
txt.str<-c("A","B","C","M")
text(xc,yc,txt.str)
p1<-(A+B+M)/3
p2<-(B+C+M)/3
p3<-(A+C+M)/3
plot(Tr,xlab="",ylab="", main="Illustration of M-edge regions in a triangle",
axes=TRUE,pch=".",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
L<-Tr; R<-rbind(M,M,M)
segments(L[,1], L[,2], R[,1], R[,2], lty = 2)
txt<-rbind(Tr,M,p1,p2,p3)
xc<-txt[,1]+c(-.02,.02,.02,.02,.02,.02,.02)
yc<-txt[,2]+c(.02,.02,.04,.05,.02,.02,.02)
txt.str<-c("A","B","C","M","re=3","re=1","re=2")
text(xc,yc,txt.str)
# }
Run the code above in your browser using DataLab