summaryrefslogtreecommitdiffstats
path: root/src/math/Quaternion.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-04-24 13:49:30 +0200
committerGitHub <noreply@github.com>2020-04-24 13:49:30 +0200
commit17dda21cca625d9c985dded2c3b80746eb937c01 (patch)
treec4be4fa57b16c61d45e8156a51dd07b11e049bba /src/math/Quaternion.h
parentremoved fix that made no sense (diff)
parentimplemented skinned peds, no cutscene hands yet (diff)
downloadre3-17dda21cca625d9c985dded2c3b80746eb937c01.tar
re3-17dda21cca625d9c985dded2c3b80746eb937c01.tar.gz
re3-17dda21cca625d9c985dded2c3b80746eb937c01.tar.bz2
re3-17dda21cca625d9c985dded2c3b80746eb937c01.tar.lz
re3-17dda21cca625d9c985dded2c3b80746eb937c01.tar.xz
re3-17dda21cca625d9c985dded2c3b80746eb937c01.tar.zst
re3-17dda21cca625d9c985dded2c3b80746eb937c01.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;