Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 切换四元数的轴和惯用手?_C#_Rotation_Xna_Game Engine_Quaternions - Fatal编程技术网

C# 切换四元数的轴和惯用手?

C# 切换四元数的轴和惯用手?,c#,rotation,xna,game-engine,quaternions,C#,Rotation,Xna,Game Engine,Quaternions,我有一个四元数,来自一个系统,具有以下内容: Right handed. Forward direction: Y axis Right direction: X axis Up direction: Z axis 我需要将其转换为坐标系,即: left-handed. Forward direction: X axis Right direction: Y axis Up direction: Z axis 我试过否定轴和角度,我试过切换值,我不能让它工作。非常感谢大家的帮助!我在C#工作

我有一个四元数,来自一个系统,具有以下内容:

Right handed.
Forward direction: Y axis
Right direction: X axis
Up direction: Z axis
我需要将其转换为坐标系,即:

left-handed.
Forward direction: X axis
Right direction: Y axis
Up direction: Z axis
我试过否定轴和角度,我试过切换值,我不能让它工作。非常感谢大家的帮助!我在C#工作,和


四元数是由四个值组成的结构
(w,x,y,z)
。如果它表示旋转,则
w=cos(phi/2)
phi
表示旋转角度)和
(x,y,z)=sin(phi/2)*(ax,ay,az)
(ax,ay,az)
表示旋转轴)

为了将四元数转换为另一个系统,只需变换旋转轴即可。对于您的示例,转换为:

    / 0  1  0 \
T = | 1  0  0 |
    \ 0  0  1 /
最后,由于要更改手的习惯,必须反转四元数,否则它将以错误的方向旋转。总之,转换后的四元数是:

(w*, x*, y*, z*) = (w, -y, -x, -z)
一般而言:

(x*, y*, z*) = det(T) T (x, y, z) //Assuming column vectors
(x*, y*, z*) = det(T) T (x, y, z) //Assuming column vectors