mirror of https://github.com/AxioDL/zeus.git
CQuaternion: Remove unnecessary local in slerp()
We can turn this assignment into a direct return expression, tidying up the code a little bit.
This commit is contained in:
parent
949dbff9b8
commit
9409825ace
|
@ -148,16 +148,16 @@ CQuaternion CQuaternion::nlerp(const CQuaternion& a, const CQuaternion& b, doubl
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuaternion CQuaternion::slerp(const CQuaternion& a, const CQuaternion& b, double t) {
|
CQuaternion CQuaternion::slerp(const CQuaternion& a, const CQuaternion& b, double t) {
|
||||||
if (t <= 0.0f)
|
if (t <= 0.0f) {
|
||||||
return a;
|
return a;
|
||||||
if (t >= 1.0f)
|
}
|
||||||
|
|
||||||
|
if (t >= 1.0f) {
|
||||||
return b;
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
CQuaternion ret;
|
const float mag = std::sqrt(a.dot(a) * b.dot(b));
|
||||||
|
const float prod = a.dot(b) / mag;
|
||||||
float mag = std::sqrt(a.dot(a) * b.dot(b));
|
|
||||||
|
|
||||||
float prod = a.dot(b) / mag;
|
|
||||||
|
|
||||||
if (std::fabs(prod) < 1.0f) {
|
if (std::fabs(prod) < 1.0f) {
|
||||||
const double sign = (prod < 0.0f) ? -1.0f : 1.0f;
|
const double sign = (prod < 0.0f) ? -1.0f : 1.0f;
|
||||||
|
@ -167,10 +167,9 @@ CQuaternion CQuaternion::slerp(const CQuaternion& a, const CQuaternion& b, doubl
|
||||||
const double d = 1.0 / std::sin(theta);
|
const double d = 1.0 / std::sin(theta);
|
||||||
const double s0 = std::sin((1.0 - t) * theta);
|
const double s0 = std::sin((1.0 - t) * theta);
|
||||||
|
|
||||||
ret = (a * s0 + b * s1) * d;
|
return (a * s0 + b * s1) * d;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue