Description Usage Arguments Value See Also Examples
Computes distance between two polygons
1 | distpolytopoly(poly1, poly2)
|
poly1 |
a polygon (a n x 2 numerical matrix) |
poly2 |
a polygon (a n x 2 numerical matrix) |
a positive number, the distance between the two polygons
distsegmenttopoly
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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)
for(cc in closestpointsontwopolygons_n(poly1,poly2)){
points(cc,type="l",col="red",lty=3)}}
par(mfrow=c(2,2),oma=c(0,0,1,0),mar=c(0.1,0.1,1,0.1))
set.seed(2);replicate(4,zz())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.