diff --git a/package/MDAnalysis/transformations/rotate.py b/package/MDAnalysis/transformations/rotate.py index 694aec606e2..a8b80a5caa7 100644 --- a/package/MDAnalysis/transformations/rotate.py +++ b/package/MDAnalysis/transformations/rotate.py @@ -43,35 +43,39 @@ def rotateby(angle, direction, point=None, ag=None, weights=None, wrap=False): ''' - Rotates the trajectory by a given angle on a given axis. The axis is defined by + Rotates the trajectory by a given angle on a given axis. The axis is defined by the user, combining the direction vector and a point. This point can be the center - of geometry or the center of mass of a user defined AtomGroup, or an array defining + of geometry or the center of mass of a user defined AtomGroup, or an array defining custom coordinates. - + Examples -------- - - e.g. rotate the coordinates by 90 degrees on a axis formed by the [0,0,1] vector and + + e.g. rotate the coordinates by 90 degrees on a axis formed by the [0,0,1] vector and the center of geometry of a given AtomGroup: - + .. code-block:: python - + + from MDAnalysis import transformations + ts = u.trajectory.ts angle = 90 - ag = u.atoms() + ag = u.atoms d = [0,0,1] - rotated = MDAnalysis.transformations.rotate(angle, direction=d, ag=ag)(ts) - + rotated = transformations.rotate.rotateby(angle, direction=d, ag=ag)(ts) + e.g. rotate the coordinates by a custom axis: - + .. code-block:: python + from MDAnalysis import transformations + ts = u.trajectory.ts angle = 90 p = [1,2,3] d = [0,0,1] - rotated = MDAnalysis.transformations.rotate(angle, direction=d, point=point)(ts) - + rotated = transformations.rotate.rotateby(angle, direction=d, point=p)(ts) + Parameters ---------- angle: float @@ -100,7 +104,7 @@ def rotateby(angle, direction, point=None, ag=None, weights=None, wrap=False): Returns ------- MDAnalysis.coordinates.base.Timestep - + Warning ------- Wrapping/unwrapping the trajectory or performing PBC corrections may not be possible @@ -138,7 +142,7 @@ def rotateby(angle, direction, point=None, ag=None, weights=None, wrap=False): center_method = partial(atoms.center, weights, pbc=wrap) else: raise ValueError('A point or an AtomGroup must be specified') - + def wrapped(ts): if point is None: position = center_method() @@ -149,8 +153,8 @@ def wrapped(ts): translation = matrix[:3, 3] ts.positions= np.dot(ts.positions, rotation) ts.positions += translation - + return ts - + return wrapped - +