R/withinRadius.R

Defines functions withinRadius

#' Test whether point "b" is within a given radius of point "a".
#'
#' @param a Numeric. Data frame of x-y coordinates.
#' @param b Numeric. Data frame of x-y coordinates.
#' @param radius Numeric.
#' @noRd

withinRadius <- function(a, b, radius = 2) {
  (a[, 1] - b[, 1])^2 + (a[, 2] - b[, 2])^2 <= radius^2
}

Try the cholera package in your browser

Any scripts or data that you put into this service are public.

cholera documentation built on March 7, 2023, 5:31 p.m.