# \donttest{
#Examples for rank.dist2edges.std.tri
n<-10
set.seed(1)
Xp<-runif.std.tri(n)$gen.points
dec.dist<-rank.dist2edges.std.tri(Xp)
dec.dist
dec.dist.rank<-dec.dist[[2]]
#the rank of distances to the edges in decreasing order
dec.dist.rank
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.0,.01),
ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(Xp,pch=".")
text(Xp,labels = factor(dec.dist.rank) )
inc.dist<-rank.dist2edges.std.tri(Xp,dec = FALSE)
inc.dist
inc.dist.rank<-inc.dist[[2]]
#the rank of distances to the edges in increasing order
inc.dist.rank
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist
plot(A,pch=".",xlab="",ylab="",xlim=Xlim,ylim=Ylim)
polygon(Te)
points(Xp,pch=".",xlab="",ylab="", main="",xlim=Xlim+xd*c(-.05,.05),
ylim=Ylim+yd*c(-.05,.05))
text(Xp,labels = factor(inc.dist.rank))
# }
# \donttest{
#Examples for order.dist2edges.std.tri
n<-10
set.seed(1)
Xp<-runif.std.tri(n)$gen.points #try also Xp<-cbind(runif(n),runif(n))
dec.dist<-order.dist2edges.std.tri(Xp)
dec.dist
dec.dist.order<-dec.dist[[2]]
#the order of distances to the edges in decreasing order
dec.dist.order
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.01,.01),
ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(Xp,pch=".")
text(Xp[dec.dist.order,],labels = factor(1:n) )
inc.dist<-order.dist2edges.std.tri(Xp,dec = FALSE)
inc.dist
inc.dist.order<-inc.dist[[2]]
#the order of distances to the edges in increasing order
inc.dist.order
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist
dist[inc.dist.order] #distances in increasing order
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.05,.05),
ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
points(Xp,pch=".")
text(Xp[inc.dist.order,],labels = factor(1:n))
# }
Run the code above in your browser using DataLab