line.intersect: Line intersections

View source: R/line.intersect.R

line.intersectR Documentation

Line intersections

Description

Returns coordinates where pairs of lines intersect.

Usage

line.intersect(beta0, beta1, pairwise = TRUE)

Arguments

beta0

Two-element vector or two-column matrix of line slopes and intercept values.

beta1

Two-element vector or two-column matrix of line slopes and intercept values.

pairwise

Logical value specifying whether to calculate intersection points for all possible slope and intercept pair combinations.

Value

Returns a list of x and y intersection points.

Examples

n <- 10
m <- 2*runif(n)-1
b <- 2*runif(n)-1
plot(c(-2, 2), c(-2, 2), type = "n", xlab = "x", ylab = "y")
for (i in 1:n) abline(b[i], m[i], col = "grey70")
r <- line.intersect(cbind(m, b))
points(r$x, r$y, pch = 21, bg = "red")

TobieSurette/gulf.stats documentation built on Jan. 4, 2023, 4:19 p.m.