Last chance! 50% off unlimited learning
Sale ends in
Returns the index of the edge whose region contains point, pt
, in
the standard equilateral triangle
Edges are labeled as 3 for edge AB, 1 for edge BC, and 2 for edge AC.
If the point, pt
, is not inside tri
, then the function yields NA
as output.
Edge region 1 is the triangle
See also (ceyhan:Phd-thesis,ceyhan:comp-geo-2010,ceyhan:mcap2012,ceyhan:arc-density-CS;textualpcds).
reTeCM(pt)
A 2D point for which CM-edge region it resides in is to be determined in the
the standard equilateral triangle
A list with three elements
Index of the CM-edge region that contains point, pt
in the standard equilateral triangle
The vertices of the standard equilateral triangle
Description of the edge labels
re.triCM
, re.tri.cent
,
re.bastriCM
, re.bastri.cent
, and redge.triCM
# NOT RUN {
P<-c(.4,.2)
reTeCM(P)
P<-c(.8,.2)
reTeCM(P)
P<-c(.8,.8)
reTeCM(P)
P<-c(.5,.61)
reTeCM(P)
A<-c(0,0); B<-c(1,0); C<-c(0.5,sqrt(3)/2);
Te<-rbind(A,B,C)
D1<-(B+C)/2; D2<-(A+C)/2; D3<-(A+B)/2;
reTeCM(A)
reTeCM(B)
reTeCM(C)
reTeCM(D1)
reTeCM(D2)
reTeCM(D3)
CM<-(A+B+C)/3
reTeCM(CM)
n<-10 #try also n<-20
dat<-runifTe(n)$gen.points
re<-vector()
for (i in 1:n)
re<-c(re,reTeCM(dat[i,])$re)
re
Xlim<-range(Te[,1],dat[,1])
Ylim<-range(Te[,2],dat[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(Te,asp=1,xlab="",ylab="",axes=TRUE,pch=".",xlim=Xlim+xd*c(-.01,.01),ylim=Ylim+yd*c(-.01,.01))
points(dat,pch=".")
polygon(Te)
L<-Te; R<-matrix(rep(CM,3),ncol=2,byrow=TRUE)
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
text(dat,labels=factor(re))
txt<-rbind(Te,CM)
xc<-txt[,1]+c(-.03,.03,.03,-.06)
yc<-txt[,2]+c(.02,.02,.02,.03)
txt.str<-c("A","B","C","CM")
text(xc,yc,txt.str)
p1<-(A+B+CM)/3
p2<-(B+C+CM)/3
p3<-(A+C+CM)/3
plot(Te,xlab="",ylab="",axes=TRUE,pch=".",xlim=Xlim+xd*c(-.01,.01),ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
L<-Te; R<-matrix(rep(CM,3),ncol=2,byrow=TRUE)
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
txt<-rbind(Te,CM,p1,p2,p3)
xc<-txt[,1]+c(-.03,.03,.03,-.06,0,0,0)
yc<-txt[,2]+c(.02,.02,.02,.03,0,0,0)
txt.str<-c("A","B","C","CM","re=3","re=1","re=2")
text(xc,yc,txt.str)
# }
Run the code above in your browser using DataLab