mesa_frames.Grid.get_directions#
- Grid.get_directions(pos0: int | Sequence[int] | DataFrame | Sequence[int | slice | Sequence[int]] | Collection[int | Sequence[int] | DataFrame] | None = None, pos1: int | Sequence[int] | DataFrame | Sequence[int | slice | Sequence[int]] | Collection[int | Sequence[int] | DataFrame] | None = None, agents0: int | Collection[int] | Series | DataFrame | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None = None, agents1: int | Collection[int] | Series | DataFrame | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None = None, normalize: bool = False) DataFrame#
Return the directions from pos0 to pos1 or agents0 and agents1.
If the space is a Network, the direction is the shortest path between the two nodes. In all other cases, the direction is the direction vector between the two positions. Either positions (pos0, pos1) or agents (agents0, agents1) must be specified, not both and they must have the same length.
- Parameters:
pos0 (SpaceCoordinate | SpaceCoordinates | None, optional) – The starting positions
pos1 (SpaceCoordinate | SpaceCoordinates | None, optional) – The ending positions
agents0 (IdsLike | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None, optional) – The starting agents
agents1 (IdsLike | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None, optional) – The ending agents
normalize (bool, optional) – Whether to normalize the vectors to unit norm. By default False
- Returns:
A DataFrame where each row represents the direction from pos0 to pos1 or agents0 to agents1
- Return type:
DataFrame