mindsponge.common.make_transform_from_reference

mindsponge.common.make_transform_from_reference(point_a, point_b, point_c)[source]

Using GramSchmidt process to construct rotation and translation from given points.

Calculate the rotation matrix and translation meets

  1. point_b is the original point.

  2. point_c is on the x_axis.

  3. the plane a-b-c is on the x-y plane.

\[\begin{split}\begin{split} &\vec v_1 = \vec x_3 - \vec x_2 \\ &\vec v_2 = \vec x_1 - \vec x_2 \\ &\vec e_1 = \vec v_1 / ||\vec v_1|| \\ &\vec u_2 = \vec v_2 - \vec e_1(\vec e_1^T\vec v_2) \\ &\vec e_2 = \vec u_2 / ||\vec u_2|| \\ &\vec e_3 = \vec e_1 \times \vec e_2 \\ &rotation = (\vec e_1, \vec e_2, \vec e_3) \\ &translation = (\vec x_2) \\ \end{split}\end{split}\]
Parameters
  • point_a (float, tensor) -> (tensor) – Spatial location information of atom ‘N’, shape is \([..., N_{res}, 3]\) .

  • point_b (float, tensor) -> (tensor) – Spatial location information of atom ‘CA’, shape is \([..., N_{res}, 3]\) .

  • point_c (float, tensor) -> (tensor) – Spatial location information of atom ‘C’, shape is \([..., N_{res}, 3]\) .

Returns

  • Tuple, rots \((xx, xy, xz, yx, yy, yz, zx, zy, zz)\) , the shape of every element is \((..., N_{res})\) .

  • Tuple, trans \((x, y, z)\) , the shape of every element is \((..., N_{res})\) .

Supported Platforms:

Ascend GPU

Examples

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