Fixed broken references: - texture-import-settings: Fix 16 files referencing wrong overview filename - math/rectint: Fix 9 method links (rectint-* → get*, contains, intersects) - rhi/opengl/device: Fix 8 cross-references (opengl-* → */**) - resources/mesh: Fix meshsection and vertexattribute links - rhi/d3d12/sampler: Fix RHISampler reference path - math/vector3: Fix projectonplane → project-on-plane - rhi/opengl/command-list: Remove broken ClearFlag enum ref - rhi/opengl/device: Create 2 new method docs (MakeContextCurrent, GetNativeContext) - rhi/device: Fix device-info types reference All 0 broken references remaining.
38 lines
865 B
Markdown
38 lines
865 B
Markdown
# Quaternion::FromRotationMatrix
|
|
|
|
```cpp
|
|
static Quaternion FromRotationMatrix(const Matrix4x4& matrix);
|
|
```
|
|
|
|
从 4x4 旋转矩阵创建四元数。矩阵必须是正交矩阵且行列式为 1。
|
|
|
|
**参数:**
|
|
- `matrix` - 旋转矩阵
|
|
|
|
**返回:** 对应的四元数
|
|
|
|
**线程安全:** ✅
|
|
|
|
**复杂度:** O(1)
|
|
|
|
**示例:**
|
|
|
|
```cpp
|
|
#include <XCEngine/Core/Math/Quaternion.h>
|
|
#include <XCEngine/Core/Math/Matrix4.h>
|
|
|
|
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) - 转换为矩阵
|