vec_angles: Angles / radian between two or more vectors.

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Function comes in two flavors. Either it calculates the smallest angle [0, 180) or the anti-clockwise angle with respect to the second vector [0, 360).

Usage

1
vec_angles(a, b, rad = TRUE, mode = 1)

Arguments

a

A matrix or a vector

b

A reference vector to find angle against.

rad

Angular measure is radian? (default TRUE).

mode

1= smallest angle in [0, 180); 2=anti-clockwise angle with respect vector b in [0, 360).

Value

Vector of angles

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
v <- c(1,0)   # point vector

rad <- seq(0, 2*pi, length=10)    # radians to rotate
m <- cbind(cos(rad), sin(rad))    # 2d m matrix 

# mode 1: between 0 and 180 degrees, minimal angle / radian
vec_angles(v, c(1,0))
vec_angles(m, c(1,0))

# mode 2: between 0 and 360 degrees, anti-clockwise 
vec_angles(v, c(1,0), mode=2)
vec_angles(m, c(1,0), mode=2)

markheckmann/circplot documentation built on May 21, 2019, 12:06 p.m.