amep.utils.rotate_coords#

amep.utils.rotate_coords(coords: ndarray, theta: float, center: ndarray) ndarray#

Rotates all coordinate vectors given in coords by the angle theta around the origin of the system given by center.

Parameters:
  • coords (np.ndarray) – Coordinates array.

  • theta (float) – Angle.

  • center (np.ndarray) – Center of the system (this is the origin around the coordinates are rotated).

Returns:

coords – Rotated coordinates array (same shape as input coords array).

Return type:

np.ndarray

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> frame = traj[-1]
>>> theta = 0.25*np.pi
>>> rcoords = amep.utils.rotate_coords(
...     frame.coords(), theta, np.mean(frame.box, axis=1)
... )
>>> fig, axs = amep.plot.new(ncols=2, figsize=(6,3))
>>> amep.plot.particles(
...     axs[0], frame.coords(), frame.box, frame.radius(),
...     set_ax_limits=False
... )
>>> amep.plot.box(axs[0], frame.box)
>>> axs[0].set_xlim(-10, 90)
>>> axs[0].set_ylim(-10, 90)
>>> axs[0].set_xlabel(r'$x$')
>>> axs[0].set_ylabel(r'$y$')
>>> axs[0].set_title('original')
>>> amep.plot.particles(
...     axs[1], rcoords, frame.box, frame.radius(),
...     set_ax_limits=False
... )
>>> amep.plot.box(axs[1], frame.box)
>>> axs[1].set_xlim(-10, 90)
>>> axs[1].set_ylim(-10, 90)
>>> axs[1].set_xlabel(r'$x$')
>>> axs[1].set_ylabel(r'$y$')
>>> axs[1].set_title('rotated')
>>> fig.savefig('./figures/utils/utils-rotate_coords.png')
>>>
../_images/utils-rotate_coords.png