Compute the angle of a vector
Usage
vector_angle(x, origin = c(0, 0), degrees = FALSE, allow_negative = FALSE)
Arguments
- x
A length-2 vector
- origin
A length-2 vector
- degrees
If TRUE, returns angles in degrees instead of radians
- allow_negative
If TRUE, returns angles between -pi and pi (-180 and +180. If FALSE, returns angles between 0 and 2 * pi (0 and 360)
Examples
vector_angle(c(1,1))
#> [1] 0.7853982
vector_angle(c(1,1), degrees = TRUE)
#> [1] 45