# biotite.structure.move_inside_box¶

biotite.structure.move_inside_box(coord, box)[source]

Move all coordinates into the given box, with the box vectors originating at (0,0,0).

Coordinates are outside the box, when they cannot be represented by a linear combination of the box vectors with scalar factors $$0 \le a_i \le 1$$. In this case the affected coordinates are translated by the box vectors, so that they are inside the box.

Parameters
coordndarray, dtype=float, shape=(n,3) or shape=(m,n,3)

The coordinates for one or multiple models.

boxndarray, dtype=float, shape=(3,3) or shape=(m,3,3)

The box(es) for one or multiple models. When coord is given for multiple models, box must be given for multiple models as well.

Returns
moved_coordndarray, dtype=float, shape=(n,3) or shape=(m,n,3)

The moved coordinates. Has the same shape is the input coord.

Examples

>>> box = np.array([[10,0,0], [0,10,0], [0,0,10]], dtype=float)
>>> inside_coord        = [ 1,  2,  3]
>>> outside_coord       = [ 1, 22, 54]
>>> other_outside_coord = [-4,  8,  6]
>>> coord = np.stack([inside_coord, outside_coord, other_outside_coord])
>>> print(coord)
[[ 1  2  3]
[ 1 22 54]
[-4  8  6]]
>>> moved_coord = move_inside_box(coord, box)
>>> print(moved_coord.astype(int))
[[1 2 3]
[1 2 4]
[6 8 6]]