quaternion: remove the linear case for slerp
This commit is contained in:
parent
442dd12f8f
commit
33dd89e465
@ -118,19 +118,17 @@ cruft::slerp (quaternion<T> a, quaternion<T> b, T t)
|
|||||||
b = -b;
|
b = -b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate coefficients
|
// Calculate coefficients.
|
||||||
T p, q;
|
//
|
||||||
if (T(0.9995) > cosine) {
|
// We previously used a linear interpolation when cosine was almost 1, but
|
||||||
T omega = std::acos (cosine); // extract theta from dot product's cos theta
|
// it tended to trigger assertions for normalised quaternions; feel free to
|
||||||
T sine = std::sin (omega);
|
// 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;
|
T const p = std::sin ((1 - t) * omega) / sine;
|
||||||
q = std::sin ( t * omega) / sine;
|
T const q = std::sin ( t * omega) / sine;
|
||||||
} else {
|
|
||||||
// Very close, do linear interp (because it's faster)
|
|
||||||
p = 1 - t;
|
|
||||||
q = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
return a * p + b * q;
|
return a * p + b * q;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user