41 lines
928 B
Markdown
41 lines
928 B
Markdown
|
|
# Quaternion::operator*
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
Quaternion operator*(const Quaternion& other) const;
|
||
|
|
Vector3 operator*(const Quaternion& q, const Vector3& v);
|
||
|
|
```
|
||
|
|
|
||
|
|
四元数乘法运算符。
|
||
|
|
|
||
|
|
**成员函数版本(四元数 * 四元数):**
|
||
|
|
- `other` - 另一个四元数
|
||
|
|
- **返回:** 组合旋转后的四元数
|
||
|
|
|
||
|
|
**全局函数版本(四元数 * 向量):**
|
||
|
|
- `q` - 四元数
|
||
|
|
- `v` - 要旋转的三维向量
|
||
|
|
- **返回:** 旋转后的向量
|
||
|
|
|
||
|
|
**线程安全:** ✅
|
||
|
|
|
||
|
|
**复杂度:** O(1)
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
#include <XCEngine/Math/Quaternion.h>
|
||
|
|
#include <XCEngine/Math/Vector3.h>
|
||
|
|
|
||
|
|
using namespace XCEngine::Math;
|
||
|
|
|
||
|
|
Quaternion q1 = Quaternion::FromAxisAngle(Vector3::Up(), Math::Radians(90.0f));
|
||
|
|
Quaternion q2 = Quaternion::FromAxisAngle(Vector3::Right(), Math::Radians(90.0f));
|
||
|
|
|
||
|
|
Quaternion combined = q1 * q2;
|
||
|
|
Vector3 rotated = q1 * Vector3::Forward();
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [Quaternion](quaternion.md) - 返回类总览
|