mindsponge.common.quat_to_rot

mindsponge.common.quat_to_rot(normalized_quat, use_numpy=False)[source]

Convert a normalized quaternion to a rotation matrix.

xx=12yy2zzxy=2xy+2wzxz=2xz2wyyx=2xy2wzyy=12xx2zzyz=2zy+2wxzx=2xz+2wyzy=2yz2wxzz=12xx2yy
Parameters
  • normalized_quat (tensor) – normalized quaternion, shape (Nres,4).

  • use_numpy (bool) – use numpy or not, Default: “False”.

Returns

tuple, rotation (xx,xy,xz,yx,yy,yz,zx,zy,zz), every element shape (Nres,).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import Tensor
>>> from mindsponge.common.geometry import quat_to_rot
>>> input_0 = Tensor(np.ones((256, 4)), ms.float32)
>>> output = quat_to_rot(input_0)
>>> print(len(output), output[0].shape)
9, (256,)