本文整理汇总了C++中TwoDScene::getHalfplane方法的典型用法代码示例。如果您正苦于以下问题:C++ TwoDScene::getHalfplane方法的具体用法?C++ TwoDScene::getHalfplane怎么用?C++ TwoDScene::getHalfplane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwoDScene
的用法示例。
在下文中一共展示了TwoDScene::getHalfplane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detectParticleHalfplane
// Detects whether a particle and a half-plane are overlapping (including the
// radius of the particle) and are approaching.
// If the two objects overlap and are approaching, returns true and sets the
// vector n to be the shortest vector between the particle and the half-plane.
// Inputs:
// scene: The scene data structure.
// vidx: The index of the particle.
// pidx: The index of the halfplane. The vectors (px, py) and (nx, ny) can
// be retrieved by calling scene.getHalfplane(pidx).
// Outputs:
// n: The shortest vector between the particle and the half-plane.
// Returns true if the two objects overlap and are approaching.
bool SimpleCollisionHandler::detectParticleHalfplane(TwoDScene &scene, int vidx, int pidx, VectorXs &n)
{
VectorXs x1 = scene.getX().segment<2>(2*vidx);
VectorXs px = scene.getHalfplane(pidx).first;
VectorXs pn = scene.getHalfplane(pidx).second;
pn.normalize();
n = (px-x1).dot(pn)*pn;
if(n.norm() < scene.getRadius(vidx))
{
double relvel = scene.getV().segment<2>(2*vidx).dot(n);
if(relvel > 0)
return true;
}
return false;
}