quaternion: remove the linear case for slerp

This commit is contained in:
Danny Robson 2019-10-04 17:01:17 +10:00
parent 442dd12f8f
commit 33dd89e465

View File

@ -118,19 +118,17 @@ cruft::slerp (quaternion<T> a, quaternion<T> b, T t)
b = -b;
}
// Calculate coefficients
T p, q;
if (T(0.9995) > cosine) {
T omega = std::acos (cosine); // extract theta from dot product's cos theta
T sine = std::sin (omega);
// Calculate coefficients.
//
// We previously used a linear interpolation when cosine was almost 1, but
// it tended to trigger assertions for normalised quaternions; feel free to
// change this back, but at this point performance isn't the most prominent
// concern.
T const omega = std::acos (cosine); // extract theta from dot product's cos theta
T const sine = std::sin (omega);
p = std::sin ((1 - t) * omega) / sine;
q = std::sin ( t * omega) / sine;
} else {
// Very close, do linear interp (because it's faster)
p = 1 - t;
q = t;
}
T const p = std::sin ((1 - t) * omega) / sine;
T const q = std::sin ( t * omega) / sine;
return a * p + b * q;
}