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


C++ IVP_U_Float_Point::dot_product方法代码示例

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


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

示例1: GetEnergy

// convert square velocity magnitude from IVP to HL
float CPhysicsObject::GetEnergy()
{
	IVP_Core *pCore = m_pObject->get_core();
	IVP_FLOAT energy = 0.0f;
	IVP_U_Float_Point tmp;

	energy = 0.5f * pCore->get_mass() * pCore->speed.dot_product(&pCore->speed); // 1/2mvv
	tmp.set_pairwise_mult(&pCore->rot_speed, pCore->get_rot_inertia()); // wI
	energy += 0.5f * tmp.dot_product(&pCore->rot_speed); // 1/2mvv + 1/2wIw
	
	return ConvertEnergyToHL( energy );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:13,代码来源:physics_object.cpp

示例2: MaxSpeed

void CShadowController::MaxSpeed( const Vector &velocity, const AngularImpulse &angularVelocity )
{
	IVP_Core *pCore = m_pObject->GetObject()->get_core();

	// limit additional velocity to that which is not amplifying the current velocity
	IVP_U_Float_Point ivpVel;
	ConvertPositionToIVP( velocity, ivpVel );
	IVP_U_Float_Point available = ivpVel;

	m_currentSpeed = ivpVel;
	
	// normalize and save length
	float length = ivpVel.real_length_plus_normize();

	float dot = ivpVel.dot_product( &pCore->speed );
	if ( dot > 0 )
	{
		ivpVel.mult( dot * length );
		available.subtract( &ivpVel );
	}
	IVP_Float_PointAbs( m_shadow.maxSpeed, available );

	// same for angular, project on to current and remove redundant (amplifying) input
	IVP_U_Float_Point ivpAng;
	ConvertAngularImpulseToIVP( angularVelocity, ivpAng );
	IVP_U_Float_Point availableAng = ivpAng;
	float lengthAng = ivpAng.real_length_plus_normize();

	float dotAng = ivpAng.dot_product( &pCore->rot_speed );
	if ( dotAng > 0 )
	{
		ivpAng.mult( dotAng * lengthAng );
		availableAng.subtract( &ivpAng );
	}

	IVP_Float_PointAbs( m_shadow.maxAngular, availableAng );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:37,代码来源:physics_shadow.cpp

示例3: DoSimulationPontoonsGround

//-----------------------------------------------------------------------------
// Purpose: Handle pontoons on ground.
//-----------------------------------------------------------------------------
void IVP_Controller_Raycast_Airboat::DoSimulationPontoonsGround( IVP_Raycast_Airboat_Wheel *pPontoonPoint, 
																 IVP_Raycast_Airboat_Pontoon_Temp *pTempPontoon,
													             IVP_Raycast_Airboat_Impact *pImpact, IVP_Event_Sim *pEventSim,
													             IVP_Core *pAirboatCore )
{
	// Check to see if we hit anything, otherwise the no force on this point.
	IVP_DOUBLE flDiff = pPontoonPoint->raycast_dist - pPontoonPoint->raycast_length;
	if ( flDiff >= 0 ) 
		return;
	
	IVP_FLOAT flSpringConstant, flSpringRelax, flSpringCompress;
	flSpringConstant = pPontoonPoint->spring_constant;
	flSpringRelax = pPontoonPoint->spring_damp_relax;
	flSpringCompress = pPontoonPoint->spring_damp_compress;
	
	IVP_DOUBLE flForce = -flDiff * flSpringConstant;
	IVP_FLOAT flInvNormalDotDir = pTempPontoon->inv_normal_dot_dir;
	if ( flInvNormalDotDir < 0.0f ) { flInvNormalDotDir = 0.0f; }
	if ( flInvNormalDotDir > 3.0f ) { flInvNormalDotDir = 3.0f; }
	flForce *= flInvNormalDotDir;
	
	IVP_U_Float_Point vecSpeedDelta; 
	vecSpeedDelta.subtract( &pTempPontoon->projected_surface_speed_wheel_ws, &pTempPontoon->surface_speed_wheel_ws );
	
	IVP_DOUBLE flSpeed = vecSpeedDelta.dot_product( &pTempPontoon->raycast_dir_ws );
	if ( flSpeed > 0 )
	{
		flForce -= flSpringRelax * flSpeed;
	}
	else
	{
		flForce -= flSpringCompress * flSpeed;
	}
	
	if ( flForce < 0 )
	{
		flForce = 0.0f;
	}
	
	IVP_DOUBLE flImpulse = flForce * pEventSim->delta_time;		
	
	IVP_U_Float_Point vecImpulseWS; 
	vecImpulseWS.set_multiple( &pTempPontoon->ground_normal_ws, flImpulse );
	pAirboatCore->push_core_ws( &pTempPontoon->ground_hit_ws, &vecImpulseWS );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:48,代码来源:ivp_controller_airboat.cpp


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