Learn R Programming

treePlotArea (version 3.1.0)

get_intersection: Get Intersection Point of Two Lines

Description

Get the intersection point of two straight lines given in slope–intercept form.

Usage

get_intersection(x, y)

Value

A named vector giving the intersection, NULL if the lines do not intersect, NaN if they are identical.

Arguments

x

A named vector with intercept ["a"] and slope ["b"].

y

A named vector with intercept ["a"] and slope ["b"].

See Also

Other geometry functions: points2equation(), vector_length()

Examples

Run this code
get_intersection(x = c(a = 0, b = 1), y = c(a = 2, b = -1))
get_intersection(x = c(a = 0, b = 1), y = c(a = 2, b = 1))
x <- c(a = 0, b = 1)
get_intersection(x = x, y = x)

Run the code above in your browser using DataLab