perpDist | R Documentation |
Calculate the perpendicular distance of a matrix of points to a line.
perpDist(pts, line)
pts |
two column matrix of points. |
line |
either a 2x2 matrix of points defining line or two element vector giving intercept and slope of line. |
Eric Archer eric.archer@noaa.gov
ran.pts <- matrix(runif(10), ncol = 2)
x <- perpDist(ran.pts, c(0, 1))
x
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
abline(a = 0, b = 1)
points(ran.pts[, 1], ran.pts[, 2])
segments(ran.pts[, 1], ran.pts[, 2], x[, 1], x[, 2], lty = "dashed")
points(x[, 1], x[, 2], col = "red")
axis(1, pos = 0)
axis(2, pos = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.