Download NetLogo 5.1.0 User Manual - Center for Connected Learning and

Transcript
NetLogo 5.1.0 User Manual
If the caller is the observer, then the points are measured relative to the origin, in other words, the
points are taken as absolute patch coordinates.
If the caller is a turtle, the points are measured relative to the turtle's exact location, and not from the
center of the patch under the turtle.
ask turtles at-points [[2 4] [1 2] [10 15]]
[ fd 1 ] ;; only the turtles on the patches at the
;; distances (2,4), (1,2) and (10,15),
;; relative to the caller, move
atan
atan x y
Converts x and y offsets to a turtle heading in degrees (from 0 to 360).
Note that this version of atan is designed to conform to the geometry of the NetLogo world, where a
heading of 0 is straight up, 90 is to the right, and so on clockwise around the circle. (Normally in
geometry an angle of 0 is right, 90 is up, and so on, counterclockwise around the circle, and atan
would be defined accordingly.)
When y is 0: if x is positive, it reports 90; if x is negative, it reports 270; if x is zero, you get an error.
show atan 1 -1
=> 135
show atan -1 1
=> 315
crt 1 [ set heading 30
=> 30
fd 1
print atan xcor ycor ]
In the final example, note that the result of atan equals the turtle's heading.
If you ever need to convert a turtle heading (obtained with atan or otherwise) to a normal
mathematical angle, the following should be helpful:
to-report heading-to-angle [ h ]
report (90 - h) mod 360
end
autoplot?
autoplot?
Reports true if auto-plotting is on for the current plot, false otherwise.
auto-plot-off
auto-plot-on
NetLogo Dictionary
323