scipp.spatial.rotations#

scipp.spatial.rotations(*, dims, values)#

Creates a rotation-type variable from the provided quaternion coefficients.

The quaternion coefficients are provided in scalar-last order (x, y, z, w), where x, y, z and w form the quaternion

\[q = w + xi + yj + zk.\]

Attention

The quaternions must be normalized in order to represent a rotation. You can use, e.g.

>>> q = np.array([[1, 2, 3, 4], [-1, -2, -3, -4]])
>>> rot = sc.spatial.rotations(
...     dims=['x'],
...     values=q / np.linalg.norm(q, axis=1)[:, np.newaxis])
Parameters:
  • dims (Sequence[str]) – The dimensions of the variable.

  • values (ndarray[Any, dtype[TypeVar(_Float, bound= float64 | float32, covariant=True)]] | Sequence[Any]) – A NumPy array of NumPy arrays corresponding to the quaternion coefficients (w, x*i, y*j, z*k)

Returns:

Variable – An array variable of dtype rotation3.