Files
XCEngine/engine/include/XCEngine/Math/Quaternion.h
ssdfasd 7c54a62f9e feat: 添加Math库和Google Test测试框架
- 新增Math库: Vector2/3/4, Matrix3/4, Quaternion, Transform, Color等
- 新增测试框架: Google Test (gtest)
- 新增140个单元测试,覆盖Vector, Matrix, Quaternion, Geometry
- VolumeRenderer支持vcpkg的NanoVDB
- 添加TESTING.md测试文档
2026-03-13 18:43:14 +08:00

41 lines
1.2 KiB
C++

#pragma once
#include "Math.h"
#include "Vector3.h"
namespace XCEngine {
namespace Math {
struct Matrix4x4;
struct Quaternion {
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
float w = 1.0f;
Quaternion() = default;
constexpr Quaternion(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
static Quaternion Identity() { return Quaternion(0, 0, 0, 1); }
static Quaternion FromAxisAngle(const Vector3& axis, float radians);
static Quaternion FromEulerAngles(float pitch, float yaw, float roll);
static Quaternion FromEulerAngles(const Vector3& euler);
static Quaternion FromRotationMatrix(const Matrix4x4& matrix);
static Quaternion Slerp(const Quaternion& a, const Quaternion& b, float t);
static Quaternion LookRotation(const Vector3& forward, const Vector3& up = Vector3::Up());
Vector3 ToEulerAngles() const;
Matrix4x4 ToMatrix4x4() const;
Quaternion operator*(const Quaternion& other) const;
Quaternion Inverse() const;
float Dot(const Quaternion& other) const;
float Magnitude() const;
Quaternion Normalized() const;
static Quaternion Normalize(const Quaternion& q);
};
} // namespace Math
} // namespace XCEngine