Report the patches
or turtles
among agents2
within given distances of
each of the agents
. Currently, this function multiplies radius
by
1.0000001 so that the response of inRadius
is inclusive.
inRadius(agents, radius, agents2, world, torus = FALSE)
# S4 method for matrix,numeric,matrix
inRadius(agents, radius, agents2, world, torus = FALSE)
Matrix (ncol
= 2) with the first column pxcor
and the second
column pycor
representing the patches
coordinates, or
Numeric. Vector of distances from agents
to locate
agents2
. Must be of length 1 or of length agents
.
Matrix (ncol
= 2) with the first column pxcor
and the second
column pycor
representing the patches
coordinates, or
WorldMatrix
or worldArray
object.
Logical to determine if the world
is wrapped. Default is
torus = FALSE
.
Matrix (ncol
= 3) with the first column pxcor
and the second column pycor
representing the coordinates of the
patches
among agents2
within radius
distances for each agents
which are represented by the id
column, if
agents2
are patches
, or
Distances from/to patches
are calculated from/to their center.
Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4)
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10))
if (requireNamespace("sf", quietly = TRUE)) {
p1 <- inRadius(agents = patch(w1, 0, 0), radius = 2, agents2 = patches(w1))
t2 <- inRadius(agents = patch(w1, 0, 0), radius = 2, agents2 = t1)
p2 <- inRadius(agents = t1, radius = 2, agents2 = patches(w1))
t3 <- inRadius(agents = turtle(t1, who = 0), radius = 2, agents2 = t1)
}