angle2d {gear} | R Documentation |
angle2d
determines the angle between pairs of
coordinates in degrees or radians. The coordinates are
assumed to be in two-dimensional space.
angle2d(coords1, coords2, radians = FALSE, invert = TRUE)
coords1 |
An |
coords2 |
An |
radians |
A logical value indicating whether the
angles returned should be in degrees or radians. The
default is |
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 |
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].
Returns a vector of angles.
Joshua French
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)