Programming/물리엔진/게임엔진
쿼터니온을 Yaw, Pitch, Roll 로 뽑기
알수없는영역
2013. 1. 29. 15:57
D3DXQuaternionRotationMatrix(&qQut, &Rotmat);
float fqw = qQut.w * qQut.w;
float fqx = qQut.x * qQut.x;
float fqy = qQut.y * qQut.y;
float fqz = qQut.z * qQut.z;
float fYaw = atan2f( 2.0f * ( qQut.x * qQut.z + qQut.w * qQut.y ), ( -fqx - fqy + fqz + fqw ) ); // Yaw
float fPitch = asinf( 2.0f * ( qQut.w * qQut.x - qQut.y * qQut.z ) ); // Pitch
float fRoll = atan2f( 2.0f * ( qQut.x * qQut.y + qQut.w * qQut.z ), ( -fqx +fqy -fqz +fqw ) ); // Roll
float x = D3DXToDegree( fPitch );
float y = D3DXToDegree( fYaw );
float z = D3DXToDegree( fRoll );