I wish to draw an arrow at the top turtle representing a vector denoted by
[x1,y1] . The vector is of unit magnitude and the size of the arrow should not exceed that of the turtle. The vector is stored in a list with two elements.
I don't wish to use the shape editor in netlogo to shape as arrow and then point the turtle in the heading denoted by the vector. The reason being I could draw one than 1 arrows for each turtle.
Bryan's answer gives the following:
Video link : https://www.youtube.com/watch?v=9SVcLg4Oyoc&t=23 for better explanation.
Best How To :
Here's how I'd do it:
Make sure your turtles are all of one breed, say,
particles, or whatever they represent. Create another turtles breed called
vectors or something. These turtles are going to be the tip of your vectors but you'll use links to actually visualize the vectors. Now, you can create the vectors like so:
ask particles [
hatch-vectors 1 [
To update the position of the vectors (given that the vector itself is stored in a turtle variable
vec), you can do:
ask particles [
let abs-x xcor + first vec
let abs-y ycor + last vec
;; Since the particle is linked to the vector by a directed link, it's an out-link-neighbor
ask out-link-neighbors [ setxy abs-x abs-y ]
Edit in response to update:
That's tougher, since link shape editing is more limited than turtle shape editing. One possibility would be to set the shape of the vector turtles to an arrow head (you could either create a new such shape, or the default turtle shape could suffice). Rather than hiding the
vectors, you'd then point them in the right direction. This can easily be done by having them face their link-partner and then turn around.
You may also want to switch from directed to undirected links to get rid of the arrow in the link itself. This should only involve minor code changes.