Description Usage Arguments Value Examples
computes the coordinates of the closest point on the border of a polygon to a point in the plane
1 | closestpointsontwopolygons(poly1, poly2)
|
poly1 |
a nx2 numeric matrix, representing a polygon. Each row of the matrix are the coordinates of a vertice of the polygon. |
poly2 |
a nx2 numeric matrix, representing a polygon. Each row of the matrix are the coordinates of a vertice of the polygon. |
the coordinates of the closest point on the polygon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | zz<-function(){
poly1=matrix(sample(0:6,6,rep=T),3,2)[c(1:3,1),]
poly2=matrix(sample(0:6,6,rep=T),3,2)[c(1:3,1),]
s<-rbind(poly1,poly2)
dd<-distpolytopoly(poly1,poly2)
plot(s,cex=.5,main=paste0("Distance: ", signif(dd,3)),asp=1,xlim=range(s),ylim=range(s),xaxt='n',yaxt='n',xlab='',ylab='')
points(poly1,type="l",lwd=2)
points(poly2,type="l",lwd=2)
cc<-closestpointsontwopolygons(poly1,poly2)
points(cc ,col="red",cex=2)
points(cc,type="l",col="red",lty=3)
}
par(oma=c(0,0,0,0),mfrow=c(2,2))
set.seed(2);replicate(4,zz())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.