summaryrefslogtreecommitdiffstats
path: root/src/math/Quaternion.h
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-04-25 11:15:29 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-04-25 11:15:29 +0200
commit34ef766c67b50b6abf4a05a77521e2393b116cca (patch)
tree3005e50fdcd82c3a9dc604fdcd89e694d5f621b8 /src/math/Quaternion.h
parentundo (diff)
parentdisable mouse steering by default (diff)
downloadre3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar.gz
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar.bz2
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar.lz
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar.xz
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.tar.zst
re3-34ef766c67b50b6abf4a05a77521e2393b116cca.zip
Diffstat (limited to 'src/math/Quaternion.h')
-rw-r--r--src/math/Quaternion.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h
index fb37dc10..1d04bdff 100644
--- a/src/math/Quaternion.h
+++ b/src/math/Quaternion.h
@@ -10,6 +10,18 @@ public:
float Magnitude(void) const { return Sqrt(x*x + y*y + z*z + w*w); }
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
+ void Normalise(void) {
+ float sq = MagnitudeSqr();
+ if(sq == 0.0f)
+ w = 1.0f;
+ else{
+ float invsqrt = RecipSqrt(sq);
+ x *= invsqrt;
+ y *= invsqrt;
+ z *= invsqrt;
+ w *= invsqrt;
+ }
+ }
const CQuaternion &operator+=(CQuaternion const &right) {
x += right.x;