mindsponge.common.quat_affine

查看源文件
mindsponge.common.quat_affine(quaternion, translation, rotation=None, normalize=True, unstack_inputs=False, use_numpy=False)[源代码]

基于旋转矩阵与平移向量生成仿射变换。

参数:
  • quaternion (tensor) - shape为 \((N_{res}, 4)\)

  • translation (tensor) - shape为 \((N_{res}, 3)\)

  • rotation (tensor) - 旋转矩阵,shape为 \((N_{res}, 9)\)

  • normalize (bool) - 是否归一化,默认值: True

  • unstack_inputs (bool) - 输入为向量(True)还是张量(False),默认值: False

  • use_numpy (bool) - 是否使用numpy计算,默认值: False

返回:

返回仿射变换后结果。

  • 四元数 (tensor),shape为 \((N_{res}, 4)\)

  • 旋转矩阵 (tuple) \((xx, xy, xz, yx, yy, yz, zx, zy, zz)\) ,每个元素shape为 \((N_{res},)\)

  • 平移向量 (tensor),shape为 \((N_{res}, 3)\)

支持平台:

Ascend GPU

样例:

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import Tensor
>>> from mindsponge.common.geometry import quat_affine
>>> input_0 = Tensor(np.ones((256, 4)), ms.float32)
>>> input_1 = Tensor(np.ones((256, 3)), ms.float32)
>>> qua, rot, trans = quat_affine(input_0, input_1)
>>> print(qua.shape, len(rot), rot[0].shape, trans.shape)
(256, 4), 9, (256,), (256, 3)