avectors | R Documentation |
This function returns the angle (in radians) between two vectors. The vectors can be of any dimension.
avectors(u, v)
u |
a vector |
v |
a vector |
the angle (in radians) between the two input vectors.
Aaron Olsen
## THE ANGLE BETWEEN TWO 2D, ORTHOGONAL VECTORS
## VALUE IS EQUAL TO asin(1/sqrt(2))
u <- c(0, 1)
v <- c(1, 0)
avectors(u, v)
## THE ANGLE BETWEEN TWO 3D VECTORS
## VALUE IS EQUAL TO asin(sqrt(2)/sqrt(3))
u <- c(1, 1, 1)
v <- c(0, 1, 0)
avectors(u, v)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.