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.pre_compose

View Source On Gitee
mindsponge.common.pre_compose(quaternion, rotation, translation, update)[source]

Return a new QuatAffine which applies the transformation update first.

The process of obtaining the updated translation vector and rotation matrix is as follows:

update=(xx,xy,xz,yx,yy,yz)vector_quaternion_update=(xx,xy,xz)x=(yx)y=(yy)z=(yz)trans_update=(x,y,z)new_quaternion=quaternion+vector_quaternion_updatequaternionrotated_trans_update=rotationtrans_updatenew_translation=translation+rotated_trans_update

vector_quaternion_update and quaternion are multiplied by the quat_multiply_by_vec function, Affine transformation is performed using the generated new_quaternion and new_translation. The process of affine transformation is referred to the quat_affine api.

Parameters
  • quaternion (Tensor) – The initial quaternion to be updated, shape [(...,4)].

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

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

  • update (Tensor) – The update-assisted matrix has shape [(...,6)]. 3-vector of x, y, and z such that the quaternion update is (1,x,y,z) and zero for the 3-vector is the identity quaternion. 3-vector for translation concatenated.

Returns

  • Tensor, new quaternion.The updated Tensor tuple has shape [(...,4)].

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

  • Tuple, the updated 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 pre_compose
>>> from mindspore.common import Tensor
>>> from mindspore import dtype as mstype
>>> np.random.seed(1)
>>> quaternion = Tensor(np.random.rand(4),dtype=mstype.float32)
>>> update = Tensor(np.random.rand(6),dtype=mstype.float32)
>>> rotation = Tensor(np.random.rand(9),dtype=mstype.float32)
>>> translation = Tensor(np.random.rand(3),dtype=mstype.float32)
>>> quaternion, rotation, translation = pre_compose(quaternion,rotation,translation,update)
>>> print(quaternion)
[ 0.27905196  0.82475466 -0.05600705  0.48864394]
>>> print(rotation)
(Tensor(shape=[], dtype=Float32, value= 0.516181), Tensor(shape=[], dtype=Float32, value= -0.365098),
Tensor(shape=[], dtype=Float32, value= 0.774765), Tensor(shape=[], dtype=Float32, value= 0.18033),
Tensor(shape=[], dtype=Float32, value= -0.837986), Tensor(shape=[], dtype=Float32, value= -0.515034),
Tensor(shape=[], dtype=Float32, value= 0.837281), Tensor(shape=[], dtype=Float32, value= 0.405564),
Tensor(shape=[], dtype=Float32, value= -0.366714))
>>> print(translation)
(Tensor(shape=[], dtype=Float32, value= 0.724994), Tensor(shape=[], dtype=Float32, value= 1.47631),
Tensor(shape=[], dtype=Float32, value= 1.40978))