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)

Arguments

agents

Matrix (ncol = 2) with the first column "pxcor" and the second column "pycor" representing the patches coordinates, or

AgentMatrix object representing the moving agents.

radius

Numeric. Vector of distances from agents to locate agents2. Must be of length 1 or of length agents.

agents2

Matrix (ncol = 2) with the first column "pxcor" and the second column "pycor" representing the patches coordinates, or

AgentMatrix object representing the moving agents.

world

WorldMatrix or worldArray object.

torus

Logical to determine if the world is wrapped. Default is torus = FALSE.

Value

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 reprensented by the "id" column, if agents2 are patches, or

Matrix (ncol = 2) with the first column "who" representing the "who" numbers of the turtles among agents2 within radius distances for each agents which are reprensented by the "id" column, if agents2 are turtles.

Details

Distances from/to patches are calculated from/to their center.

If torus = FALSE, world does not need to be provided.

If torus = TRUE, the radius distances are calculared around the sides of the world to select agents2.

References

Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.

See also

https://ccl.northwestern.edu/netlogo/docs/dictionary.html#in-radius

Examples

w1 <- createWorld(minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4) t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10)) 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)