Files
XCSDD/docs/api/math/vector4/vector4.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

1.2 KiB
Raw Permalink Blame History

Vector4

4D 向量结构体,用于表示齐次坐标、颜色 (RGBA) 或 SIMD 操作。

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

命名空间: XCEngine::Math

结构体定义

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

构造函数

  • Vector4(float x, float y, float z, float w) - 从四个分量构造
  • explicit Vector4(const Vector3& v, float w = 0.0f) - 从 Vector3 构造

静态工厂方法

方法 返回值 描述
Zero() Vector4 返回 (0, 0, 0, 0)
One() Vector4 返回 (1, 1, 1, 1)

静态数学方法

方法 返回值 描述
Dot(a, b) float 4D 点积
Project(vector, onNormal) Vector4 投影

实例方法

方法 返回值 描述
ToVector3() Vector3 转换到 Vector3丢弃 w

运算符

  • 算术: +, -, * (scalar)
  • 下标: operator[] (0=x, 1=y, 2=z, 3=w)
  • 比较: ==, !=

相关文档