本文整理汇总了C++中PathGeometric::subdivide方法的典型用法代码示例。如果您正苦于以下问题:C++ PathGeometric::subdivide方法的具体用法?C++ PathGeometric::subdivide怎么用?C++ PathGeometric::subdivide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathGeometric
的用法示例。
在下文中一共展示了PathGeometric::subdivide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/* Based on COMP450 2010 project of Yun Yu and Linda Hill (Rice University) */
void ompl::geometric::PathSimplifier::smoothBSpline(PathGeometric &path, unsigned int maxSteps, double minChange)
{
if (path.getStateCount() < 3)
return;
const base::SpaceInformationPtr &si = path.getSpaceInformation();
std::vector<base::State*> &states = path.getStates();
base::State *temp1 = si->allocState();
base::State *temp2 = si->allocState();
for (unsigned int s = 0 ; s < maxSteps ; ++s)
{
path.subdivide();
unsigned int i = 2, u = 0, n1 = states.size() - 1;
while (i < n1)
{
if (si->isValid(states[i - 1]))
{
si->getStateSpace()->interpolate(states[i - 1], states[i], 0.5, temp1);
si->getStateSpace()->interpolate(states[i], states[i + 1], 0.5, temp2);
si->getStateSpace()->interpolate(temp1, temp2, 0.5, temp1);
if (si->checkMotion(states[i - 1], temp1) && si->checkMotion(temp1, states[i + 1]))
{
if (si->distance(states[i], temp1) > minChange)
{
si->copyState(states[i], temp1);
++u;
}
}
}
i += 2;
}
if (u == 0)
break;
}
si->freeState(temp1);
si->freeState(temp2);
}