Report the agents within the "cone of vision" in front of each one of the
turtles.
inCone(turtles, radius, angle, agents, world, torus = FALSE)
# S4 method for agentMatrix,numeric,numeric,matrix
inCone(turtles, radius, angle, agents, world, torus = FALSE)AgentMatrix object representing the moving agents.
Numeric. Vector of distances from turtles to locate
agents. Must be of length 1 or of length turtles.
Numeric. Vector of angles to define the size of the cone of vision
for the turtles. The cone of vision is defined between the
direction of their headings minus angle / 2
to the direction of their headings plus angle / 2. Must be of
length 1 or
of length turtles.
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 the cone of vision of each of the
turtles
which are represented by the id column, if
agents are patches, or
agents are reported if there are within radius
distance of the turtle and their direction from the turtle is within
[-angle, + angle] of the turtle's heading.
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 <- inCone(turtles = t1, radius = 2, agents = patches(w1), angle = 90)
t2 <- inCone(turtles = turtle(t1, who = 0), radius = 2, angle = 90, agents = t1)
}