molsysmt.structure.rotate#
- molsysmt.structure.rotate(molecular_system, rotation=None, rotation_center=None, selection='all', structure_indices='all', syntax='MolSysMT', in_place=False, skip_digestion=False)[source]#
Rotate atomic coordinates of a selection by a given rotation.
The rotation is applied frame-by-frame. If a
rotation_centeris provided, the coordinates are first translated so that the center sits at the origin, rotated, then translated back.Two rotation representations are accepted:
Array-like matrices of shape
(3, 3),(n_structures, 3, 3), or(n_structures, n_atoms, 3, 3).An object providing an
apply(coordinates)method, such asscipy.spatial.transform.Rotation. SciPy is not required.
- Parameters:
molecular_system (molecular system) – Molecular system in any supported MolSysMT format.
rotation (array-like or rotation-like object, default=None) – Proper rotation matrices or an object providing an apply method.
rotation_center (PyUnitWizard quantity or None, default=None) – Point about which coordinates are rotated, in units of length.
selection (str, list, tuple, or numpy.ndarray, default='all') – Selection string or boolean/integer array specifying elements.
structure_indices (int, list, tuple, or numpy.ndarray, default='all') – Structure indices (0-based) to include or process.
syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).
in_place (bool, default=False) – Whether to modify the input molecular system in place.
skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.
- Returns:
A new molecular system with the rotated coordinates when
in_place=False;Nonewhenin_place=True.- Return type:
molecular system or None
- Raises:
ArgumentError – If a matrix has an invalid shape, non-finite values, is not orthonormal, or has a determinant other than +1.
NotImplementedMethodError – If
rotationis not a supported type.StructuralInconsistencyError – If the number of per-frame or per-atom matrices cannot be broadcast to the selected coordinates.
Notes
MolSysMT uses active proper rotations on row-vector coordinates. Distances and handedness are therefore preserved.
See also
molsysmt.structure.translate()Translate selected coordinates.
molsysmt.structure.least_rmsd_fit()Estimate and apply a least-RMSD rigid transformation.
Examples
>>> import molsysmt as msm >>> coordinates = msm.pyunitwizard.quantity([[[1.0, 0.0, 0.0]]], 'nm') >>> rotation = [[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]] >>> rotated = msm.structure.rotate(coordinates, rotation=rotation) >>> msm.pyunitwizard.get_value(rotated, to_unit='nm').round(12).tolist() [[[0.0, 1.0, 0.0]]]
Tutorial with more examples
See Rotate.
Added in version 1.0.0.