コード例 #1
0
def create_polygons(center_blocks):
    """
    Create shapely Polygons from center points, where center points
    consist of a collection of tuples (x, y, m), where x and y are the
    coordinates on the board, and m is a checker value (0/1)
    :param center_blocks: collection of center points with (x, y, m)
    :return: np.array of initial_polygons
    """
    polygons = []
    for idx, block in enumerate(center_blocks):
        pts = np.array(block)[:, :-1]
        poly = MultiPoint(pts + 0.5).buffer(0.5, cap_style=3)
        poly.checkers = np.array(block)
        poly.orientations = get_unique_orientations(poly)
        poly.id = idx
        polygons.append(poly)
    return np.array(polygons)