将四元数从右手坐标翻转到左手坐标 [英] Flipping a quaternion from right to left handed coordinates

查看:144
本文介绍了将四元数从右手坐标翻转到左手坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从右翻转四元数:
x = left to right
y = front to back
z = top to bottom

I need to flip a quaternion from right:
x = left to right
y = front to back
z = top to bottom

到左手坐标,其中:
x = left to right
y = top to bottom
z = front to back

to left handed coordinates where:
x = left to right
y = top to bottom
z = front to back

我该怎么做?

推荐答案

我认为这些答案都不正确.

I don't think any of these answers is correct.

安德列斯认为四元数没有惯用性是正确的.惯用性(或我称之为轴约定")是人类适用的一种属性.这就是我们将向前,向右,向上"的概念映射到X,Y,Z轴的方式.

Andres is correct that quaternions don't have handedness. Handedness (or what I'll call "axis conventions") is a property that humans apply; it's how we map our concepts of "forward, right, up" to the X, Y, Z axes.

这些都是真的:

  • 纯旋转矩阵(正交,行列式1等)可以转换为四元数单位并返回,以恢复原始矩阵.
  • 不是纯旋转的矩阵(行列式为-1的矩阵,例如,翻转单个轴的矩阵)也称为不正确的旋转",并且不能转换为单位四元数,并且背部.您的mat_to_quat()例程可能不会崩溃,但不会为您提供正确的答案(就quat_to_mat(mat_to_quat(M)) == M而言).
  • 换手的基础改变具有行列式-1.这是不适当的旋转:等同于围绕原点镜像的旋转(也许是身份).
  • Pure-rotation matrices (orthogonal, determinant 1, etc) can be converted to a unit quaternion and back, recovering the original matrix.
  • Matrices that are not pure rotations (ones that have determinant -1, for example matrices that flip a single axis) are also called "improper rotations", and cannot be converted to a unit quaternion and back. Your mat_to_quat() routine may not blow up, but it won't give you the right answer (in the sense that quat_to_mat(mat_to_quat(M)) == M).
  • A change-of-basis that swaps handedness has determinant -1. It is an improper rotation: equivalent to a rotation (maybe identity) composed with a mirroring about the origin.

要更改四元数的基础,例如从ROS(右手)更改为Unity(左手),我们可以使用.

To change the basis of a quaternion, say from ROS (right-handed) to Unity (left-handed), we can use the method of .

mat3x3 ros_to_unity = /* construct this by hand */;
mat3x3 unity_to_ros = ros_to_unity.inverse();
quat q_ros = ...;
mat3x3 m_unity = ros_to_unity * mat3x3(q_ros) * unity_to_ros ;
quat q_unity = mat_to_quat(m_unity);

第1-4行只是 https://stackoverflow.com/a/39519079/194921 的方法: 您如何在矩阵上执行基础变更?"

Lines 1-4 are simply the method of https://stackoverflow.com/a/39519079/194921: "How do you perform a change-of-basis on a matrix?"

第5行很有趣.我们知道mat_to_quat()仅适用于纯旋转矩阵.我们怎么知道m_unity是纯旋转?当然可以想象并非如此,因为unity_to_rosros_to_unity都具有行列式-1(由于换手功能).

Line 5 is interesting. We know mat_to_quat() only works on pure-rotation matrices. How do we know that m_unity is a pure rotation? It's certainly conceivable that it's not, because unity_to_ros and ros_to_unity both have determinant -1 (as a result of the handedness switch).

波浪手势的回答是,惯性切换了两次,因此结果没有惯性切换.更深层的答案与以下事实有关:相似性转换保留了运算符的某些方面,但是我没有足够的数学来证明.

The hand-wavy answer is that the handedness is switching twice, so the result has no handedness switch. The deeper answer has to do with the fact that similarity transformations preserve certain aspects of the operator, but I don't have enough math to make the proof.

请注意,这将为您提供正确的结果,但是如果unity_to_ros是简单矩阵(例如,仅进行轴交换),则可以更快地完成操作.但是您可能应该通过扩展此处完成的数学运算来得出更快的方法.

Note that this will give you a correct result, but you can probably do it more quickly if unity_to_ros is a simple matrix (say, with just an axis swap). But you should probably derive that faster method by expanding the math done here.

这篇关于将四元数从右手坐标翻转到左手坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆