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


C++ btQuaternion类代码示例

本文整理汇总了C++中btQuaternion的典型用法代码示例。如果您正苦于以下问题:C++ btQuaternion类的具体用法?C++ btQuaternion怎么用?C++ btQuaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getQuaternionDiffShortestRad

//q1 and q2 must always have values within [0,2*PI]
//strong assumption here that q1 and q2 are not displaced by much from each other
double getQuaternionDiffShortestRad(btQuaternion q1, btQuaternion q2)
{
  double th1 = q1.getAngle();
  double th2 = q2.getAngle();

  double diffval = (th1-th2);
  ///double diffval1 = (th1-th2);

  /*
  cout << "th1: " << (th1/PI*180.0) << "\n";
  cout << "th2: " << (th2/PI*180.0) << "\n";
  */

  if((diffval<(-PI))&&((th1<=(PI/2.0))&&(th1>=0.0))&&((th2>=(3*PI/2.0))&&(th2<=(2*PI))))
    {
      diffval = (diffval+2*PI);
    }
  else if((diffval>PI)&&((th2<=(PI/2.0))&&(th2>=0.0))&&((th1>=(3*PI/2.0))&&(th1<=(2*PI))))
    {
      diffval = (diffval-2*PI);
    }

  ///cout << "2.diffval: " << (diffval/PI*180.0) << "\n";

  /*
  if(diffval<(-PI))
    diffval=(diffval+2*PI);
  else if(diffval>PI)
    diffval=(diffval-2*PI);
  */

  ///cout << "diffval: " << (diffval/PI*180.0) << "\n";

  return diffval;
}
开发者ID:jwcjdenissen,项目名称:ROSMAV,代码行数:37,代码来源:quat_utils.cpp

示例2: getQuaternionDiff

//q1 and q2 must always have values within [0,2*PI]
btQuaternion getQuaternionDiff(btQuaternion q1, btQuaternion q2)
{
  double th1 = q1.getAngle();
  double th2 = q2.getAngle();

  double diffval = (th1-th2);

  /*
  if((diffval<(-PI))&&((th1<(PI/2.0))&&(th1>0.0))&&((th2>(3*PI/2.0))&&(th2<(2*PI))))
    {
      diffval = (diffval+2*PI);
    }
  else if((diffval>PI)&&((th2<(PI/2.0))&&(th2>0.0))&&((th1>(3*PI/2.0))&&(th1<(2*PI))))
    {
      diffval = (diffval-2*PI);
    }
  */

  if(diffval<0)
    diffval=(diffval+2*PI);

  btQuaternion diffq;
  diffq.setRPY(0.0,0.0,diffval);

  return diffq;
}
开发者ID:jwcjdenissen,项目名称:ROSMAV,代码行数:27,代码来源:quat_utils.cpp

示例3: copy_quat_btquat

static inline void copy_quat_btquat(float quat[4], const btQuaternion &btquat)
{
	quat[0] = btquat.getW();
	quat[1] = btquat.getX();
	quat[2] = btquat.getY();
	quat[3] = btquat.getZ();
}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:7,代码来源:rb_bullet_api.cpp

示例4: btQuaternion_to_Quaternion

void btQuaternion_to_Quaternion(JNIEnv * const &jenv, jobject &target, const btQuaternion & source)
{
	quaternion_ensurefields(jenv, target);
	jenv->SetFloatField(target, quaternion_x, source.getX());
	jenv->SetFloatField(target, quaternion_y, source.getY());
	jenv->SetFloatField(target, quaternion_z, source.getZ());
	jenv->SetFloatField(target, quaternion_w, source.getW());
}
开发者ID:0302zq,项目名称:libgdx,代码行数:8,代码来源:mathtypes.cpp

示例5:

Quaternion::Quaternion(const btQuaternion &aBulletQuaternion)
{
	x = aBulletQuaternion.getX();
	y = aBulletQuaternion.getY();
	z = aBulletQuaternion.getZ();
	w = aBulletQuaternion.getW();

}
开发者ID:jfcameron,项目名称:cpp11Engine,代码行数:8,代码来源:Quaternion.cpp

示例6: convert

// convert quaternion
math::quat convert( const btQuaternion& q )
{
	return math::quat(
		q.x(),
		q.y(),
		q.z(),
		q.w() );
}
开发者ID:bdapi,项目名称:bdapi,代码行数:9,代码来源:core.cpp

示例7: computeConeLimitInfo

// given a cone rotation in constraint space, (pre: twist must already be removed)
// this method computes its corresponding swing angle and axis.
// more interestingly, it computes the cone/swing limit (angle) for this cone "pose".
void btConeTwistConstraint::computeConeLimitInfo(const btQuaternion& qCone,
												 btScalar& swingAngle, // out
												 btVector3& vSwingAxis, // out
												 btScalar& swingLimit) // out
{
	swingAngle = qCone.getAngle();
	if (swingAngle > SIMD_EPSILON)
	{
		vSwingAxis = btVector3(qCone.x(), qCone.y(), qCone.z());
		vSwingAxis.normalize();
#if 0
        // non-zero twist?! this should never happen.
       btAssert(fabs(vSwingAxis.x()) <= SIMD_EPSILON));
#endif
        
		// Compute limit for given swing. tricky:
		// Given a swing axis, we're looking for the intersection with the bounding cone ellipse.
		// (Since we're dealing with angles, this ellipse is embedded on the surface of a sphere.)

		// For starters, compute the direction from center to surface of ellipse.
		// This is just the perpendicular (ie. rotate 2D vector by PI/2) of the swing axis.
		// (vSwingAxis is the cone rotation (in z,y); change vars and rotate to (x,y) coords.)
		btScalar xEllipse =  vSwingAxis.y();
		btScalar yEllipse = -vSwingAxis.z();

		// Now, we use the slope of the vector (using x/yEllipse) and find the length
		// of the line that intersects the ellipse:
		//  x^2   y^2
		//  --- + --- = 1, where a and b are semi-major axes 2 and 1 respectively (ie. the limits)
		//  a^2   b^2
		// Do the math and it should be clear.

		swingLimit = m_swingSpan1; // if xEllipse == 0, we have a pure vSwingAxis.z rotation: just use swingspan1
		if (fabs(xEllipse) > SIMD_EPSILON)
		{
			btScalar surfaceSlope2 = (yEllipse*yEllipse)/(xEllipse*xEllipse);
			btScalar norm = 1 / (m_swingSpan2 * m_swingSpan2);
			norm += surfaceSlope2 / (m_swingSpan1 * m_swingSpan1);
			btScalar swingLimit2 = (1 + surfaceSlope2) / norm;
			swingLimit = sqrt(swingLimit2);
		}

		// test!
		/*swingLimit = m_swingSpan2;
		if (fabs(vSwingAxis.z()) > SIMD_EPSILON)
		{
		btScalar mag_2 = m_swingSpan1*m_swingSpan1 + m_swingSpan2*m_swingSpan2;
		btScalar sinphi = m_swingSpan2 / sqrt(mag_2);
		btScalar phi = asin(sinphi);
		btScalar theta = atan2(fabs(vSwingAxis.y()),fabs(vSwingAxis.z()));
		btScalar alpha = 3.14159f - theta - phi;
		btScalar sinalpha = sin(alpha);
		swingLimit = m_swingSpan1 * sinphi/sinalpha;
		}*/
	}
开发者ID:5432935,项目名称:awayphysics-core-fp11,代码行数:58,代码来源:btConeTwistConstraint.cpp

示例8: quatToEuler

	// Taken from Irrlicht page
	btVector3 quatToEuler(const btQuaternion & quat)
	{
		btVector3 ret;
		btScalar w = quat.getW(), x = quat.getX(), y = quat.getY(), z = quat.getZ();
		float ws = w*w, xs = x*x, ys = y*y, zs = z*z;
		ret.setX(atan2f(2.0f*(y*z+x*w), -xs-ys+zs+ws));
		ret.setY(asinf(-2.0f*(x*z-y*w)));
		ret.setZ(atan2f(2.0f*(x*y+z*w), xs-ys-zs+ws));
		ret *= irr::core::RADTODEG;
		return ret;
	}
开发者ID:DeathByTape,项目名称:OldWork,代码行数:12,代码来源:PhysicsManagerImpl.cpp

示例9: transform

void BulletDynamicsBody::GetTransform( Vector3& position, Quaternion& rotation )
{
  // get updated parameters
  const btTransform& transform( GetBody()->getWorldTransform() );
  const btVector3& origin( transform.getOrigin() );
  const btQuaternion currentRotation( transform.getRotation() );
  const btVector3& axis( currentRotation.getAxis() );
  const btScalar& angle( currentRotation.getAngle() );

  position = Vector3( origin.x(), origin.y(), origin.z() );
  rotation = Quaternion( float(angle), Vector3( axis.x(), axis.y(), axis.z() ) );
}
开发者ID:Tarnyko,项目名称:dali-adaptor,代码行数:12,代码来源:bullet-dynamics-body.cpp

示例10: qtdot_ref

static inline btScalar qtdot_ref(btQuaternion& q1, btQuaternion& q2)
{
	return q1.x() * q2.x() +
		   q1.y() * q2.y() +
		   q1.z() * q2.z() +
		   q1.w() * q2.w();
}
开发者ID:bulletphysics,项目名称:bullet3,代码行数:7,代码来源:Test_qtdot.cpp

示例11: IsEqual

static bool IsEqual(const btQuaternion &pt0, const btQuaternion &pt1) {
	float delta = fabs(pt0.x() - pt1.x());
	delta += fabs(pt0.y() - pt1.y());
	delta += fabs(pt0.z() - pt1.z());
	delta += fabs(pt0.w() - pt1.w());
	return delta < 1e-8f;
}
开发者ID:Jcw87,项目名称:Gmod-vphysics,代码行数:7,代码来源:CShadowController.cpp

示例12: QuaternionToEuler

// Converts a quaternion to an euler angle
void QuaternionToEuler(const btQuaternion &tQuat, btVector3 &tEuler) {
  btScalar w = tQuat.getW();
  btScalar x = tQuat.getX();
  btScalar y = tQuat.getY();
  btScalar z = tQuat.getZ();
  float wSquared = w * w;
  float xSquared = x * x;
  float ySquared = y * y;
  float zSquared = z * z;

  tEuler.setX(atan2f(2.0f * (y * z + x * w), -xSquared - ySquared + zSquared + wSquared));
  tEuler.setY(asinf(-2.0f * (x * z - y * w)));
  tEuler.setZ(atan2f(2.0f * (x * y + z * w), xSquared - ySquared - zSquared + wSquared));
  tEuler *= SIMD_DEGS_PER_RAD;
}
开发者ID:shinta-h,项目名称:bowling,代码行数:16,代码来源:util.cpp

示例13: setX

void Vec3::setHPR(const btQuaternion& q)
{
    float W = q.getW();
    float X = q.getX();
    float Y = q.getY();
    float Z = q.getZ();
    float WSquared = W * W;
    float XSquared = X * X;
    float YSquared = Y * Y;
    float ZSquared = Z * Z;

    setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared));
    setY(asinf(-2.0f * (X * Z - Y * W)));
    setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
}   // setHPR(btQuaternion)
开发者ID:Charence,项目名称:stk-code,代码行数:15,代码来源:vec3.cpp

示例14: createTransform

geometry_msgs::TransformStamped createTransform(btQuaternion q, btVector3 v, ros::Time stamp, const std::string& frame1, const std::string& frame2)
{
  geometry_msgs::TransformStamped t;
  t.header.frame_id = frame1;
  t.child_frame_id = frame2;
  t.header.stamp = stamp;
  t.transform.translation.x = v.x();
  t.transform.translation.y = v.y();
  t.transform.translation.z = v.z();
  t.transform.rotation.x = q.x();
  t.transform.rotation.y = q.y();
  t.transform.rotation.z = q.z();
  t.transform.rotation.w = q.w();
  return t;
}
开发者ID:mkjaergaard,项目名称:geometry_experimental,代码行数:15,代码来源:test_message_filter.cpp

示例15: QuaternionToEuler

// Converts a quaternion to an euler angle
void CTBulletHelper::QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) {
	btScalar W = TQuat.getW();
	btScalar X = TQuat.getX();
	btScalar Y = TQuat.getY();
	btScalar Z = TQuat.getZ();
	float WSquared = W * W;
	float XSquared = X * X;
	float YSquared = Y * Y;
	float ZSquared = Z * Z;
	
	TEuler.setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared));
	TEuler.setY(asinf(-2.0f * (X * Z - Y * W)));
	TEuler.setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
	TEuler *= core::RADTODEG;
}
开发者ID:EEmmanuel7,项目名称:leapmotion-irrlicht,代码行数:16,代码来源:CTBulletHelper.cpp


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