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


C++ Vector3d::getOuterProduct方法代码示例

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


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

示例1: coordinate

void RigidCoordinator::coordinate(const ParticleVector& particles, const float proceedTime)
{
	const Math::Vector3d& objectCenter = getCenter( particles );
	const Math::Vector3d& velocityAverage = getAverageVelosity( particles );

	for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
		(*iter)->setVelocity( velocityAverage );
	}

	for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
		(*iter)->addCenter( -1.0 * objectCenter );
	}

	//std::cout << getCenter( particles ).x << std::endl;
	//std::cout << getCenter( particles ).y << std::endl;
	//std::cout << getCenter( particles ).z << std::endl;

	//assert( getCenter( particles ) == Math::Vector3d( 0.0, 0.0, 0.0 ) );

	Math::Vector3d inertiaMoment( 0.0, 0.0, 0.0 );
	Math::Vector3d torque( 0.0, 0.0, 0.0 );
	
	for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
		Particle* particle = (*iter);
		const Math::Vector3d& center = particle->getCenter();
		
		Math::Vector3d particleMoment( pow( center.getY(), 2) + pow( center.getZ(), 2),
			pow( center.getZ(), 2 ) + pow( center.getX(), 2),
			pow( center.getX(), 2 ) + pow( center.getY(), 2) );
		inertiaMoment += (particleMoment) * particle->getMass();

		const Math::Vector3d diffVector( Math::Vector3d( 0.0, 0.0, 0.0), particle->getCenter() );
		const Math::Vector3d& particleTorque = diffVector.getOuterProduct( particle->getForce() * particle->getVolume() );
		torque += particleTorque;
	}

	getAngleVelosity( inertiaMoment , torque, proceedTime );

	if( Math::Tolerances::isEqualStrictly( angleVelosity.getLength() ) ) {
		for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
			(*iter)->addCenter( objectCenter );
		}
		convertToFluidForce( particles);
		return;
	}
	const float rotateAngle = angleVelosity.getLength() * proceedTime;
	if( rotateAngle < 1.0e-5 ) {
		for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
			(*iter)->addCenter( objectCenter );
		}
		convertToFluidForce( particles);
		return;
	}

	Math::Quaternion quaternion( angleVelosity.getNormalized(), rotateAngle );
	const Math::Matrix3d& rotateMatrix = quaternion.getMatrix();
/*	for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
		(*iter)->variable.center.rotate( rotateMatrix );
	}

	for( ParticleVector::const_iterator iter = particles.begin(); iter != particles.end(); ++iter ) {
		(*iter)->variable.center += objectCenter;
	} */
	convertToFluidForce( particles );
}
开发者ID:Energy0124,项目名称:cryphous,代码行数:65,代码来源:RigidCoordinator.cpp


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