scipy.spatial.transform.Rotation.from_quat#
- Rotation.from_quat(type cls, quat)#
Initialize from quaternions.
3D rotations can be represented using unit-norm quaternions [1].
- Parameters:
- quatarray_like, shape (N, 4) or (4,)
Each row is a (possibly non-unit norm) quaternion in scalar-last (x, y, z, w) format. Each quaternion will be normalized to unit norm.
- Returns:
- rotation
Rotation
instance Object containing the rotations represented by input quaternions.
- rotation
References
Examples
>>> from scipy.spatial.transform import Rotation as R
Initialize a single rotation:
>>> r = R.from_quat([1, 0, 0, 0]) >>> r.as_quat() array([1., 0., 0., 0.]) >>> r.as_quat().shape (4,)
Initialize multiple rotations in a single object:
>>> r = R.from_quat([ ... [1, 0, 0, 0], ... [0, 0, 0, 1] ... ]) >>> r.as_quat() array([[1., 0., 0., 0.], [0., 0., 0., 1.]]) >>> r.as_quat().shape (2, 4)
It is also possible to have a stack of a single rotation:
>>> r = R.from_quat([[0, 0, 0, 1]]) >>> r.as_quat() array([[0., 0., 0., 1.]]) >>> r.as_quat().shape (1, 4)
Quaternions are normalized before initialization.
>>> r = R.from_quat([0, 0, 1, 1]) >>> r.as_quat() array([0. , 0. , 0.70710678, 0.70710678])