inCone {NetLogoR} | R Documentation |
Agents
in cone
Description
Report the agents
within the "cone of vision" in front of each one of the
turtles
.
Usage
inCone(turtles, radius, angle, agents, world, torus = FALSE)
## S4 method for signature 'agentMatrix,numeric,numeric,matrix'
inCone(turtles, radius, angle, agents, world, torus = FALSE)
Arguments
turtles |
|
radius |
Numeric. Vector of distances from |
angle |
Numeric. Vector of angles to define the size of the cone of vision
for the |
agents |
Matrix ( `AgentMatrix` object representing the moving `agents`. |
world |
|
torus |
Logical to determine if the |
Details
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.
Distances to `patches` are calculated to their center. If `torus = FALSE`, `world` does not need to be provided. If `torus = TRUE`, the `radius` distances are calculated around the sides of the `world` to select `agents`.
Value
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
Matrix (`ncol` = 2) with the first column `who` representing the `who` numbers of the `turtles` among `agents2` within the cone of vision of each of the `turtles` which are represented by the `id` column, if `agents` are `turtles`.
Author(s)
Sarah Bauduin
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-cone
Examples
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)
}