mindsponge.common.apply_to_point

mindsponge.common.apply_to_point(rotation, translation, point, extra_dims=0)[source]

Rotate and translate the input coordinates.

\[\begin{split}\begin{split} &rot_point = rotation \cdot point \\ &result = rot_point + translation \\ \end{split}\end{split}\]

For specific multiplication and addition procedures, refer to the rots_mul_vecs and vecs_add apis.

Parameters
  • rotation (Tuple) – The rotation matrix \((xx, xy, xz, yx, yy, yz, zx, zy, zz)\), and \(xx, xy\) are Tensor and have the same shape.

  • translation (Tuple) – Translation vector \([(x, y, z)]\), where \(x, y, z\) are Tensor and have the same shape.

  • point (Tensor) – Initial coordinate values \([(x, y, z)]\), where \(x, y, z\) are Tensor and have the same shape.

  • extra_dims (int) – Control whether to expand dims. default:0.

Returns

Tuple, the result of the coordinate transformation. Length is 3.

Supported Platforms:

Ascend GPU

Examples

>>> 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]))