本文整理汇总了C++中Contact::getBody2方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::getBody2方法的具体用法?C++ Contact::getBody2怎么用?C++ Contact::getBody2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::getBody2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: force
/*! This is a helper function for grasp force optimization routines. Given a
set of contacts, and a matrix of contact wrenches expressed in *world*
coordinates and relative to object origin (as computed in gfo routines)
this function will convert them to object coordinate system and accumulate
them in the object's external wrench accumulator. This can serve as an
output of the gfo functions and also for rendering purposes, as the
external wrench accumulator can then be rendered.
*/
void
Grasp::accumulateAndDisplayObjectWrenches(std::list<Contact*> *contacts,
const Matrix &objectWrenches)
{
int count = 0;
std::list<Contact*>::iterator it;
for (it=contacts->begin(); it!=contacts->end(); it++, count++) {
Contact *contact = *it;
vec3 force(objectWrenches.elem(6*count+0,0),
objectWrenches.elem(6*count+1,0),
objectWrenches.elem(6*count+2,0));
vec3 torque(objectWrenches.elem(6*count+3,0),
objectWrenches.elem(6*count+4,0),
objectWrenches.elem(6*count+5,0));
if (contact->getBody2()->isDynamic()) {
DynamicBody *object = (DynamicBody*)(contact->getBody2());
//compute force and torque in body reference frame
//and scale them down for now for rendering and output purposes
force = 1.0e-6 * force * object->getTran().inverse();
//torque is also scaled by maxRadius in conversion matrix
torque = 1.0e-6 * torque * object->getTran().inverse();
//accumulate them on object
object->addForce(force);
object->addTorque(torque);
}
}
}
示例2:
/*! This is a helper function for grasp force optimization routines. Given a
set of contacts and a matrix of contact wrenches expressed in *local*
contact coordinates, it will set these wrenches in the dynamic wrench slot
of the contacts for rendering purposes.
*/
void
Grasp::displayContactWrenches(std::list<Contact*> *contacts,
const Matrix &contactWrenches)
{
int count = 0;
std::list<Contact*>::iterator it;
for (it=contacts->begin(); it!=contacts->end(); it++, count++) {
Contact *contact = *it;
if (contact->getBody2()->isDynamic()) {
//wrench is also scaled down for now for rendering and output purposes
//we also transform the wrench to the mate's coordinate system, which
//usually involves negating the x and z axes
double dynWrench[6];
for (int i=0; i<6; i++) {
dynWrench[i] = -1.0 * 1.0e-6 * contactWrenches.elem(6*count+i,0);
}
//the y axis is not negated
dynWrench[1] = -1.0 * dynWrench[1];
dynWrench[4] = -1.0 * dynWrench[4];
contact->getMate()->setDynamicContactWrench(dynWrench);
}
}
}