mindsponge.common.quaternion_from_tensor
- mindsponge.common.quaternion_from_tensor(tensor, normalize=False)[source]
Take the input 'tensor'
to get the new 'quaternion', 'rotation', 'translation'.Affine transformation is performed using the generated quaternion and translation. The process of affine transformation is referred to the quat_affine api.
- Parameters
tensor (Tensor) – An initial Tensor
. is the same with quaternion. is the same with translation.normalize (bool) – Control whether to find the norm during quat_affine. Default:
False
.
- Returns
Tensor, new quaternion.Tensor of shape
.Tuple, new rotation,
, and xx and xy are Tensor and have the same shape.Tuple, translation vector
, where x, y and z are Tensor and have the same shape.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> from mindsponge.common.geometry import quaternion_from_tensor >>> from mindspore.common import Tensor >>> tensor = Tensor(np.random.rand(7),dtype=mstype.float32) >>> quaternion, rotation, translation = quaternion_from_tensor(tensor) >>> print(quaternion) [4.17021990e-01, 7.20324516e-01, 1.14374816e-04, 3.02332580e-01] >>> print(rotation) (Tensor(shape=[], dtype=Float32, value= 0.60137), Tensor(shape=[], dtype=Float32, value= -0.251994), Tensor(shape=[], dtype=Float32, value= 0.435651), Tensor(shape=[], dtype=Float32, value= 0.252323), Tensor(shape=[], dtype=Float32, value= -0.436365), Tensor(shape=[], dtype=Float32, value= -0.600713), Tensor(shape=[], dtype=Float32, value= 0.43546), Tensor(shape=[], dtype=Float32, value= 0.600851), Tensor(shape=[], dtype=Float32, value= -0.253555)) >>> print(translation) (Tensor(shape=[], dtype=Float32, value= 0.146756),Tensor(shape=[], dtype=Float32, value= 0.0923386), Tensor(shape=[], dtype=Float32, value= 0.18626))