Libraries‎ > ‎Library‎ > ‎Movement‎ > ‎

Jump to location on circle

BehaviourComposer: ignore everything before this.
Note that this needs to be a behaviour of the agents being laid out. It works by finding a position in the list of all agents being laid out in this circle and using that to compute the angle from the centre that it is to be moved to. 

Begin micro-behaviour:
Begin description:
Jump to a location on a circle. Many agents can do this and will be spread out along the circle.
End description

Jump to a location on a circle

Begin NetLogo code:
substitute-text-area-for radius 8
substitute-text-area-for center-x 0
substitute-text-area-for center-y 0
substitute-text-area-for agents-on-the-circle all-individuals
let saved-my-heading my-heading
let those-in-the-circle sort agents-on-the-circle
set my-next-heading position self those-in-the-circle * 360 / length those-in-the-circle
set my-next-x center-x
set my-next-y center-y
go-forward radius
set my-heading saved-my-heading
End NetLogo code


To change the radius of the circle change the last box to another number. To change the centre of the circle change the values of my-next-x and my-next-y. If you want separate circles for different kinds of agents, e.g. "Sheep" then those-in-the-circle to all-of-kind "Sheep".

How this works

This temporarily sets my-heading to an angle that places each agent 360 divided by the number of agents multiplied by the position of the agent in a list of all agents in the circle. It then moves the radius distance in the computed heading. Finally it restore my-heading to its original value.

Related micro-behaviours

Place a set of agents on a circle relies upon the NetLogo layout-circle primitive which is restricted to placing all circles in the centre of the world. Place a set of agents in a rectangular grid places agents to fill a rectangle. Lay out a set of agents where the agents repel each other and the links between them act like springs attempts to find good locations for agents based upon their links with other agents. There are many movement behaviours in the main library.


Jump to a location on a circle was implemented by Ken Kahn.
BehaviourComposer: ignore everything after this.