Quaternion(計算用)からDegree(表示用)に変換時、ジンバルロックが起こりm_rotation.x,yの数値が意図しない挙動になります。 以下でデバッグしているのですが rotation.yが0〜90に加算されたのち90〜0に減算されてしまう 0〜90の減算時、xが180になる if (InputKeyTrigger(VK_Q, this)) { XMFLOAT3 degree = {0.0f, 15.0f, 0.0f }; m_quat = DirectXMathLibrary::AddDegreeToQuaternion(degree, m_quat, GetRightVec()); m_rotation.y = DirectXMathLibrary::QuaternionToDegree(m_quat).y; m_rotation.x = DirectXMathLibrary::QuaternionToDegree(m_quat).x; } 実装) MouseMovement() { POINT currPos; GetCursorPos(&currPos); int centerX = SCREEN_WIDTH / 2; int centerY = SCREEN_HEIGHT / 2; ShowCursor(FALSE); SetCursorPos(centerX, centerY); float dx = (currPos.x - centerX) * MOUSE_SENSITIVE; static float dy = 0.0f; float storeDy = dy; dy += (centerY - currPos.y) * MOUSE_SENSITIVE; if (std::fabsf(dy) >= 80.0f) dy = storeDy;//上下制限 Rotate(dx, dy - storeDy); } Rotate(float deltaYaw, float deltaPitch) { // 加算 XMFLOAT3 degree = { -deltaPitch, deltaYaw, 0.0f }; m_quat = DirectXMathLibrary::AddDegreeToQuaternion(degree, m_quat, GetRightVec()); m_rotation.y = DirectXMathLibrary::QuaternionToDegree(m_quat).y; m_rotation.x = DirectXMathLibrary::QuaternionToDegree(m_quat).x; } XMFLOAT3 DirectXMathLibrary::DegreeToRadian(const XMFLOAT3& rot) { XMFLOAT3 rad; rad.x = XMConvertToRadians(rot.x); rad.y = XMConvertToRadians(rot.y); rad.z = XMConvertToRadians(rot.z); return rad; } XMVECTOR DirectXMathLibrary::DegreeToQuaternion( const XMFLOAT3& rot, const XMVECTOR& right) { XMVECTOR worldForward = XMVectorSet(0, 0, 1, 0); XMVECTOR worldUp = XMVectorSet(0, 1, 0, 0); XMFLOAT3 rad = DegreeToRadian(rot); XMVECTOR pitchQuat = XMQuaternionRotationAxis(right, rad.x); XMVECTOR yawQuat = XMQuaternionRotationAxis(worldUp, rad.y); XMVECTOR rollQuat = XMQuaternionRotationAxis(worldForward, rad.z); XMVECTOR quat = XMQuaternionMultiply(rollQuat, pitchQuat); quat = XMQuaternionMultiply(quat, yawQuat); return XMQuaternionNormalize(quat); }