line.line.intersection: Determine intersection between two lines

Description Usage Arguments Value Author(s) Source Examples

View source: R/geometry.R

Description

Determine the intersection of two lines L1 and L2 in two dimensions, using the formula described by Weisstein.

Usage

1
line.line.intersection(P1, P2, P3, P4, interior.only = FALSE)

Arguments

P1

vector containing x,y coordinates of one end of L1

P2

vector containing x,y coordinates of other end of L1

P3

vector containing x,y coordinates of one end of L2

P4

vector containing x,y coordinates of other end of L2

interior.only

boolean flag indicating whether only intersections inside L1 and L2 should be returned.

Value

Vector containing x,y coordinates of intersection of L1 and L2. If L1 and L2 are parallel, this is infinite-valued. If interior.only is TRUE, then when the intersection does not occur between P1 and P2 and P3 and P4, a vector containing NAs is returned.

Author(s)

David Sterratt

Source

Weisstein, Eric W. "Line-Line Intersection." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html

Examples

1
2
3
4
5
## Intersection of two intersecting lines
line.line.intersection(c(0, 0), c(1, 1), c(0, 1), c(1, 0))

## Two lines that don't intersect
line.line.intersection(c(0, 0), c(0, 1), c(1, 0), c(1, 1))

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] 0.5 0.5
[1] Inf Inf

retistruct documentation built on April 4, 2020, 5:08 p.m.