rotate

m3sh.linalg.rotate(x, a, phi, sinphi=None)[source]

Rotate vector about axis.

Rotation is performed via Rodrigues’ rotation formula,

\[\mathbf{x}_{\text{rot}} = \mathbf{x} \cos(\varphi) + (1-\cos(\varphi)) \mathbf{a} \mathbf{a}^T \mathbf{x} + (\mathbf{a} \times \mathbf{x}) \sin(\varphi)\]

which results in a positive (counter-clockwise) rotation for \(\varphi > 0\) when looking on the normal plane of the axis vector pointing towards the viewer (right-hand rule).

Parameters:
  • x (ndarray, shape (3, )) – Vector to be rotated.

  • a (ndarray, shape (3, )) – Normalized axis vector.

  • phi (float) – Rotation angle in radians or \(\cos(\varphi)\).

  • sinphi (float, optional) – \(\sin(\varphi)\).

Returns:

The rotated vector.

Return type:

ndarray

Note

Computation of \(\sin(\varphi)\) can be avoid by providing this value as the optional argument sinphi. In this case phi is taken to be \(\cos(\varphi)\) and no trigonometric functions are evaluated.