sl.line.line.intersect: Check if/where Two Lines Intersect

View source: R/sl.line.line.intersect.R

sl.line.line.intersectR Documentation

Check if/where Two Lines Intersect

Description

Check where two lines on a sphere, defined by two times two points, intersect, and whether they intersect on the shorter ways of the great-circle line.

Usage

sl.line.line.intersect(line1.lon, line1.lat, line2.lon, line2.lat)

Arguments

line1.lon

a vector of length 2 giving the longitudes of the points of the first line.

line1.lat

a vector of length 2 giving the latitudes of the points of the first line.

line2.lon

a vector of length 2 giving the longitudes of the points of the second line.

line2.lat

a vector of length 2 giving the latitudes of the points of the second line.

Details

If the lines intersect on the shorter ways of the great-circle line (that is, if lines.intersect=TRUE), that point will be in the first set of output variables (that is, the variables without '2' in the name). THIS FUNCTION NEEDS MODIFICATION: IT CURRENTLY FAILS WHEN THE LINES ARE IDENTICAL.

Value

lines.intersect

a logical value indicating whether the lines intersect on the shorter ways of the great-circle lines.

lon

a scalar giving the longitude of the first intersection point.

lat

a scalar giving the latitude of the first intersection point.

lon2

a scalar giving the longitude of the second intersection point.

lat2

a scalar giving the latitude of the second intersection point.

x

a scalar giving the x-coordinate of the first intersection point.

y

a scalar giving the y-coordinate of the first intersection point.

z

a scalar giving the z-coordinate of the first intersection point.

x2

a scalar giving the x-coordinate of the second intersection point.

y2

a scalar giving the y-coordinate of the second intersection point.

y3

a scalar giving the z-coordinate of the second intersection point.

Author(s)

Helge Goessling

Examples

sl.line.line.intersect(line1.lon=c(0,10),line1.lat=c(0,0),line2.lon=c(0,10),line2.lat=c(10,5))
## Should return:
## $lines.intersect
## [1] FALSE
## 
## $lon
## [1] -160.4361
## 
## $lat
## [1] 0
## 
## $lon2
## [1] 19.56389
## 
## $lat2
## [1] 0
## 
## $x
## [1] -0.01467808
## 
## $y
## [1] -0.005216208
## 
## $z
## [1] 0
## 
## $x2
## [1] 0.01467808
## 
## $y2
## [1] 0.005216208
## 
## $z2
## [1] 0

helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.