m3sh.linalg.

rotate#

rotate(x, axis, phi, sin_phi=None)#

Rotate vector about axis.

A rotation is defined by an oriented axis vector of unit length and an oriented angle. The corresponding rotation can be computed 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).\]

This corresponds to 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, axisndarray, shape (3,)

Vector to be rotated and unit length axis vector.

phifloat

Rotation angle in radians or the value \(\cos(\varphi)\).

sin_phifloat, optional

The value \(\sin(\varphi)\).

Returns:
x_rotndarray, shape (3,)

The rotated vector.

See also

rotation

Notes

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