From 73e9629832f282af3608a6c118386a0e1bc2d4b9 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 15:33:17 +0100 Subject: [PATCH] Removed incorrect Quaternion to AngAxis conversion use Float3 AngularAxis( const Quaternion &rotation ) in ::Oyster::Math3D instead --- .../DanBiasGame/GameClientState/GameState.cpp | 4 +- Code/OysterMath/LinearMath.h | 2 +- Code/OysterMath/OysterMath.cpp | 46 ------------------- Code/OysterMath/OysterMath.h | 6 --- 4 files changed, 3 insertions(+), 55 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 1bc77921..66ca6c12 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -420,7 +420,7 @@ void GameState::DataRecieved( NetEventmyId == decoded.object_ID ) - camera.SetAngular( QuaternionToAngularAxis(rotation).xyz ); + camera.SetAngular( AngularAxis(rotation) ); int i = FindObject( this->dynamicObjects, decoded.object_ID ); if( i > -1 ) @@ -437,7 +437,7 @@ void GameState::DataRecieved( NetEventmyId == decoded.object_ID ) { camera.SetPosition( position ); - camera.SetAngular( QuaternionToAngularAxis(rotation).xyz ); + camera.SetAngular( AngularAxis(rotation) ); } int i = FindObject( this->dynamicObjects, decoded.object_ID ); diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index 23fe0511..25b65331 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -375,7 +375,7 @@ namespace LinearAlgebra3D template inline ::LinearAlgebra::Vector3 AngularAxis( const ::LinearAlgebra::Quaternion &rotation ) - { + { // see http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm ScalarType angle = ScalarType(2) * (ScalarType)::std::acos( rotation.real ), multiplier = angle / (ScalarType)::std::sqrt( ScalarType(1) - rotation.real * rotation.real ); return multiplier * rotation.imaginary; diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp index 8db4e175..deac2d0b 100644 --- a/Code/OysterMath/OysterMath.cpp +++ b/Code/OysterMath/OysterMath.cpp @@ -102,52 +102,6 @@ namespace Oyster { namespace Math3D // return ::LinearAlgebra3D::ExtractAngularAxis( orientationMatrix ); //} - Float4 QuaternionToAngularAxis(Float4 quaternion) - { - Float4 axis = Float4::null; - Float s = sqrtf(1 - quaternion.w*quaternion.w); - - axis.w = 2*acos(quaternion.w*quaternion.w); - - if(1 - quaternion.w > 0.001f) - { - axis.x = quaternion.x/s; - axis.y = quaternion.y/s; - axis.z = quaternion.z/s; - } - else - { - axis.x = quaternion.x; - axis.y = quaternion.y; - axis.z = quaternion.z; - } - - return axis; - } - - Float4 QuaternionToAngularAxis(Quaternion quaternion) - { - Float4 axis = Float4::null; - Float s = sqrtf(1 - quaternion.real*quaternion.real); - - axis.w = 2*acos(quaternion.real*quaternion.real); - - if(1 - quaternion.real > 0.001f) - { - axis.x = quaternion.imaginary.x/s; - axis.y = quaternion.imaginary.y/s; - axis.z = quaternion.imaginary.z/s; - } - else - { - axis.x = quaternion.imaginary.x; - axis.y = quaternion.imaginary.y; - axis.z = quaternion.imaginary.z; - } - - return axis; - } - Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem ) { return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index 8de2759a..da23e16d 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -152,12 +152,6 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized ////! Extracts the angularAxis from orientationMatrix //Float4 ExtractAngularAxis( const Float4x4 &orientationMatrix ); - //! Converts a quaternion as Float4 to angular axis as Float4 - Float4 QuaternionToAngularAxis(Float4 quaternion); - - //! Converts a quaternion to angular axis as Float4 - Float4 QuaternionToAngularAxis(Quaternion quaternion); - //! Sets and returns targetMem to a translationMatrix with position as translation. Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem = Float4x4() );