mindsponge.common.rots_from_two_vecs
- mindsponge.common.rots_from_two_vecs(e0_unnormalized, e1_unnormalized)[source]
Put in two vectors
and . Calculate the rotation matrix between local coordinate system, in which the x-y plane consists of two input vectors and global coordinate system.Calculate the unit vector
as the unit vector of x axis.Then calculate the projected length of
on a axis. .So the projected vector of
on a axis is . The vector perpendicular to e0 is .The unit vector of
is , which is the y axis of the local coordinate system.Finally get the unit vector of z axis
by calculating cross product of and .The final rots is
.- Parameters
- Returns
tuple, rotation matrix
. Data type is constant or Tensor with same shape.
- Supported Platforms:
Ascend
GPU
Examples
>>> import mindsponge >>> v1 = (1, 2, 3) >>> v2 = (3, 4, 5) >>> ans = mindsponge.common.rots_from_two_vecs(v1, v2) >>> print(ans) (0.4242640686695021, -0.808290367995452, 0.40824828617045156, 0.5656854248926695, -0.1154700520346678, -0.8164965723409039, 0.7071067811158369, 0.5773502639261153, 0.4082482861704521)