Lattice
Lattice(origin, cell_size, levels)
The fixed grid of points on which every square of a refined quad mesh has its corners.
Parameters
| origin |
tuple of float |
Lattice point (x, y) from which lattice indices are counted. |
required |
| cell_size |
float |
Side length of the base cell; any positive length. |
required |
| levels |
int |
Highest refinement level; the finest square has side cell_size / 2**levels. |
required |
Raises
|
InputError |
If the origin is not finite, the cell size is not positive or the number of levels is negative. |
Methods
| to_coordinates |
Convert integer lattice indices to coordinates. |
| to_indices |
Convert coordinates to the nearest integer lattice indices. |
to_coordinates
Lattice.to_coordinates(indices)
Convert integer lattice indices to coordinates.
Parameters
| indices |
array_like of int, shape (n, 2) |
Lattice indices in units of :attr:unit from the origin. |
required |
Returns
|
numpy.ndarray of float, shape (n, 2) |
Coordinates origin + index * unit. |
to_indices
Lattice.to_indices(coordinates)
Convert coordinates to the nearest integer lattice indices.
Parameters
| coordinates |
array_like of float, shape (n, 2) |
Point coordinates. |
required |
Returns
| indices |
numpy.ndarray of int, shape (n, 2) |
Nearest lattice indices in units of :attr:unit from the origin. |
| on_lattice |
numpy.ndarray of bool, shape (n,) |
True where the point lies within 1e-6 * unit of that lattice point. |