Files
XCEngine/docs/api/math/vector2/dot.md
2026-03-20 02:35:15 +08:00

33 lines
660 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Vector2::Dot
```cpp
static float Dot(const Vector2& a, const Vector2& b)
```
计算两个 2D 向量的点积。点积结果可用于判断两个向量的方向关系:正值表示夹角小于 90°零表示垂直负值表示夹角大于 90°。
**参数:**
- `a` - 第一个向量
- `b` - 第二个向量
**返回:** `float` - 点积结果 a.x * b.x + a.y * b.y
**线程安全:**
**异常:** (无)
**复杂度:** O(1)
**示例:**
```cpp
Vector2 a(1.0f, 0.0f);
Vector2 b(0.0f, 1.0f);
float dot = Vector2::Dot(a, b); // 0.0f
```
## 相关文档
- [Vector2](vector2.md) - 返回类总览
- [Cross](Cross.md) - 叉积运算