当前位置: 首页>>代码示例>>C++>>正文


C++ Contact::getBody2方法代码示例

本文整理汇总了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);
		}
	}
}
开发者ID:BerkeleyAutomation,项目名称:google_goggles_project,代码行数:35,代码来源:grasp.cpp

示例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);
		}
	}
}
开发者ID:BerkeleyAutomation,项目名称:google_goggles_project,代码行数:28,代码来源:grasp.cpp


注:本文中的Contact::getBody2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。