| face | R Documentation |
Set the turtles' heading towards agents2.
face(turtles, agents2, world, torus = FALSE)
## S4 method for signature 'agentMatrix,matrix'
face(turtles, agents2, world, torus = FALSE)
turtles |
|
agents2 |
Matrix ( `AgentMatrix` object representing the moving `agents`, or
Matrix (`ncol` = 2) with the first column `x` and the second column
`y` representing locations coordinates.
|
world |
|
torus |
Logical to determine if the |
The number of agents/locations in agents2 must be equal to 1 or
to the length of turtles.
If `torus = FALSE`, `world` does not need to be provided.
If `torus = TRUE` and the distance from one `turtles` to
its corresponding agent/location `agents2` is smaller around the
sides of the `world` than across it, then the direction to the agent/location
`agents2` going around the sides of the `world` is given to the `turtle`.
If a turtle is facing its own location, its heading does not change.
AgentMatrix representing the turtles with updated headings.
Sarah Bauduin
Wilensky, U. 1999. NetLogo. https://www.netlogo.org. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL.
https://docs.netlogo.org/dictionary.html#face
<https://docs.netlogo.org/dictionary.html#facexy>
w1 <- createWorld(
minPxcor = 0, maxPxcor = 4, minPycor = 0, maxPycor = 4,
data = runif(25)
)
t1 <- createTurtles(n = 10, coords = randomXYcor(w1, n = 10))
plot(w1)
points(t1, col = of(agents = t1, var = "color"), pch = 16)
t1 <- face(turtles = t1, agents2 = cbind(x = 0, y = 0))
t1 <- fd(turtles = t1, dist = 0.5)
points(t1, col = of(agents = t1, var = "color"), pch = 16)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.