from_scipy_rotation#
- classmethod Quaternion.from_scipy_rotation(rotation: Rotation) Quaternion [source]#
Create unit quaternions from
scipy.spatial.transform.Rotation
.- Parameters:
- rotation
SciPy rotations.
- Returns:
quaternion
Quaternions.
Notes
The SciPy rotation is inverted to be consistent with the orix framework of passive rotations.
While orix represents quaternions with the scalar as the first parameter, SciPy has the scalar as the last parameter.
Examples
>>> from orix.quaternion import Quaternion >>> from orix.vector import Vector3d >>> from scipy.spatial.transform import Rotation as SciPyRotation
SciPy and orix represent quaternions differently
>>> R_scipy = SciPyRotation.from_euler("ZXZ", [90, 0, 0], degrees=True) >>> R_scipy.as_quat() array([0. , 0. , 0.70710678, 0.70710678]) >>> Q = Quaternion.from_scipy_rotation(R_scipy) >>> Q Quaternion (1,) [[ 0.7071 0. 0. -0.7071]] >>> ~Q Quaternion (1,) [[ 0.7071 -0. -0. 0.7071]]
SciPy and orix rotate vectors differently
>>> v = [1, 1, 0] >>> R_scipy.apply(v) array([-1., 1., 0.]) >>> Q * Vector3d(v) Vector3d (1,) [[ 1. -1. 0.]] >>> ~Q * Vector3d(v) Vector3d (1,) [[-1. 1. 0.]]