Computes the directional angle between a set of normalized vectors and a reference direction in a specific dimension. The function allows returning the result in degrees or radians and optionally considering the opposite direction.
Arguments
- v
A numeric matrix of dimension
d x n. Each column represents a normalized vector.- dim
Integer indicating the reference dimension, with
1 <= dim <= d.- negdir
Logical. If
TRUE, considers the negative direction (complementary angle).- deg
Logical. If
TRUE, returns angles in degrees; ifFALSE, returns them in radians.
Examples
# Three normalized vectors in the X, Y, and Z directions
v <- matrix(c(1, 0, 0,
0, 1, 0,
0, 0, 1), nrow = 3)
# Angle with respect to the X axis
angled2(v, dim = 1)
#> [1] 0 90 90
# Angle with respect to the Y axis
angled2(v, dim = 2)
#> [1] 90 0 90
# Angle with respect to the Z axis
angled2(v, dim = 3)
#> [1] 90 90 0