Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindsponge.common.quaternion_from_tensor

View Source On Gitee
mindsponge.common.quaternion_from_tensor(tensor, normalize=False)[source]

Take the input 'tensor' [(xx,xy,xz,yx,yy,yz,zz)] to get the new 'quaternion', 'rotation', 'translation'.

tensor=[(xx,xy,xz,yx,yy,yz,zz)]quaternion=(xx,xy,xz,yx)translation=(yy,yz,zz)

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 [(xx,xy,xz,yx,yy,yz,zz)] . [(xx,xy,xz,yx)] is the same with quaternion. (yy,yz,zz) 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 (...,4) .

  • Tuple, new rotation, (xx,xy,xz,yx,yy,yz,zx,zy,zz), and xx and xy are Tensor and have the same shape.

  • Tuple, translation vector [(x,y,z)], 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))