# NOT RUN {
#the standard equilateral triangle
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
delta<-.3 #try also .5,.75,.85
seg.tri.supp(delta,Te)
Tseg<-seg.tri.supp(delta,Te)
Xlim<-range(Te[,1],Tseg[,1])
Ylim<-range(Te[,2],Tseg[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
oldpar <- par(no.readonly = TRUE)
par(pty="s")
plot(Te,pch=".",xlab="",ylab="",
main="segregation support is the intersection\n of these two triangles"
,axes=TRUE,xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
polygon(Tseg,lty=2)
txt<-rbind(Te,Tseg)
xc<-txt[,1]+c(-.03,.03,.03,.05,.04,-.04)
yc<-txt[,2]+c(.02,.02,.04,-.03,0,0)
txt.str<-c("A","B","C","T1","T2","T3")
text(xc,yc,txt.str)
par(oldpar)
#for a general triangle
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
delta<-.3 #try also .5,.75,.85
Tseg<-seg.tri.supp(delta,Tr)
Xlim<-range(Tr[,1],Tseg[,1])
Ylim<-range(Tr[,2],Tseg[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
oldpar <- par(no.readonly = TRUE)
par(pty="s")
plot(Tr,pch=".",xlab="",ylab="",
main="segregation support is the intersection\n of these two triangles"
,axes=TRUE,xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
polygon(Tseg,lty=2)
txt<-rbind(Tr,Tseg)
xc<-txt[,1]+c(-.03,.03,.03,.06,.04,-.04)
yc<-txt[,2]+c(.02,.02,.04,-.03,0,0)
txt.str<-c("A","B","C","T1","T2","T3")
text(xc,yc,txt.str)
par(oldpar)
dat.fr<-data.frame(a=Tr)
seg.tri.supp(delta,dat.fr)
# }
Run the code above in your browser using DataLab