gigablochs.utils.rodrigues_rotation

gigablochs.utils.rodrigues_rotation#

gigablochs.utils.rodrigues_rotation(v, k, theta, *, normalize=True, axis=-1)[source]#

Apply Rodrigues rotation formula to rotate a vector v around an axis k by an angle theta.

Parameters:
  • v (array_like) – The vector to be rotated.

  • k (array_like) – The rotation axis.

  • theta (float) – The rotation angle in radians.

  • normalize (bool, optional) – Whether to normalize the rotation axis k. Default is True.

  • axis (int, optional) – The axis along which to compute the norm of k. Default is -1.

Returns:

The rotated vector.

Return type:

array_like

Notes

The Rodrigues rotation formula is given by:

\[v_{\text{rot}} = v \cos\theta + (k \times v) \sin\theta + k (k \cdot v) (1 - \cos\theta)\]

where \(v_{\text{rot}}\) is the rotated vector, \(v\) is the original vector, \(k\) is the rotation axis, and \(\theta\) is the rotation angle.

Examples

>>> import numpy as np
>>> from gigablochs import bloch
>>> v = np.array([1, 0, 0])
>>> k = np.array([0, 0, 1])
>>> theta = np.pi / 2
>>> bloch.rodrigues_rotation(v, k, theta)
array([0., 1., 0.])