0
我有一個QVector3D,它定義了局部座標系中的物體速度(=正Z表示向前移動,...),QVector3D在10度(0 .3600)步驟定義對象在全局座標系中的旋轉。將本地(=旋轉後的)座標轉換爲全局座標
現在模擬我的場景,我需要在全局座標系中的對象速度QVector3D。
我找到什麼了到目前爲止是旋轉矩陣(從http://en.wikipedia.org/wiki/Rotation_matrix#Rotations_in_three_dimensions):
qreal angle(qreal in){ //helper function
return in/1800.0f*M_PI;
}
qreal xptr[9]={
1,0,0,
0,cos(angle(rotation.x())),-sin(angle(rotation.x())),
0,sin(angle(rotation.x())),cos(angle(rotation.x()))
};
qreal yptr[9]={
cos(angle(rotation.y())),0,sin(angle(rotation.y())),
0,1,0,
-sin(angle(rotation.y())),0,cos(angle(rotation.y()))
};
qreal zptr[9]={
cos(angle(rotation.z())),-sin(angle(rotation.z())),0,
sin(angle(rotation.z())),cos(angle(rotation.z())),0,
0,0,1
};
,但我不知道如何正確地使用它們。
編輯:如果其相關:單位,旋轉方向......遵循OpenGL標準。
使用四元現在,不需要這些矩陣更多... – nonchip 2011-04-23 13:11:01