# Quaternion::FromRotationMatrix ```cpp static Quaternion FromRotationMatrix(const Matrix4x4& matrix); ``` 从 4x4 旋转矩阵创建四元数。矩阵必须是正交矩阵且行列式为 1。 **参数:** - `matrix` - 旋转矩阵 **返回:** 对应的四元数 **线程安全:** ✅ **复杂度:** O(1) **示例:** ```cpp #include #include using namespace XCEngine::Math; Matrix4 rotMatrix; rotMatrix.m[0][0] = 1; rotMatrix.m[0][1] = 0; rotMatrix.m[0][2] = 0; rotMatrix.m[1][0] = 0; rotMatrix.m[1][1] = 0; rotMatrix.m[1][2] = -1; rotMatrix.m[2][0] = 0; rotMatrix.m[2][1] = 1; rotMatrix.m[2][2] = 0; Quaternion q = Quaternion::FromRotationMatrix(rotMatrix); ``` ## 相关文档 - [Quaternion](quaternion.md) - 返回类总览 - [ToMatrix4x4](to-matrix4x4.md) - 转换为矩阵