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