sl.checkposition: Check Position of Point Relative to a Line on a Sphere

View source: R/sl.checkposition.R

sl.checkpositionR Documentation

Check Position of Point Relative to a Line on a Sphere

Description

Check if a point is located to the left or to the right of a (directed) line, defined by two other points, on a sphere. This is equivalent to checking the direction of rotation of the resulting triangle.

Usage

sl.checkposition(a, b, c, ccw.defined.as = 1)

Arguments

a

Vector of length 2 with longitude and latitude of the start point of the line.

b

Vector of length 2 with longitude and latitude of the end point of the line.

c

Vector of length 2 with longitude and latitude of the point for which the position relative to the (great circle) line spanned from a to b is sought.

ccw.defined.as

By default ccw.defined.as=1, meaning that the return value is 1 if c is located to the left of the line (that is, if the resulting triangle rotates counterclockwise). If ccw.defined.as=-1, the return value is inverted.

Value

Scalar return value: 1 if c is located to the left (if the triangle a-b-c rotates counterclockwise), -1 if c is located to the right (if the triangle a-b-c rotates clockwise), or 0 if all points lie on one (great circle) line. (Values inverted if ccw.defined.as=-1.))

Author(s)

Helge Goessling

Examples

sl.checkposition(a=c(0,0),b=c(90,0),c=c(45,1))
## Should return:
## [1] 1

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