polymerist.maths.lattices.coordinates

Representation of vectors of coordinates and elementary distance geometry operations

Attributes

Num

Classes

Coordinates

Represention class for encapsulating N-vectors of D-dimensional coordinates, with basic coordinate operations

BoundingBox

For representing a minimum bounding box around an N-coordinate vector of D-dimensional points

Module Contents

polymerist.maths.lattices.coordinates.Num
class polymerist.maths.lattices.coordinates.Coordinates(points: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], Num] | None = None)[source]

Bases: Generic[Num]

Represention class for encapsulating N-vectors of D-dimensional coordinates, with basic coordinate operations

points = None
n_dims
property n_points: int

The number of points currently stored in the coordinates vector

property dimensions: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]

The side lengths of the bounding box along each dimension

property minimum: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]

The bounding box vertex with the smallest coordinates in each dimension

property maximum: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]

The bounding box vertex with the largest coordinates in each dimension

property extrema: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[2, polymerist.genutils.typetools.numpytypes.D], Num]

A 2xN array of the minimal and maximal bounding box vertices

validate_point(point: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]) None[source]

Check if a point is compatible with the coordinates, or else raise Exception with reason why not

dists_to_point(point: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num], norm_order: int | None = None) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N], Num][source]

The distance between each point in a coordinate array and a single arbitrary point

weighted_centroid(weights: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N], Num] | None = None) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num][source]

The average (center-of-mass) coordinate of a vector of coordinates, with optional array of weights for each coordinates

property centroid: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]

The unweighted average coordinate of the vector

dists_to_centroid(norm_order: int | None = None, weights: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N], Num] | None = None) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N], Num][source]

The distance of each coordinate in an array of coordinates to the coordinates’ centroid

property lex_ordered_idxs: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], int]

Returns a vector of the position that each point in self.points occupies when ordered lexicographically

property lex_ordered_points: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], Num]

Return copy of the points in the lattice in lexicographic order

lex_order_points() None[source]

Sort points in the lattice in lexicographic order

randomize_points() None[source]

Place the points in the lattice in a random order

translate(displacement: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D], Num]) None[source]

Apply affine shift (translation only) to all points

linear_transformation(matrix: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D, polymerist.genutils.typetools.numpytypes.D], float], as_coords: bool = False) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], float] | Coordinates[source]

Accepts an NxN matrix (where D is the dimension of the lattice), returns a linearly-transformed copy of the coordinate points

affine_transformation(matrix: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.D, polymerist.genutils.typetools.numpytypes.D], float], as_coords: bool = False) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], float] | Coordinates[source]

Accepts an NxN matrix (where D is the dimension of the lattice), returns an affinely-transformed copy of the coordinate points

class polymerist.maths.lattices.coordinates.BoundingBox(coords: Coordinates | numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], Num])[source]

Bases: Coordinates

For representing a minimum bounding box around an N-coordinate vector of D-dimensional points

property vertices: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], Num]

Alias of the “points” attribute to distinguish use via syntax

property face_indices: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], int]

Returns a [2**(n_dim-1) x 2*n_dim] whose points are the indices of (2*n_dims)-tuplets which form a “face” of the bounding box (i.e. shared values of exactly one coordinate)

property face_coords: numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D, 3], int]

Return a [2**(n_dim-1) x 2*n_dim x 3] array in which each row is the set

surrounds(coords: Coordinates | numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], Num], strict: bool = False) numpy.ndarray[polymerist.genutils.typetools.numpytypes.Shape[polymerist.genutils.typetools.numpytypes.N, polymerist.genutils.typetools.numpytypes.D], bool][source]

Boolean mask of whether the coordinates in a point vector lies within the bounding box