Skip to main content

Lattice

Lattice(origin, cell_size, levels)

The fixed grid of points on which every square of a refined quad mesh has its corners.

Parameters

Name Type Description Default
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

Name Type Description
InputError If the origin is not finite, the cell size is not positive or the number of levels is negative.

Attributes

Name Description
cell_size
levels
origin
unit Side length of the finest square, cell_size / 2**levels.

Methods

Name Description
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

Name Type Description Default
indices array_like of int, shape (n, 2) Lattice indices in units of :attr:unit from the origin. required

Returns

Name Type Description
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

Name Type Description Default
coordinates array_like of float, shape (n, 2) Point coordinates. required

Returns

Name Type Description
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.