pygeon.grids.einstein module

Grid build from the a-periodic monotile cell.

class pygeon.grids.einstein.EinSteinGrid(*args, **kwargs)[source]

Bases: Grid

Build the EinStein grid from an svg file that has been generated from https://cs.uwaterloo.ca/~csk/hat/app.html

__init__(file_name)[source]

Initialize the EinSteinGrid object.

Parameters:

file_name (str) – The name of the file containing the grid data.

Returns:

None

add_hanging_node()[source]

Function to add the hanging nodes for each polygons to fix T-junctions.

This function adds a hanging node to each polygon in the grid to fix T-junctions. The hanging node is inserted at the midpoint of the third and fourth vertices of each polygon.

Parameters:

None

Returns:

None

build_connectivity()[source]

Build the connectivity of the grid.

Parameters:

None

Returns:

A tuple containing the following:

  • coords (np.ndarray): The rescaled points of the polygons in the unit square.

  • cell_faces (sps.csc_array): The sparse matrix representing the cell-face relations.

  • face_nodes (sps.csc_array): The sparse matrix representing the face-nodes relations.

Return type:

Tuple[np.ndarray, sps.csc_array, sps.csc_array]

rescale()[source]

Rescale the coordinates of the polygons in the unit square.

Returns:

The rescaled coordinates of the polygons.

Return type:

np.ndarray

poly_adder(input_str, transform)[source]

Recursive function to build all the polygons based on the transformation matrices.

Parameters:
  • input_str (str) – The input string representing the current tag.

  • transform (np.ndarray) – The transformation matrix.

Returns:

None

from_file(file_name)[source]

Read an SVG file and create the first data structure.

Parameters:

file_name (str) – The path to the SVG file.

Returns:

A tuple containing three elements:

  • poly_dict: A dictionary mapping polygon IDs to their corresponding polygons.

  • trans_dict: A dictionary mapping transformation IDs to a list of transformations.

  • use_info: A tuple containing the ID and transformation matrix of the root use element.

Return type:

Tuple[dict, dict, tuple]

as_polygon(pts)[source]

Convert a string to a 2D polygon in homogeneous coordinate

Parameters:

pts (str) – The string representing the polygon points.

Returns:

The 2D polygon in homogeneous coordinate

Return type:

np.ndarray

as_matrix(mat)[source]

Convert a string to a 2D matrix in homogeneous coordinate

Parameters:

mat (str) – The string representation of the matrix.

Returns:

The 2D matrix in homogeneous coordinate

Return type:

np.ndarray