avectors: Computes the angle between two vectors

Description Usage Arguments Value Author(s) Examples

Description

This function returns the angle (in radians) between two vectors. The vectors can be of any dimension.

Usage

1
avectors(u, v)

Arguments

u

a vector

v

a vector

Value

the angle (in radians) between the two input vectors.

Author(s)

Aaron Olsen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

nitlon/Eartheaters documentation built on May 23, 2019, 7:06 p.m.