mindsponge.common.quaternion_to_tensor

查看源文件
mindsponge.common.quaternion_to_tensor(quaternion, translation)[源代码]

将输入的四元数变为Tensor。

\[\begin{split}\begin{split} &quaternion = [(x_1, y_1, z_1, m_1)] \\ &translation = [(x_2, y_2, z_2)] \\ &result = [(x_1, y_1, z_1, m_1, x_2, y_2, z_2)] \\ \end{split}\end{split}\]
参数:
  • quaternion (Tensor) - 输入的初始坐标,shape为 \((..., 4)\) 的Tensor。

  • translation (Tensor) - 坐标平移值,shape为 \((..., 3)\) 的Tensor。

返回:

Tensor,返回 quaterniontranslation 的连接结果,shape为 \((..., 7)\)

支持平台:

Ascend GPU

样例:

>>> import numpy as np
>>> from mindsponge.common.geometry import quaternion_to_tensor
>>> from mindspore.common import Tensor
>>> from mindspore import dtype as mstype
>>> np.random.seed(1)
>>> quaternion = Tensor(np.random.rand(4),dtype=mstype.float32)
>>> translation = Tensor(np.random.rand(3),dtype=mstype.float32)
>>> out = quaternion_to_tensor(quaternion, translation)
>>> print(out)
[0.6631489  0.44137922 0.97213906 0.7425225  0.3549025  0.6535310.5426164 ]