INNER CODE UNIT · C++
dot
camila314/gdp · Slerp2D.cpp:10
float dot = (cosStart * cosEnd) + (sinStart * sinEnd);
float weightStart, weightEnd;
if (dot < 0.f) {
dot = -dot;
sinEnd = -sinEnd;
cosEnd = -cosEnd;
}
if (1.f - dot > 0.0001f) {
float theta = acosf(dot);
float sinTheta = sinf(theta);
weightStart = sinf(theta * (1.f - t)) / sinTheta;
weightEnd = sinf(theta * t) / sinTheta;
} else {
weightStart = 1.f - t;
weightEnd = t;
}