本文整理汇总了C++中ControlPoint::interpolate方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlPoint::interpolate方法的具体用法?C++ ControlPoint::interpolate怎么用?C++ ControlPoint::interpolate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlPoint
的用法示例。
在下文中一共展示了ControlPoint::interpolate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInterpolatedControlPoint
bool AnimationPath::getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const
{
if (_timeControlPointMap.empty()) return false;
switch(_loopMode)
{
case(SWING):
{
double modulated_time = (time - getFirstTime())/(getPeriod()*2.0);
double fraction_part = modulated_time - floor(modulated_time);
if (fraction_part>0.5) fraction_part = 1.0-fraction_part;
time = getFirstTime()+(fraction_part*2.0) * getPeriod();
break;
}
case(LOOP):
{
double modulated_time = (time - getFirstTime())/getPeriod();
double fraction_part = modulated_time - floor(modulated_time);
time = getFirstTime()+fraction_part * getPeriod();
break;
}
case(NO_LOOPING):
// no need to modulate the time.
break;
}
TimeControlPointMap::const_iterator second = _timeControlPointMap.lower_bound(time);
if (second==_timeControlPointMap.begin())
{
controlPoint = second->second;
}
else if (second!=_timeControlPointMap.end())
{
TimeControlPointMap::const_iterator first = second;
--first;
// we have both a lower bound and the next item.
// delta_time = second.time - first.time
double delta_time = second->first - first->first;
if (delta_time==0.0)
controlPoint = first->second;
else
{
controlPoint.interpolate((time - first->first)/delta_time,
first->second,
second->second);
}
}
else // (second==_timeControlPointMap.end())
{
controlPoint = _timeControlPointMap.rbegin()->second;
}
return true;
}