Files
XCEngine/docs/api/math/quaternion/quaternion.md
ssdfasd 7e4c48d4f9 docs: Document stub/not-implemented methods in resources module
Fixed discrepancies between source code and documentation:
- AsyncLoader: Document Initialize() ignores workerThreadCount, Submit() doesn't do actual async loading, Update() is stub
- ResourceManager: Document UnloadUnused() and ReloadResource() are stubs
- ResourceCache: Document OnZeroRefCount() and Flush() are stubs
- ResourceDependencyGraph: Document TopologicalSort() returns empty (stub)
- ResourceFileSystem: Document GetResourceInfo() doesn't fill modifiedTime, EnumerateResources() is stub
- FileArchive: Document Enumerate() is stub
- ResourcePackageBuilder: Document AddDirectory() is stub
- ImportSettings: Document LoadFromJSON/SaveToJSON are stubs
- TextureImportSettings/MeshImportSettings: Document JSON methods are stubs
- TextureLoader/MeshLoader/MaterialLoader/ShaderLoader/AudioLoader: Document GetDefaultSettings() returns nullptr
- AudioLoader: Document ParseWAVData() is stub, Load() doesn't parse WAV headers
- ShaderLoader: Document DetectShaderType/ParseShaderSource are stubs
- MaterialLoader: Document ParseMaterialData() is stub
- Texture: Document Create() mipLevels=0 behavior, GenerateMipmaps() returns false
- Mesh: Document MeshLoader::Load() is example only
- IResourceLoader: Document GetDefaultSettings() returns nullptr for all loaders
2026-03-19 01:16:12 +08:00

1.9 KiB

Quaternion

四元数结构体,用于表示 3D 旋转,避免欧拉角的万向锁问题。

头文件: #include <XCEngine/Math/Quaternion.h>

命名空间: XCEngine::Math

结构体定义

struct Quaternion {
    float x = 0.0f;
    float y = 0.0f;
    float z = 0.0f;
    float w = 1.0f;
};

静态工厂方法

方法 返回值 描述
Identity() Quaternion 返回 (0, 0, 0, 1),恒等旋转
FromAxisAngle(axis, radians) Quaternion 从轴角创建
FromEulerAngles(pitch, yaw, roll) Quaternion 从欧拉角创建(弧度)
FromEulerAngles(euler) Quaternion 从 Vector3 欧拉角创建
FromRotationMatrix(matrix) Quaternion 从旋转矩阵创建
Slerp(a, b, t) Quaternion 球面线性插值
LookRotation(forward, up) Quaternion 看向方向

实例方法

方法 返回值 描述
ToEulerAngles() Vector3 转换为欧拉角(弧度)
ToMatrix4x4() Matrix4 转换为 4x4 旋转矩阵
Inverse() Quaternion 共轭/逆四元数
Dot(other) float 点积
Magnitude() float 模长
Normalized() Quaternion 归一化副本

静态方法

方法 返回值 描述
Normalize(q) Quaternion 归一化四元数

运算符

运算符 描述
operator*(Quaternion, Quaternion) 组合旋转

与 Vector3 的乘法

Vector3 * Quaternion - 用四元数旋转向量

相关文档