angle2d: Determine angle

Description Usage Arguments Details Value Author(s) Examples

View source: R/angle2d.R

Description

angle2d determines the angle between pairs of coordinates in degrees or radians. The coordinates are assumed to be in two-dimensional space.

Usage

1
angle2d(coords1, coords2, radians = FALSE, invert = TRUE)

Arguments

coords1

An N \times 2 matrix of spatial coordinates.

coords2

An N \times 2 matrix of spatial coordinates.

radians

A logical value indicating whether the angles returned should be in degrees or radians. The default is FALSE, indicating that the returned angles are in degrees.

invert

A logical value indicating whether the axes of the coordinates should be inverted (i.e., the x- and y-axis are switched). The default is TRUE to mimic results from other geostatistical R packages like gstat, geoR, and other software like GSLIB and GeoEAS. Set to FALSE to use the typical x- and y-axes.

Details

Note that the angle is between the actual pairs of points, not the angle between the vectors extending from the origin to the points. e.g., the angle between (0, 1) and (1, 1) is 90 degrees, not 45. The sign of the direction not accounted for, e.g., a -135 degree angle is rotated by 180 degrees to become a 45 degree angle. All angles returned are in the interval [0, 180].

Value

Returns a vector of angles.

Author(s)

Joshua French

Examples

1
2
3
4
coords1 = matrix(0, nrow = 8, ncol = 2)
coords2 = cbind(c(2, 2, 0, -2, -2, -2, 0, 2), c(0, 2, 2, 2, 0, -2, -2, -2))
angle2d(coords1, coords2)
angle2d(coords1, coords2, radians = TRUE)

gear documentation built on April 14, 2020, 5:12 p.m.

Related to angle2d in gear...