Last chance! 50% off unlimited learning
Sale ends in
Returns the index of the edge whose region contains point, pt
, in the
basic triangle c1
is in
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
Any given triangle can be mapped to the basic triangle by a combination of rigid body motions (i.e., translation, rotation and reflection) and scaling, preserving uniformity of the points in the original triangle. Hence basic triangle is useful for simulation studies under the uniformness hypothesis.
See also (ceyhan:Phd-thesis,ceyhan:comp-geo-2010,ceyhan:mcap2012,ceyhan:arc-density-CS;textualpcds).
re.bastriCM(pt, c1, c2)
A 2D point for which CM-edge region it resides in is to be determined in the
basic triangle
Positive real numbers which constitute the upper vertex of the basic triangle (i.e., the vertex
adjacent to the shorter edges of c1
must be in
A list with three elements
Index of the CM-edge region that contains point, pt
in the basic triangle
The vertices of the triangle, where row labels are
Description of the edge labels
re.triCM
, re.tri.cent
,
re.bastri.cent
, reTeCM
, and redge.triCM
# NOT RUN {
c1<-.4; c2<-.6
P<-c(.4,.2)
re.bastriCM(P,c1,c2)
c1<-.5; c2<-.8
P<-c(.4,.2)
re.bastriCM(P,c1,c2)
P<-c(.8,.2)
re.bastriCM(P,c1,c2)
P<-c(1.8,.2)
re.bastriCM(P,c1,c2)
c1<-.4; c2<-.6
A<-c(0,0);B<-c(1,0);C<-c(c1,c2);
Tb<-rbind(A,B,C)
CM<-(A+B+C)/3
re.bastriCM(A,c1,c2)
re.bastriCM(B,c1,c2)
re.bastriCM(C,c1,c2)
re.bastriCM(CM,c1,c2)
n<-10 #try also n<-20
dat<-runif.bastri(n,c1,c2)$g
re<-vector()
for (i in 1:n)
re<-c(re,re.bastriCM(dat[i,],c1,c2)$re)
re
Xlim<-range(Tb[,1],dat[,1])
Ylim<-range(Tb[,2],dat[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(Tb,xlab="",ylab="",axes=TRUE,pch=".",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
points(dat,pch=".")
polygon(Tb)
L<-Tb; 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(Tb,CM)
xc<-txt[,1]+c(-.03,.03,.02,0)
yc<-txt[,2]+c(.02,.02,.02,-.04)
txt.str<-c("A","B","C","CM")
text(xc,yc,txt.str)
# }
Run the code above in your browser using DataLab