vec_angle: Angle / radian between two 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_angle(a, b, rad = TRUE, mode = 1)

Arguments

a,b

Vector

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

Angle

Examples

1
2
3
4
5
6
7
8
v <- c(1,0)                                  # point vector
as <- seq(0, 2*pi, length=10)                # radians to rotate
# mode 1: between 0 and 180 degrees, minimal angle / radian
for (a in as)         
  print(vec_angle(v %*% rotation_matrix_2d(a, F), v, mode=1))
# mode 2: between 0 and 360 degrees, anti-clockwise 
for (a in as)
  print(vec_angle(v %*% rotation_matrix_2d(a, F), v, mode=2))

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