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


C++ Sphere::getTranslation方法代码示例

本文整理汇总了C++中Sphere::getTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::getTranslation方法的具体用法?C++ Sphere::getTranslation怎么用?C++ Sphere::getTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sphere的用法示例。


在下文中一共展示了Sphere::getTranslation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: matMulVec

void computeBV<AABB>(const Sphere& s, AABB& bv)
{
  Vec3f T = matMulVec(s.getRotation(), s.getLocalTranslation()) + s.getTranslation();

  bv.max_ = T + Vec3f(s.radius, s.radius, s.radius);
  bv.min_ = T + Vec3f(-s.radius, -s.radius, -s.radius);
}
开发者ID:Gitu1997,项目名称:Gazebo,代码行数:7,代码来源:geometric_shapes_utility.cpp

示例2: GraphicsCallback

//
// The Graphics Callback runs in the application "client thread" (qhStart) and sets the transformations
// for the Red Sphere and Green Line of the Cursor. Also, this callback sets the WorldToDevice matrix
// for use in the ServoLoopCallback.
//
void GraphicsCallback(void)
{
    QHGLUT* localDisplayObject = QHGLUT::searchWindow("Coulomb Field Demo");//Get a Pointer to the display object
    Cursor* localDeviceCursor = Cursor::searchCursor("devCursor");//Get a pointer to the cursor
    Cylinder* localForceArrow = Cylinder::searchCylinder("forceArrow");//get a pointer to the cylinder
    Cone* localForceArrowTip = Cone::searchCone("forceArrowTip");//get a pointer to the cylinder
	Sphere* localCursorSphere = Sphere::searchSphere("cursorSphere");//get a pointer top the Sphere

	if( localDisplayObject == NULL || localDeviceCursor == NULL || localForceArrow == NULL || localCursorSphere == NULL)
		return;

	hduMatrix CylinderTransform;//Transformation for the Cylinder. This transform makes it point toward the Model
	hduVector3Dd localCursorPosition;
	hduVector3Dd DirectionVecX;
	hduVector3Dd PointOnPlane;
	hduVector3Dd DirectionVecY;
	hduVector3Dd DirectionVecZ;

	//Compute the world to device transform
    WorldToDevice = localDisplayObject->getWorldToDeviceTransform();

	// Set transform for Red Sphere
    localCursorPosition = localDeviceCursor->getPosition();//Get the local cursor position in World Space
	
	hduVector3Dd localCursorSpherePos = localCursorSphere->getTranslation();
	localCursorSphere->setTranslation(-localCursorSpherePos);
	localCursorSphere->setTranslation(localCursorPosition);//Set the position of the Sphere the same as the cursor
    
	////////////////////////////////////////////////////////////////////////////////////////////
	//Code to calculate the transform of the green cylinder to point along the force direction
	////////////////////////////////////////////////////////////////////////////////////////////
	hduMatrix DeviceToWorld = WorldToDevice.getInverse();
	HDdouble ForceMagnitude = forceVec.magnitude();
	DeviceToWorld[3][0] = 0.0;			   
	DeviceToWorld[3][1] = 0.0;			   
	DeviceToWorld[3][2] = 0.0;
	DirectionVecX = forceVec * DeviceToWorld;
    DirectionVecX.normalize();
    PointOnPlane.set(0.0,0.0,(DirectionVecX[0]*localCursorPosition[0] + DirectionVecX[1]*localCursorPosition[1] + DirectionVecX[2]*localCursorPosition[2])/DirectionVecX[2]);
    DirectionVecY = PointOnPlane  - localCursorPosition;
    DirectionVecY.normalize();

    DirectionVecZ = -DirectionVecY.crossProduct(DirectionVecX);

    CylinderTransform[0][0] = DirectionVecZ[0]; CylinderTransform[0][1] = DirectionVecZ[1]; CylinderTransform[0][2] = DirectionVecZ[2]; CylinderTransform[0][3] = 0.0;
    CylinderTransform[1][0] = DirectionVecX[0]; CylinderTransform[1][1] = DirectionVecX[1]; CylinderTransform[1][2] = DirectionVecX[2]; CylinderTransform[1][3] = 0.0;
    CylinderTransform[2][0] = DirectionVecY[0]; CylinderTransform[2][1] = DirectionVecY[1]; CylinderTransform[2][2] = DirectionVecY[2]; CylinderTransform[2][3] = 0.0;
    CylinderTransform[3][0] = 0.0             ; CylinderTransform[3][1] = 0.0             ; CylinderTransform[3][2] = 0.0             ; CylinderTransform[3][3] = 1.0;
    CylinderTransform = CylinderTransform * hduMatrix::createTranslation(localCursorPosition[0], localCursorPosition[1], localCursorPosition[2]);
    
    localForceArrow->update(chargeRadius/4, ForceMagnitude*50, 15);
    localForceArrow->setTranslation(localCursorPosition);
    localForceArrow->setTransform(CylinderTransform);

     hduMatrix ConeTransform = CylinderTransform * hduMatrix::createTranslation(DirectionVecX[0]
     * ForceMagnitude*50,DirectionVecX[1] * ForceMagnitude*50,DirectionVecX[2] * ForceMagnitude*50 );

    localForceArrowTip->setTransform(ConeTransform);
	/////////////////////////////////////////////
}
开发者ID:danepowell,项目名称:openhaptics,代码行数:65,代码来源:main.cpp


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