Added RotationMatrix for Float3x3

This commit is contained in:
Dander7BD 2014-02-10 11:59:35 +01:00
parent 0c4f70e400
commit abdb820b09
3 changed files with 19 additions and 0 deletions

View File

@ -451,6 +451,17 @@ namespace LinearAlgebra3D
} }
} }
template<typename ScalarType>
inline ::LinearAlgebra::Matrix3x3<ScalarType> & RotationMatrix( const ::LinearAlgebra::Quaternion<ScalarType> &rotationQuaternion, ::LinearAlgebra::Matrix3x3<ScalarType> &targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>() )
{
::LinearAlgebra::Quaternion<ScalarType> conjugate = rotationQuaternion.GetConjugate();
targetMem.v[0] = (rotationQuaternion * ::LinearAlgebra::Vector3<ScalarType>(1,0,0) * conjugate).imaginary;
targetMem.v[1] = (rotationQuaternion * ::LinearAlgebra::Vector3<ScalarType>(0,1,0) * conjugate).imaginary;
targetMem.v[2] = (rotationQuaternion * ::LinearAlgebra::Vector3<ScalarType>(0,0,1) * conjugate).imaginary;
return targetMem;
}
template<typename ScalarType> template<typename ScalarType>
inline ::LinearAlgebra::Matrix4x4<ScalarType> & RotationMatrix( const ::LinearAlgebra::Quaternion<ScalarType> &rotationQuaternion, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() ) inline ::LinearAlgebra::Matrix4x4<ScalarType> & RotationMatrix( const ::LinearAlgebra::Quaternion<ScalarType> &rotationQuaternion, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
{ {

View File

@ -121,6 +121,11 @@ namespace Oyster { namespace Math3D
return ::LinearAlgebra3D::Rotation( angularAxis ); return ::LinearAlgebra3D::Rotation( angularAxis );
} }
Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem )
{
return ::LinearAlgebra3D::RotationMatrix( rotationQuaternion, targetMem );
}
Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem ) Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem )
{ {
return ::LinearAlgebra3D::RotationMatrix( rotationQuaternion, targetMem ); return ::LinearAlgebra3D::RotationMatrix( rotationQuaternion, targetMem );

View File

@ -164,6 +164,9 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized
/** @todo TODO: add doc */ /** @todo TODO: add doc */
Quaternion Rotation( const Float4 &angularAxis ); Quaternion Rotation( const Float4 &angularAxis );
/** @todo TODO: add doc */
Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem = Float3x3() );
/** @todo TODO: add doc */ /** @todo TODO: add doc */
Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem = Float4x4() ); Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem = Float4x4() );