本文整理汇总了C++中Simplex::RemovePoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Simplex::RemovePoint方法的具体用法?C++ Simplex::RemovePoint怎么用?C++ Simplex::RemovePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simplex
的用法示例。
在下文中一共展示了Simplex::RemovePoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SolveTetrahedronSimplex
bool CollisionSolver::SolveTetrahedronSimplex(Simplex& simplex, D3DXVECTOR3& direction)
{
const D3DXVECTOR3& pointA = simplex.GetPoint(3);
const D3DXVECTOR3& pointB = simplex.GetPoint(0);
const D3DXVECTOR3& pointC = simplex.GetPoint(1);
const D3DXVECTOR3& pointD = simplex.GetPoint(2);
const D3DXVECTOR3 AB = pointB - pointA;
const D3DXVECTOR3 AC = pointC - pointA;
const D3DXVECTOR3 AD = pointD - pointA;
const D3DXVECTOR3 AO = -pointA;
// Check if within the three surrounding planes
// The forth plane has been previously tested with the plane simplex
// All normals will point to the center of the tetrahedron
D3DXVECTOR3 CBnormal, BDnormal, DCnormal;
D3DXVec3Cross(&CBnormal, &AC, &AB);
D3DXVec3Cross(&BDnormal, &AB, &AD);
D3DXVec3Cross(&DCnormal, &AD, &AC);
const float CBdistance = D3DXVec3Dot(&CBnormal, &AO);
const float BDdistance = D3DXVec3Dot(&BDnormal, &AO);
const float DCdistance = D3DXVec3Dot(&DCnormal, &AO);
bool originInsideSimplex = true;
if(CBdistance < 0.0f)
{
// Origin is outside of the CB plane
// D is furthest point, remove it and search towards the origin
simplex.RemovePoint(pointD);
direction = -CBnormal;
originInsideSimplex = false;
}
else if(BDdistance < 0.0f)
{
// Origin is outside of the BD plane
// C is furthest point, remove it and search towards the origin
simplex.RemovePoint(pointC);
direction = -BDnormal;
originInsideSimplex = false;
}
else if(DCdistance < 0.0f)
{
// Origin is outside of the DC plane
// C is furthest point, remove it and search towards the origin
simplex.RemovePoint(pointB);
direction = -DCnormal;
originInsideSimplex = false;
}
return originInsideSimplex;
}