coords.Coords.align#

Coords.align(alignment='---', point=[0.0, 0.0, 0.0])#

Align a Coords object on a given point.

Alignment involves a translation such that the bounding box of the Coords object becomes aligned with a given point. The bounding box alignment is done by the translation of a bounding box point to the target point.

Parameters#

alignment: str

The requested alignment is a string of three characters, one for each of the coordinate axes. The character determines how the structure is aligned in the corresponding direction:

  • ‘-’: aligned on the minimal value of the bounding box,

  • ‘+’: aligned on the maximal value of the bounding box,

  • ‘0’: aligned on the middle value of the bounding box.

Any other value will make the alignment in that direction unchanged.

point: point-like

The target point of the alignment.

Returns#

Coords

The Coords translated thus that the alignment bounding_box_point() is at point.

Notes#

The default parameters translate the Coords thus that all points are in the octant with all positive coordinate values.

Coords.align(alignment = '000') will center the object around the origin, just like the centered() (which is slightly faster). This can however be used for centering around any point.

Examples#

>>> X = Coords([[0.0, 0.0],[1.0, 0.0],[1.0, 1.0],[0.0, 1.0]])
>>> print(X.align(alignment='000', point=[0.0,0.0,2.0]))
[[-0.5 -0.5  2. ]
 [ 0.5 -0.5  2. ]
 [ 0.5  0.5  2. ]
 [-0.5  0.5  2. ]]