lengths.angle {cwhmisc}R Documentation

Lengths of two vectors and angle between them.

Description

Compute lengths of two vectors and the angle between them.

Usage

  lengths.angle(x, y)

Arguments

x the first vector. Alternatively, a single matrix with both vectors as columns can be provided.
y the second vector, optional if x is an appropriate structure.

Value

A list with elements
lx the length of x.
ly the length of y.
angle the angle (in radian) between x and y.
angleDeg the angle (in degrees) between x and y.

Author(s)

Christian W. Hoffmann <c-w.hoffmann@sunrise.ch>
http://www.wsl.ch/personal_homepages/hoffmann/index_EN

Examples

  x <- c(1,2,2,-1)
	y <- c(0,0.1,3,2)
  (l <- lengths.angle(x, y))  # == lengths.angle(cbind(x, y))
#> $lx    #> [1] 3.16228
#> $ly    #> [1] 3.60694
#> $angle #> [1] 1.1937
l$angle/pi*180 # in degrees  >  68.394

[Package cwhmisc version 2.0.1 Index]