我想弄清楚如何將動畫旋轉的Collada(從Assimp)四元數轉換回FBX的歐拉旋轉。我相信這是一個簡單的算法,我找不到合適的算法...我嘗試的所有算法都是錯誤的,通常稱爲ToEulerXYZ。也許是因爲這些旋轉是X,那麼Y,那麼Z,而不是同時?有人知道可能很容易幫助。將四元數轉換回歐拉
這裏是我的測試樣本 - 我輸入歐拉角度,然後導出collada並獲得相應的四元數。我想做相反的事情(從四元數,得到歐拉)。請注意,我知道並不總是得到相同的值,但只需要產生相同旋轉的值。
示例值: 歐拉X,Y,Z 四元X,Y,Z,W
0,0,0-> 0,0,0,1
0.000000,0.000000, 45.000000-> 0,0,0.38268346,0.92387956
45,0,45-> 0.35355338,0.14644660,0.35355338,0.85355341
45,45,0 0.35355338, 0.35355338,-0.14644660,0.85355341
45,45,45-> 0.19134171,0.46193978,0.19134171,0.84462321
30,45,60-> 0.022260016,0.43967974,0.36042345,0.82236314
如果此幫助,Assimp正在生成四元這樣(下Assimp許可證):
angle = 60 * float(AI_MATH_PI)/180.0f;
axis = aiVector3D(0.0f, 0.0f, 1.0f);
aiMatrix4x4::Rotation(angle, axis, rot);
res *= rot;
angle = 45 * float(AI_MATH_PI)/180.0f;
axis = aiVector3D(0.0f, 1.0f, 0.0f);
aiMatrix4x4::Rotation(angle, axis, rot);
res *= rot;
angle = 30 * float(AI_MATH_PI)/180.0f;
axis = aiVector3D(1.0f, 0.0f, 0.0f);
aiMatrix4x4::Rotation(angle, axis, rot);
res *= rot;
aiVector3D scale;
aiQuaternion rotation;
aiVector3D translation;
res.Decompose(scale, rotation, translation);
偉大你想通了一種方式 - 我仍然想知道這是否與用手或什麼有關,很高興知道這個記錄。 – antont