lengths.angle {cwhmisc} | R Documentation |
Compute lengths of two vectors and the angle between them.
lengths.angle(x, y)
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. |
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 . |
Christian W. Hoffmann <c-w.hoffmann@sunrise.ch>
http://www.wsl.ch/personal_homepages/hoffmann/index_EN
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