slerp Bug
Posted: Wed Feb 19, 2014 1:20 am
Hi,
I noticed that quaternion::slerp may calculate a not normalized quaternion (because of rounding errors and epecially in the lerp case). In my case the slerp result was sometimes up to 10° off. After I added the normalization the problem disappeared:
Please change:
to
I noticed that quaternion::slerp may calculate a not normalized quaternion (because of rounding errors and epecially in the lerp case). In my case the slerp result was sometimes up to 10° off. After I added the normalization the problem disappeared:
Please change:
Code: Select all
if (angle <= (1-threshold)) // spherical interpolation
{
const f32 theta = acosf(angle);
const f32 invsintheta = reciprocal(sinf(theta));
const f32 scale = sinf(theta * (1.0f-time)) * invsintheta;
const f32 invscale = sinf(theta * time) * invsintheta;
return (*this = (q1*scale) + (q2*invscale));
}
else // linear interploation
return lerp(q1,q2,time);
Code: Select all
if (angle <= (1-threshold)) // spherical interpolation
{
const f32 theta = acosf(angle);
const f32 invsintheta = reciprocal(sinf(theta));
const f32 scale = sinf(theta * (1.0f-time)) * invsintheta;
const f32 invscale = sinf(theta * time) * invsintheta;
*this = (q1*scale) + (q2*invscale);
}
else // linear interploation
lerp(q1,q2,time);
normalize();
return *this;