Given the locations and headings of different objects, this function determines the angle between the heading of each object and the position to the nearest neighboring object.
Value
A vector of the same length as x and y representing the distance to the nearest neighboring object for each object.
Author
Simon Garnier, garnier@njit.edu, Marina Papadopoulou, m.papadopoulou.rug@gmail.com
Examples
x <- rnorm(25)
y <- rnorm(25, sd = 3)
hs <- rnorm(25, sd = 1)
nnba(x, y, hs)
#> [1] 2.4427019 -2.0554164 -1.9716542 1.1035555 1.7748614 -0.4585439
#> [7] -1.5321244 -0.0801507 -1.5832683 -2.5461191 1.1694133 -3.1123712
#> [13] -1.0801457 1.0965103 -2.2998180 0.6667259 -3.0177790 -0.4518722
#> [19] 0.9545425 0.9354504 1.7446136 2.2512458 -0.4752451 1.7053674
#> [25] -2.2127780