# \donttest{
c1<-.4; c2<-.6 #try also c1<-.2; c2<-.2;
A<-c(0,0); B<-c(1,0); C<-c(c1,c2);
Tb<-rbind(A,B,C)
set.seed(1)
M<-as.numeric(runif.basic.tri(1,c1,c2)$g) #try also M<-c(.6,.2)
P1<-as.numeric(runif.basic.tri(1,c1,c2)$g); #try also P1<-c(.3,.2)
NASbasic.tri(P1,c1,c2) #default with M="CC"
NASbasic.tri(P1,c1,c2,M)
#or try
Rv<-rel.vert.basic.triCC(P1,c1,c2)$rv
NASbasic.tri(P1,c1,c2,M,Rv)
NASbasic.tri(c(3,5),c1,c2,M)
P2<-c(.5,.4)
NASbasic.tri(P2,c1,c2,M)
P3<-c(1.5,.4)
NASbasic.tri(P3,c1,c2,M)
if (dimension(M)==3) {M<-bary2cart(M,Tr)}
#need to run this when M is given in barycentric coordinates
#plot of the NAS region
P1<-as.numeric(runif.basic.tri(1,c1,c2)$g);
CC<-circumcenter.basic.tri(c1,c2)
if (isTRUE(all.equal(M,CC)) || identical(M,"CC"))
{cent<-CC
D1<-(B+C)/2; D2<-(A+C)/2; D3<-(A+B)/2;
Ds<-rbind(D1,D2,D3)
cent.name<-"CC"
rv<-rel.vert.basic.triCC(P1,c1,c2)$rv
} else
{cent<-M
cent.name<-"M"
Ds<-prj.cent2edges.basic.tri(c1,c2,M)
rv<-rel.vert.basic.tri(P1,c1,c2,M)$rv
}
RV<-Tb[rv,]
rad<-Dist(P1,RV)
Int.Pts<-NASbasic.tri(P1,c1,c2,M)
Xlim<-range(Tb[,1],P1[1]+rad,P1[1]-rad)
Ylim<-range(Tb[,2],P1[2]+rad,P1[2]-rad)
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,pch=".",asp=1,xlab="",ylab="",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tb)
points(rbind(Tb,P1,rbind(Int.Pts$L,Int.Pts$R)))
L<-rbind(cent,cent,cent); R<-Ds
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
interp::circles(P1[1],P1[2],rad,lty=2)
L<-Int.Pts$L; R<-Int.Pts$R
segments(L[,1], L[,2], R[,1], R[,2], lty=1,col=2)
Arcs<-Int.Pts$a;
if (!is.null(Arcs))
{
K<-nrow(Arcs)/2
for (i in 1:K)
{A1<-Arcs[2*i-1,]; A2<-Arcs[2*i,];
angles<-angle.str2end(A1,P1,A2)$c
plotrix::draw.arc(P1[1],P1[2],rad,angle1=angles[1],angle2=angles[2],col=2)
}
}
#proximity region with the triangle (i.e., for labeling the vertices of the NAS)
IP.txt<-intpts<-c()
if (!is.null(Int.Pts$a))
{
intpts<-unique(round(Int.Pts$a,7))
#this part is for labeling the intersection points of the spherical
for (i in 1:(length(intpts)/2))
IP.txt<-c(IP.txt,paste("I",i+1, sep = ""))
}
txt<-rbind(Tb,P1,cent,intpts)
txt.str<-c("A","B","C","P1",cent.name,IP.txt)
text(txt+cbind(rep(xd*.02,nrow(txt)),rep(-xd*.03,nrow(txt))),txt.str)
c1<-.4; c2<-.6;
P1<-c(.3,.2)
NASbasic.tri(P1,c1,c2,M)
# }
Run the code above in your browser using DataLab