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

View Source On Gitee
mindsponge.common.rots_from_two_vecs(e0_unnormalized, e1_unnormalized)[source]

Put in two vectors a=(ax,ay,az) and b=(bx,by,bz). 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 e0=a|a| as the unit vector of x axis.

Then calculate the projected length of b on a axis. c=|b|cosθ=ba|a| .

So the projected vector of b on a axis is ce0. The vector perpendicular to e0 is e1=bce0 .

The unit vector of e1 is e1=e1|e1|, which is the y axis of the local coordinate system.

Finally get the unit vector of z axis e2 by calculating cross product of e1 and e0.

The final rots is (e0x,e1x,e2x,e0y,e1y,e2y,e0z,e1z,e2z).

Parameters
  • e0_unnormalized (tuple) – vectors a as x-axis of x-y plane, length is 3. Data type is constant or Tensor with same shape.

  • e1_unnormalized (tuple) – vectors b forming x-y plane, length is 3. Data type is constant or Tensor with same shape.

Returns

tuple, rotation matrix (e0x,e1x,e2x,e0y,e1y,e2y,e0z,e1z,e2z) . 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)