本文整理汇总了C++中PointSet::angularMotionDisc方法的典型用法代码示例。如果您正苦于以下问题:C++ PointSet::angularMotionDisc方法的具体用法?C++ PointSet::angularMotionDisc怎么用?C++ PointSet::angularMotionDisc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointSet
的用法示例。
在下文中一共展示了PointSet::angularMotionDisc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeOfImpact
void GjkContactSolver::timeOfImpact(const PointSet & A, const PointSet & B, ContinuousCollisionContext * result)
{
result->hasContact = 0;
result->penetrateDepth = 0.f;
result->TOI = 0.f;
// std::cout<<"\nb test p"<<result->positionB;
// std::cout<<"\nb test v"<<result->linearVelocityB * 60.f;
// std::cout<<"\nb test w"<<result->angularVelocityB * 60.f;
const Vector3F relativeLinearVelocity = result->linearVelocityB - result->linearVelocityA;
// std::cout<<" velocityA "<<result->linearVelocityA.str();
// std::cout<<" velocityB "<<result->linearVelocityB.str();
// std::cout<<" relativeLinearVelocity "<<relativeLinearVelocity.str();
const float angularMotionSize = result->angularVelocityA.length() * A.angularMotionDisc()
+ result->angularVelocityB.length() * B.angularMotionDisc();
// no relative motion
if(relativeLinearVelocity.length() + angularMotionSize < TINY_VALUE)
return;
#ifdef DBG_DRAW
Vector3F lineB = result->positionB;
Vector3F lineE = lineB + relativeLinearVelocity;
glColor3f(0.f, .1f, .6f);
m_dbgDrawer->arrow(lineB, lineE);
lineB = result->positionA;
lineE = lineB - relativeLinearVelocity;
glColor3f(0.f, .1f, .6f);
m_dbgDrawer->arrow(lineB, lineE);
#endif
ClosestTestContext separateIo;
separateIo.needContributes = 1;
separateIo.margin = 0.05f;
Vector3F separateN;
float distance, closeInSpeed;
float lastDistance = 0.f;
float dDistanceaLamda;
const Vector3F position0A = result->positionA;
const Vector3F position0B = result->positionB;
const Quaternion orientation0A = result->orientationA;
const Quaternion orientation0B = result->orientationB;
float lamda = 0.f;
float limitDeltaLamda, deltaLamda = 1.f;
float lastLamda = 0.f;
int k = 0;
for(; k < 32; k++) {
separateIo.transformA.setTranslation(position0A.progress(result->linearVelocityA, lamda));
Quaternion ra = orientation0A.progress(result->angularVelocityA, lamda);
ra.normalize();
separateIo.transformA.setRotation(ra);
separateIo.transformB.setTranslation(position0B.progress(result->linearVelocityB, lamda));
Quaternion rb = orientation0B.progress(result->angularVelocityB, lamda);
rb.normalize();
separateIo.transformB.setRotation(rb);
// std::cout<<"\nk "<<k;
// std::cout<<"\nb at p"<<separateIo.transformB.getTranslation();
// std::cout<<"\nmat"<<separateIo.transformB.str();
separateIo.referencePoint.setZero();
separateIo.distance = 1e9;
separateDistance(A, B, &separateIo);
if(separateIo.hasResult) {
if(k<1) {
std::cout<<" contact at t0 try zero margin\n";
separateIo.margin = 0.f;
separateIo.distance = 1e9;
separateDistance(A, B, &separateIo);
if(separateIo.hasResult) {
std::cout<<" penetrated\n";
result->hasContact = 0;
return;
}
result->contactPointB = separateIo.contactPointB;
distance = separateIo.separateAxis.length();
result->penetrateDepth = 0.1 - distance;
separateN = separateIo.separateAxis / distance;
#ifdef DBG_GJK_DRAW
lineB = separateIo.transformB.transform(separateIo.contactPointB);
lineE = lineB + separateN;
glColor3f(1.f, 0.f, 0.f);
m_dbgDrawer->arrow(lineB, lineE);
#endif
break;
} else {
// std::cout<<" contact at "<<lamda;;
lamda = lastLamda;
break;
}
}
//.........这里部分代码省略.........