inCone: 'Agents' in cone

inConeR 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

AgentMatrix object representing the moving agents.

radius

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

angle

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.

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`.
world

WorldMatrix or worldArray object.

torus

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

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))

p1 <- inCone(turtles = t1, radius = 2, agents = patches(w1), angle = 90)
t2 <- inCone(turtles = turtle(t1, who = 0), radius = 2, angle = 90, agents = t1)



NetLogoR documentation built on Aug. 17, 2022, 9:06 a.m.