Adapted radius searching of points based on RcppHNSW

radius_search(
  query,
  ref,
  radius,
  max_neighbour,
  distance = "euclidean",
  same = FALSE,
  threads = 1L,
  verbose = FALSE,
  progress = FALSE,
  ...
)

Arguments

query

A data.table containing the set of query points where each row represent a point and each column a given coordinate.

ref

A numeric containing the set of reference points where each row represent a point and each column a given coordinate.

radius

A numeric describing maximum euclidean distance form the each query points in which a point can be consider a neighbor.

max_neighbour

An integer specifying the maximum number of ref points to look around to consider for a given radius.

distance

Type of distance to calculate. "euclidean" as default. Look hnsw_knn for more options.

same

Logic. If TRUE, it delete neighbors with distance of 0, useful when the k search is based on the same query.

threads

An integer specifying the number of threads to use for parallel processing. Experiment to see what works best for your data on your hardware.

verbose

If TRUE, log messages to the console.

progress

If TRUE, log a progress bar when verbose = TRUE. Tracking progress could cause a small overhead.

...

Arguments passed to hnsw_build and hnsw_search.

Value

A data.table with three columns describing the indices of the query and ref points and the distances.

Details

This function is based on hnswlib C++ library (Malkov & Yashunin 2016) and its bindings for R (RcppHNSW; Melville 2020) for a fast estimation of neighbors points. It is adapted to simplify the workflow within rTLS. If you use this function, please consider cite the C++ library and RcppHNSW package.

References

Malkov, Y. A., & Yashunin, D. A. (2016). Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs. arXiv preprint arXiv:1603.09320.

See also

radius_search

Author

J. Antonio Guzmán Q.

Examples


#Point cloud
data("pc_tree")

# \donttest{
#Radius search of 1
radius_search(pc_tree, pc_tree, radius = 1, max_neighbour = 100)
#>          query   ref   distance
#>       1:     1     1 0.00000000
#>       2:     1     3 0.05085840
#>       3:     1     2 0.07497273
#>       4:     1    12 0.08123342
#>       5:     1     5 0.08485103
#>      ---                       
#> 7584796: 75848 74488 0.30920058
#> 7584797: 75848 74590 0.30954511
#> 7584798: 75848 70848 0.31411552
#> 7584799: 75848 74496 0.31482312
#> 7584800: 75848 75828 0.31509626
# }