From 3630f97ab14867887acb196283ee3c09fc73efed Mon Sep 17 00:00:00 2001 From: irei1as Date: Tue, 22 Sep 2015 19:37:42 +0200 Subject: [PATCH] mQuat.h change to fix QuatF::angleBetween The old version doesn't have that 2.0f in the return that seems to be needed. Also added normalizing inside so it can be used for not-normalized quaternions too. --- Engine/source/math/mQuat.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Engine/source/math/mQuat.h b/Engine/source/math/mQuat.h index 2ea1b94c1..c167e4e18 100644 --- a/Engine/source/math/mQuat.h +++ b/Engine/source/math/mQuat.h @@ -227,8 +227,13 @@ inline F32 QuatF::dot( const QuatF &q ) const inline F32 QuatF::angleBetween( const QuatF & q ) { - // angle between to quaternions - return mAcos(x * q.x + y * q.y + z * q.z + w * q.w); + // angle between two quaternions + QuatF base(x,y,z,w); + base=base.normalize(); + QuatF q_norm=q; + q_norm=q_norm.normalize(); + return 2.0f*mAcos(base.dot(q_norm)); } + #endif // _MQUAT_H_