2016-08-30 44 views
1

我有一個四元數,從一個系統來具有以下:切換軸和四元數的手型?

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#工作,用

Microsoft.Xna.Quaternion. 

回答

2

四元數是四個值的結構(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