Description Usage Arguments Value Examples
returns a list of one or more pair of points, one on each of two segments, with minimal distance
1 | closestpointsontwosegments_n(s1, s2)
|
s1 |
a 2x2 numeric matrix, representing a segment. Each row of the matrix are the coordinates of a extreme point of the segment. |
s2 |
a 2x2 numeric matrix, representing a segment. Each row of the matrix are the coordinates of a extreme point of the segment. |
a list of 2x2 numeric matrices, representing a segment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | zz<-function(){
s1=matrix(sample(0:4,4,rep=T),2,2)
s2=matrix(sample(0:4,4,rep=T),2,2)
s<-rbind(s1,s2)
dd<-distsegmenttosegment(s1,s2)
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(s1,type="l",lwd=2)
points(s2,type="l",lwd=2)
cc<-closestpointsontwosegments_n(s1,s2)
for(ccc in cc){points(ccc ,col="red",cex=2)
points(ccc,type="l",col="red",lty=3)}
}
par(oma=c(0,0,0,0),mfrow=c(3,3))
set.seed(3);replicate(9,zz())
closestpointsontwosegments_n(matrix(c(0,3,0,0),2,2),matrix(c(1,2,0,0),2,2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.