mindsponge.common.apply_to_point
- mindsponge.common.apply_to_point(rotation, translation, point, extra_dims=0)[源代码]
对输入坐标进行旋转平移变换。
\[\begin{split}\begin{split} &rot\_point = rotation \cdot point \\ &result = rot\_point + translation \\ \end{split}\end{split}\]具体的乘法过程与加法过程可以参考 mindsponge.common.rots_mul_vecs 和 mindsponge.common.vecs_add API。
- 参数:
rotation (Tuple) - 旋转矩阵,\((xx, xy, xz, yx, yy, yz, zx, zy, zz)\) ,且 \(xx, xy\) 等均为Tensor且shape相同。
translation (Tuple) - 平移向量, \([(x, y, z)]\) ,其中 \(x, y, z\) 均为Tensor,且shape相同。
point (Tensor) - 初始坐标值, \([(x, y, z)]\) ,其中 \(x, y, z\) 均为Tensor,且shape相同。
extra_dims (int) - 控制进行几次维度的拓展。默认值:
0
。
- 返回:
Tuple,转化后的坐标,长度为3。
- 支持平台:
Ascend
GPU
样例:
>>> import numpy as np >>> from mindsponge.common.geometry import apply_to_point >>> from mindspore.common import Tensor >>> from mindspore import dtype as mstype >>> np.random.seed(1) >>> rotation = [] >>> for i in range(9): ... rotation.append(Tensor(np.random.rand(4),dtype=mstype.float32)) >>> translation = [] >>> for i in range(3): ... translation.append(Tensor(np.random.rand(4),dtype=mstype.float32)) >>> point = [] >>> for i in range(3): ... point.append(Tensor(np.random.rand(4),dtype=mstype.float32)) >>> out = apply_to_point(rotation, translation, point) >>> print(out) (Tensor(shape=[4], dtype=Float32, value= [ 1.02389336e+00, 1.12493467e+00, 2.54357845e-01, 1.25249946e+00]), Tensor(shape=[4], dtype=Float32, value= [ 9.84841168e-01, 5.20081401e-01, 6.43978953e-01, 6.15328550e-01]), Tensor(shape=[4], dtype=Float32, value= [ 8.62860143e-01, 9.11733627e-01, 1.09284782e+00, 1.44202101e+00]))