diff options
Diffstat (limited to 'src/common/quaternion.h')
| -rw-r--r-- | src/common/quaternion.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/quaternion.h b/src/common/quaternion.h index 84ac82ed3..77f626bcb 100644 --- a/src/common/quaternion.h +++ b/src/common/quaternion.h | |||
| @@ -30,6 +30,11 @@ public: | |||
| 30 | return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), | 30 | return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), |
| 31 | w * other.w - Dot(xyz, other.xyz)}; | 31 | w * other.w - Dot(xyz, other.xyz)}; |
| 32 | } | 32 | } |
| 33 | |||
| 34 | Quaternion<T> Normalized() const { | ||
| 35 | T length = std::sqrt(xyz.Length2() + w * w); | ||
| 36 | return {xyz / length, w / length}; | ||
| 37 | } | ||
| 33 | }; | 38 | }; |
| 34 | 39 | ||
| 35 | template <typename T> | 40 | template <typename T> |