SnapAngularAxis fix

floating point error there acos param could be slightly higher than 1.
Caused it to return undefined.
A clamp ought to fix it.
This commit is contained in:
Dander7BD 2014-02-03 16:20:16 +01:00
parent 8b0e1b2426
commit 358cddfd9a
1 changed files with 1 additions and 1 deletions

View File

@ -794,7 +794,7 @@ namespace LinearAlgebra3D
{ {
::LinearAlgebra::Vector4<ScalarType> worldStartNormal( WorldAxisOf(Rotation(startAngularAxis.xyz), localStartNormal.xyz), (ScalarType)0 ); ::LinearAlgebra::Vector4<ScalarType> worldStartNormal( WorldAxisOf(Rotation(startAngularAxis.xyz), localStartNormal.xyz), (ScalarType)0 );
targetMem = ::LinearAlgebra::Vector4<ScalarType>( worldStartNormal.xyz.Cross(worldEndNormal.xyz), (ScalarType)0); targetMem = ::LinearAlgebra::Vector4<ScalarType>( worldStartNormal.xyz.Cross(worldEndNormal.xyz), (ScalarType)0);
targetMem *= (ScalarType)::std::acos( worldStartNormal.Dot(worldEndNormal) ); targetMem *= (ScalarType)::std::acos( ::Utility::Value::Clamp(worldStartNormal.Dot(worldEndNormal), (ScalarType)0, (ScalarType)1) );
return targetMem += startAngularAxis; return targetMem += startAngularAxis;
} }