summaryrefslogtreecommitdiff
path: root/ui/gfx/geometry/quaternion.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/geometry/quaternion.cc')
-rw-r--r--ui/gfx/geometry/quaternion.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/ui/gfx/geometry/quaternion.cc b/ui/gfx/geometry/quaternion.cc
index 9da8f47111..ef7fae06c7 100644
--- a/ui/gfx/geometry/quaternion.cc
+++ b/ui/gfx/geometry/quaternion.cc
@@ -80,8 +80,12 @@ Quaternion Quaternion::Lerp(const Quaternion& q, double t) const {
return (((1.0 - t) * *this) + (t * q)).Normalized();
}
+double Quaternion::Length() const {
+ return x_ * x_ + y_ * y_ + z_ * z_ + w_ * w_;
+}
+
Quaternion Quaternion::Normalized() const {
- double length = x_ * x_ + y_ * y_ + z_ * z_ + w_ * w_;
+ double length = Length();
if (length < kEpsilon)
return *this;
return *this / sqrt(length);