axis_alignment_rotation()
Find the smallest rotation pointing the vector between two atoms along an axis.
Usage
axis_alignment_rotation(
geo,
keys,
axis=(0.0, 0.0, 1.0),
)Use it to put a bond or other molecular axis along a coordinate axis, e.g. before spinning the geometry about that axis.
Parameters
geo: Geometry-
Geometry.
keys: Sequence[int]-
Two atoms,
(i, j). The vector fromitojis aligned. axis: ArrayLike = (0.0, 0.0, 1.0)- Direction to point it in.
Returns
Rotation-
The rotation, to apply with rotate (about atom
place, e.g.ito keep it inrotate(geo, rot, origin=geo.coordinates[i])).
Raises
ValueError-
If
keysisn’t two distinct atoms at different positions.
Examples
>>> import autogeom
>>> geo = autogeom.Geometry(
... symbols=["H", "H"], coordinates=[[0, 0, 0], [1, 0, 0]], charge=0, spin=0
... )
>>> rot = autogeom.axis_alignment_rotation(geo, [0, 1], axis=[0, 1, 0])
>>> autogeom.rotate(geo, rot).coordinates.round(6).tolist()[[0.0, 0.0, 0.0], [0.0, 1.0, 0.0]]