Merge branch 'Physics' of https://github.com/dean11/Danbias into Physics

This commit is contained in:
Robin Engman 2014-01-21 14:11:17 +01:00
commit b0227ab513
2 changed files with 13 additions and 3 deletions

View File

@ -733,7 +733,7 @@ namespace LinearAlgebra3D
ScalarType projectedMagnitude = rotation.v[0].Dot( normalizedAxis );
if( projectedMagnitude == 1 )
{ // infinite possible solutions -> roadtrip!
::LinearAlgebra::Vector4<ScalarType> interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, t );
::LinearAlgebra::Vector4<ScalarType> interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, (ScalarType)0.5f );
// interpolated.Dot( interpolated ) == 0 should be impossible at this point
projectedMagnitude = rotation.v[0].Dot( interpolated );
@ -744,7 +744,8 @@ namespace LinearAlgebra3D
rotation.v[0] -= projectedMagnitude * normalizedAxis;
rotation.v[0].Normalize();
rotation.v[1] = normalizedAxis;
rotation.v[2] = rotation.v[0].Cross( rotation.v[1] );
rotation.v[2].xyz = rotation.v[0].xyz.Cross( rotation.v[1].xyz );
return rotation;
}
template<typename ScalarType>
@ -753,7 +754,7 @@ namespace LinearAlgebra3D
::LinearAlgebra::Vector4<ScalarType> interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, t );
if( interpolated.Dot(interpolated) == 0 )
return rotation; // return no change
return SnapAxisYToAxis_Nlerp( rotation, interpolated );
return SnapAxisYToNormal_UsingNlerp( rotation, interpolated );
}
}

View File

@ -46,7 +46,16 @@ namespace Oyster { namespace Math //! Oyster's native math library
//! Returns false if there is no explicit solution.
bool SuperpositionMatrix( const Float4x4 &in, const Float4x4 &out, Float4x4 &targetMem );
/********************************************************************
* Linear Interpolation
* @return start * (1-t) + end * t
********************************************************************/
using ::LinearAlgebra::Lerp;
/********************************************************************
* Normalized Linear Interpolation
* @return nullvector if Lerp( start, end, t ) is nullvector.
********************************************************************/
using ::LinearAlgebra::Nlerp;
} }