summaryrefslogtreecommitdiffstats
path: root/src/common/quaternion.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/quaternion.h')
-rw-r--r--src/common/quaternion.h5
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:
return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz),
w * other.w - Dot(xyz, other.xyz)};
}
+
+ Quaternion<T> Normalized() const {
+ T length = std::sqrt(xyz.Length2() + w * w);
+ return {xyz / length, w / length};
+ }
};
template <typename T>