# gridcells.core.common - common/shared definitions¶

The common module is a collection of basic classes used throughout the package:

 Pair2D(x, y) A pair of x and y attributes. Position2D(x, y, dt) Positional information with a constant time step. twisted_torus_distance(a, others, dim) Calculate a distance between a and others on a twisted torus.
class gridcells.core.common.Pair2D(x, y)[source]

Bases: object

A pair of x and y attributes.

class gridcells.core.common.Position2D(x, y, dt)[source]

Positional information with a constant time step.

gridcells.core.common.twisted_torus_distance(a, others, dim)[source]

Calculate a distance between a and others on a twisted torus.

Take a which is a 2D position and others, which is a vector of 2D positions and compute the distances between them based on the topology of the twisted torus.

If you just want to remap a function of (X, Y), set a==[[0, 0]].

Parameters: Specifies the initial position. a.x and a.y must be convertible to floats others : Pair2D Positions for which to compute the distance. dim : Pair2D Dimensions of the torus. dim.x and dim.y must be convertible to floats. An array of positions, always of the length of others