fix bug #398, the quaternion returned by slerp was not always normalized,

add a proper unit test for slerp
(transplanted from 8171adb7ff
)
This commit is contained in:
Gael Guennebaud
2011-12-23 22:39:32 +01:00
parent 05f45cfecd
commit 28bbc4bf47
2 changed files with 50 additions and 4 deletions

View File

@@ -682,7 +682,7 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth
Scalar scale0;
Scalar scale1;
if (absD>=one)
if(absD>=one)
{
scale0 = Scalar(1) - t;
scale1 = t;
@@ -695,9 +695,8 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth
scale0 = internal::sin( ( Scalar(1) - t ) * theta) / sinTheta;
scale1 = internal::sin( ( t * theta) ) / sinTheta;
if (d<0)
scale1 = -scale1;
}
if(d<0) scale1 = -scale1;
return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
}