Right now ‘m using linear bezier to interpolate angles:
float CardAnimation::valueAt( float valueA, float valueB, float t ) const
{
return (1.0f - t) * valueA + t * valueB;
}
....
if(m_startCard.m_angle != m_endCard.m_angle)
{
m_targetCard->m_angle =
valueAt(m_startCard.m_angle, m_endCard.m_angle,m_interval);
}
This works as expected. But here is my problem. If your start angle is 0.5f and you want to go to 6.0f (in radians) then it will go clockwise from 0.5f to 6.0f when really since 6.0f – 0.5f > 3.14f it would be much smarter to go counter clockwise from 0.5f to 6.0f (resulting in moving only 0.78 radians rather than 5.5). What should I do to interpolate counter clockwise if abs(endAngle – startAngle > PI) ?
Thanks
If
abs(endAngle - startAngle) > PI, then subtract2*PIfromendAngle. Then instead of going from0.5to6.0, you go from0.5to-0.28.Edit:
This actually assumes
0 <= startAngle < endAngle <= 2*Pi.If
0 <= endAngle < startAngle <= 2*PiandstartAngle - endAngle > PI, then add2*PItoendAngle.