• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ btMatrix3x3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getLocalInertia

btVector3 btRigidBody::computeGyroscopicImpulseImplicit_World(btScalar step) const
{
	// use full newton-euler equations.  common practice to drop the wxIw term. want it for better tumbling behavior.
	// calculate using implicit euler step so it's stable.

	const btVector3 inertiaLocal = getLocalInertia();
	const btVector3 w0 = getAngularVelocity();

	btMatrix3x3 I;

	I = m_worldTransform.getBasis().scaled(inertiaLocal) *
		m_worldTransform.getBasis().transpose();

	// use newtons method to find implicit solution for new angular velocity (w')
	// f(w') = -(T*step + Iw) + Iw' + w' + w'xIw'*step = 0 
	// df/dw' = I + 1xIw'*step + w'xI*step

	btVector3 w1 = w0;

	// one step of newton's method
	{
		const btVector3 fw = evalEulerEqn(w1, w0, btVector3(0, 0, 0), step, I);
		const btMatrix3x3 dfw = evalEulerEqnDeriv(w1, w0, step, I);

		btVector3 dw;
		dw = dfw.solve33(fw);
		//const btMatrix3x3 dfw_inv = dfw.inverse();
		//dw = dfw_inv*fw;

		w1 -= dw;
	}

	btVector3 gf = (w1 - w0);
	return gf;
}
开发者ID:93i,项目名称:godot,代码行数:35,代码来源:btRigidBody.cpp


示例2: Transpose

static btMatrix3x3 Transpose(btMatrix3x3 &in)
{
	btVector3 row0 = in.getRow(0);
	btVector3 row1 = in.getRow(1);
	btVector3 row2 = in.getRow(2);
	btVector3 col0 = btAssign128(row0.x(), row1.x(), row2.x(), 0);
	btVector3 col1 = btAssign128(row0.y(), row1.y(), row2.y(), 0);
	btVector3 col2 = btAssign128(row0.z(), row1.z(), row2.z(), 0);
	return btMatrix3x3(col0, col1, col2);
}
开发者ID:bulletphysics,项目名称:bullet3,代码行数:10,代码来源:Test_3x3transpose.cpp


示例3: toMatrix3d

Matrix3d toMatrix3d(const btMatrix3x3& basis)
{
	Matrix3d rotation;
	btVector3 col0 = basis.getColumn(0);
	btVector3 col1 = basis.getColumn(1);
	btVector3 col2 = basis.getColumn(2);
	rotation.col(0) = toVector3d(col0);
	rotation.col(1) = toVector3d(col1);
	rotation.col(2) = toVector3d(col2);
	return rotation;
}
开发者ID:bo-wu,项目名称:surgical,代码行数:11,代码来源:collisionUtils.cpp


示例4:

void virtuose::Matrix3ToArray(btMatrix3x3 m, float *to) {
    to[0] = m.getRow(0).getX();
    to[1] = m.getRow(0).getZ();
    to[2] = m.getRow(0).getY();
    to[3] = m.getRow(2).getX();
    to[4] = m.getRow(2).getZ();
    to[5] = m.getRow(2).getY();
    to[6] = m.getRow(1).getZ();
    to[7] = m.getRow(1).getX();
    to[8] = m.getRow(1).getY();
}
开发者ID:Victor-Haefner,项目名称:polyvr,代码行数:11,代码来源:virtuose.cpp


示例5: setRowMajorRotationMatrix

/** Set the orientation (forward and up vectors) to the
 * provided rotation matrix
 * @param matrix matrix to use to set new orientation
 * @note this method is provided to ease performance interactions with 
 * the physics library
 */
void Position::setRowMajorRotationMatrix(const btMatrix3x3& matrix)
{
	btVector3 upV = matrix.getRow(1);
	btVector3 forwardV = matrix.getRow(2);
		
	// fill in y axis, second row
	up.set(upV.getX(), upV.getY(), upV.getZ());
							
	// fill in z axis, thrid row
	forward.set(forwardV.getX(), forwardV.getY(), forwardV.getZ());
	
}
开发者ID:venev,项目名称:3DMagic,代码行数:18,代码来源:Position.cpp


示例6: ConvertRotationToHL

void ConvertRotationToHL(const btMatrix3x3& matrix, QAngle& hl) {
	btQuaternion quat;
	matrix.getRotation(quat);
	Quaternion q(quat.getX(), -quat.getZ(), quat.getY(), quat.getW());
	RadianEuler radian(q);
	hl = radian.ToQAngle();
}
开发者ID:Jcw87,项目名称:Gmod-vphysics,代码行数:7,代码来源:convert.cpp


示例7: getRowMajorRotationMatrix

/** Get the rotation matrix into a 3x3 matrix
 * @param matrix out parameter to place matrix data into
 * @note this method is provided to ease performance interactions with 
 * the physics library
 */
void Position::getRowMajorRotationMatrix(btMatrix3x3& matrix)
{
	// get local x axis
	Vector3f xAxis;
	xAxis.crossProduct(up, forward);

	matrix.setValue (
	
		// fill in x axis, first column
		xAxis.getX(),
		xAxis.getY(),
		xAxis.getZ(),
		
		// fill in y axis, second column
		up.getX(),
		up.getY(),
		up.getZ(),
								
		// fill in z axis, thrid column
		forward.getX(),
		forward.getY(),
		forward.getZ()
	
	);
}
开发者ID:venev,项目名称:3DMagic,代码行数:30,代码来源:Position.cpp


示例8: btSetCrossMatrixMinus

void btSetCrossMatrixMinus(btMatrix3x3& res, const btVector3& a)
{
	const btScalar a_0 = a[0], a_1 = a[1], a_2 = a[2];
	res.setValue(0, +a_2, -a_1,
		-a_2, 0, +a_0,
		+a_1, -a_0, 0);
}
开发者ID:3LP,项目名称:Normalize,代码行数:7,代码来源:btRigidBody.cpp


示例9: basisToNode

QDomElement SimDomElement::basisToNode(QDomDocument &doc, const btMatrix3x3 mx)
{
	QDomElement matrix = doc.createElement( "matrix" );
	
	for(int i=0;i<3;i++)
		matrix.appendChild(vectorToNode(doc, mx.getRow(i)));
	return matrix;
}
开发者ID:jsj2008,项目名称:roverSim,代码行数:8,代码来源:SimDomElement.cpp


示例10: fabs

static int operator!= ( const btMatrix3x3 &a, const btMatrix3x3 &b )
{
    int i; 
    btVector3 av3, bv3;

    for(i=0; i<3; i++)
    {
        av3 = a.getRow(i);
        bv3 = b.getRow(i);
        
        if( fabs(av3.m_floats[0] - bv3.m_floats[0]) + 
            fabs(av3.m_floats[1] - bv3.m_floats[1]) +
            fabs(av3.m_floats[2] - bv3.m_floats[2]) > FLT_EPSILON * 4)
            return 1;
    }
    
    return 0;
}
开发者ID:Ochakko,项目名称:MameBake3D,代码行数:18,代码来源:Test_3x3setRot.cpp


示例11: btbasistoorkmtx3

ork::CMatrix3 btbasistoorkmtx3( const btMatrix3x3& mtx )
{	ork::CMatrix3 rval;
	for( int i=0; i<3; i++ )
	{	const btVector3& vec = mtx.getColumn(i);
		rval.SetElemXY(i,0,float(vec.x()));
		rval.SetElemXY(i,1,float(vec.y()));
		rval.SetElemXY(i,2,float(vec.z()));
	}
	return rval;
}
开发者ID:andemi02,项目名称:orkid,代码行数:10,代码来源:bullet.cpp


示例12: convertToBtTransform

void convertToBtTransform(const Vector3d& start_pos, const Vector3d& end_pos, btVector3& origin, btMatrix3x3& basis)
{
	Matrix3d rotation;
	rotation_from_tangent((start_pos - end_pos).normalized(), rotation);
	basis.setValue(rotation(0,0), rotation(0,1), rotation(0,2),
								 rotation(1,0), rotation(1,1), rotation(1,2),
								 rotation(2,0), rotation(2,1), rotation(2,2));
	Vector3d mid_point = (start_pos + end_pos)/2.0;
	origin.setValue(mid_point(0), mid_point(1), mid_point(2));
}
开发者ID:bo-wu,项目名称:surgical,代码行数:10,代码来源:collisionUtils.cpp


示例13: return

osg::Matrix
osgbCollision::asOsgMatrix( const btMatrix3x3& m )
{
    btScalar f[ 9 ];
    m.getOpenGLSubMatrix( f );
    return( osg::Matrix(
        f[0], f[1], f[2], 0.,
        f[3], f[4], f[5], 0.,
        f[6], f[7], f[8], 0.,
        0., 0., 0., 1. ) );
}
开发者ID:WriterOfAlicrow,项目名称:SOTE,代码行数:11,代码来源:Utils.cpp


示例14: btMatrix3_to_Matrix3

void btMatrix3_to_Matrix3(JNIEnv * const &jenv, jobject &target, const btMatrix3x3 &source)
{
	matrix3_ensurefields(jenv, target);
	
	jfloatArray valArray = (jfloatArray) jenv->GetObjectField(target, matrix3_val);
	jfloat * elements = jenv->GetFloatArrayElements(valArray, NULL);
	
	// Convert to column-major
	elements[0] = (jfloat) source.getColumn(0).getX();
	elements[1] = (jfloat) source.getColumn(0).getY();
	elements[2] = (jfloat) source.getColumn(0).getZ();
	elements[3] = (jfloat) source.getColumn(1).getX();
	elements[4] = (jfloat) source.getColumn(1).getY();
	elements[5] = (jfloat) source.getColumn(1).getZ();
	elements[6] = (jfloat) source.getColumn(2).getX();
	elements[7] = (jfloat) source.getColumn(2).getY();
	elements[8] = (jfloat) source.getColumn(2).getZ();
	
	jenv->ReleaseFloatArrayElements(valArray, elements, 0);  
	jenv->DeleteLocalRef(valArray);
}
开发者ID:0302zq,项目名称:libgdx,代码行数:21,代码来源:mathtypes.cpp


示例15: M3x3mulM1M2_ref

static btMatrix3x3 M3x3mulM1M2_ref( const btMatrix3x3 &m1, const btMatrix3x3 &m2 )
{
	return btMatrix3x3(
        m2.tdotx(m1[0]), m2.tdoty(m1[0]), m2.tdotz(m1[0]),
		m2.tdotx(m1[1]), m2.tdoty(m1[1]), m2.tdotz(m1[1]),
		m2.tdotx(m1[2]), m2.tdoty(m1[2]), m2.tdotz(m1[2]));
}
开发者ID:20-sim,项目名称:bullet3,代码行数:7,代码来源:Test_3x3mulM1M2.cpp


示例16:

static int operator!= ( const btMatrix3x3 &a, const btMatrix3x3 &b )
{
    if( a.getRow(0) != b.getRow(0) )
        return 1;
    if( a.getRow(1) != b.getRow(1) )
        return 1;
    if( a.getRow(2) != b.getRow(2) )
        return 1;
    return 0;
}
开发者ID:20-sim,项目名称:bullet3,代码行数:10,代码来源:Test_3x3timesTranspose.cpp


示例17: Matrix3_to_btMatrix3

void Matrix3_to_btMatrix3(JNIEnv * const &jenv, btMatrix3x3 &target, jobject &source)
{	  
	matrix3_ensurefields(jenv, source);
	
	jfloatArray valArray = (jfloatArray) jenv->GetObjectField(source, matrix3_val);
	jfloat * elements = jenv->GetFloatArrayElements(valArray, NULL);
	
	// Convert to column-major
	target.setValue(
	elements[0], elements[3], elements[6],
	elements[1], elements[4], elements[7],
	elements[2], elements[5], elements[8]);
	
	jenv->ReleaseFloatArrayElements(valArray, elements, JNI_ABORT);
	jenv->DeleteLocalRef(valArray);
}
开发者ID:0302zq,项目名称:libgdx,代码行数:16,代码来源:mathtypes.cpp


示例18: M3x3setRot_ref

static btMatrix3x3 M3x3setRot_ref( btMatrix3x3 &m, const btQuaternion &q )
{
    btScalar d = q.length2();
    btScalar s = btScalar(2.0) / d;

    btScalar xs = q.x() * s,   ys = q.y() * s,   zs = q.z() * s;
    
    btScalar wx = q.w() * xs,  wy = q.w() * ys,  wz = q.w() * zs;
    btScalar xx = q.x() * xs,  xy = q.x() * ys,  xz = q.x() * zs;
    btScalar yy = q.y() * ys,  yz = q.y() * zs,  zz = q.z() * zs;
    m.setValue(
        btScalar(1.0) - (yy + zz), xy - wz, xz + wy,
        xy + wz, btScalar(1.0) - (xx + zz), yz - wx,
        xz - wy, yz + wx, btScalar(1.0) - (xx + yy));

    return m;
}
开发者ID:Ochakko,项目名称:MameBake3D,代码行数:17,代码来源:Test_3x3setRot.cpp


示例19: p1_norm

unsigned int btPolarDecomposition::decompose(const btMatrix3x3& a, btMatrix3x3& u, btMatrix3x3& h) const
{
  // Use the 'u' and 'h' matrices for intermediate calculations
  u = a;
  h = a.inverse();

  for (unsigned int i = 0; i < m_maxIterations; ++i)
  {
    const btScalar h_1 = p1_norm(h);
    const btScalar h_inf = pinf_norm(h);
    const btScalar u_1 = p1_norm(u);
    const btScalar u_inf = pinf_norm(u);

    const btScalar h_norm = h_1 * h_inf;
    const btScalar u_norm = u_1 * u_inf;

    // The matrix is effectively singular so we cannot invert it
    if (btFuzzyZero(h_norm) || btFuzzyZero(u_norm))
      break;

    const btScalar gamma = btPow(h_norm / u_norm, 0.25f);
    const btScalar inv_gamma = 1.0 / gamma;

    // Determine the delta to 'u'
    const btMatrix3x3 delta = (u * (gamma - 2.0) + h.transpose() * inv_gamma) * 0.5;

    // Update the matrices
    u += delta;
    h = u.inverse();

    // Check for convergence
    if (p1_norm(delta) <= m_tolerance * u_1)
    {
      h = u.transpose() * a;
      h = (h + h.transpose()) * 0.5;
      return i;
    }
  }

  // The algorithm has failed to converge to the specified tolerance, but we
  // want to make sure that the matrices returned are in the right form.
  h = u.transpose() * a;
  h = (h + h.transpose()) * 0.5;

  return m_maxIterations;
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:46,代码来源:btPolarDecomposition.cpp


示例20:

static int operator!= ( const btMatrix3x3 &a, const btMatrix3x3 &b )
{
    if( a.getRow(0) != b.getRow(0) )
	{
		if (!fuzzyEqualSlow(a.getRow(0),b.getRow(0)))
		{
			return 1;
		}
	}
    if( a.getRow(1) != b.getRow(1) )
	{
	    if( !fuzzyEqualSlow(a.getRow(1),b.getRow(1)) )
	        return 1;
	}
    if( a.getRow(2) != b.getRow(2) )
	{
		if( !fuzzyEqualSlow(a.getRow(2),b.getRow(2)) )
		{
			return 1;
		}
	}
    return 0;
}
开发者ID:20-sim,项目名称:bullet3,代码行数:23,代码来源:Test_3x3mulM1M2.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ btMultiBodyConstraintArray类代码示例发布时间:2022-05-31
下一篇:
C++ btManifoldResult类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap