spherical linear interpolation on a circle
marcus • March 3rd, 2008
how to do a slerp with angles?
that caused me some headache this morning. however, the solution is blatantly simple.
» example sketch
1 2 3 4 5 6 7 8 9 10 |
float angleSlerp(float cur, float to, float delta)
{
if(cur < -HALF_PI && to > HALF_PI) {
cur += TWO_PI;
} else if(cur > HALF_PI && to < -HALF_PI) {
cur -= TWO_PI;
}
return cur * (1-delta) + to*delta;
} |