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:
- Returns:
Variable– An array variable of dtyperotation3.
See also
scipp.spatial.rotationCreate a single rotation transformation.
scipp.spatial.rotations_from_rotvecsCreate rotations from rotation vectors.
Examples
Create multiple rotations from quaternions (identity and 180 deg around z):
>>> import numpy as np >>> import scipp as sc >>> q_array = np.array([[0, 0, 0, 1], [0, 0, 1, 0]]) >>> rots = sc.spatial.rotations(dims=['rot'], values=q_array) >>> rots <scipp.Variable> (rot: 2) rotation3 [dimensionless] [(1+0i+0j+0k), (0+0i+0j+1k)]