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)

## Arguments

turtles 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 AgentMatrix object representing the moving agents. WorldMatrix or worldArray object. 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 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.

## 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.

## References

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

Sarah Bauduin

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