pymasep.common.math.grid_tools
Classes
Tools to handling grid and map plan |
Module Contents
- class pymasep.common.math.grid_tools.GridTools
Tools to handling grid and map plan
- MOVE_NORTH_BLOCKED = 1
- MOVE_SOUTH_BLOCKED = 2
- MOVE_EAST_BLOCKED = 4
- MOVE_WEST_BLOCKED = 8
- static direction_grid_neighbor(pos1, pos2, dist_type='manhattan')
Return the direction of a neighbor from a position
- Parameters:
pos1 – Initial position
pos2 – neighbor position
dist_type – type of distance (manhattan, get N, S, E or W, euclidian, get all directions)
- Returns:
the direction according to the distance type. None if pos1=pos2
- static is_connected_neighbor(data_map, from_pos, to_pos)
Return if positions are directly connected according to a datamap
- Parameters:
data_map – The datamap. See create_graph() for format
from_pos – initial position
to_pos – final position
- Returns:
True if there is a link between from_pos and to_pos
- static is_connected_by_direction(data_map, from_pos, direction)
Calculate if we can go from a position to a direction
- Parameters:
data_map – The data map. See create_graph() for format
from_pos – initial position
direction – direction to go
- Returns:
True if the direction is not blocked in this position
- static create_graph(data_map)
Create a directional graph from a data_map.
Format for each square : bit 1 : North blocked, bit 2 : South blocked, bit 3 : East blocked, bit 4 : West blocked
- Parameters:
data_map – 2D array with the format described (bitwise) for each square
- Returns:
a networkx.DiGraph instance
- static adapt_path_from_selected(graph, origin, path, selected)
Adapt an existing path with a new position, if possible.
- Parameters:
graph – The graph used to adapt the path
origin – the origin position
path – path to adapt. Must be a valid path
selected – the selected position to add or not into the path
- Returns:
the new path, adapted or not.