Calculates a scale factor so that a collection of vectors nearly fills the current plot, that is, the longest vector does not extend beyond the plot region.
Examples
bbox <- matrix(c(-3, 3, -2, 2), 2, 2)
colnames(bbox) <- c("x","y")
rownames(bbox) <- c("min", "max")
bbox
#> x y
#> min -3 -2
#> max 3 2
vecs <- matrix( runif(10, -1, 1), 5, 2)
plot(bbox)
arrows(0, 0, vecs[,1], vecs[,2], angle=10, col="red")
(s <- vecscale(vecs))
#> [1] 3.470071
arrows(0, 0, s*vecs[,1], s*vecs[,2], angle=10)