示例#1
0
文件: D5.c 项目: Dredeg/MIPT-CS
int main(){
	float a;
	scanf("%f", &a);
	printf("%f", accelerate(a));
	return 0;
}
示例#2
0
void Physics::gravitate(Body &b) const {
    accelerate(b, mGravity);
}
示例#3
0
void velocityNav::updateInteraction()
{
   // If we are not supposed to be active, then don't run
   if ( ! this->isActive() )
   {
      return;
   }

   mAcceleratingForward = checkForAction(mActionButtons, mAccelForwardCombo);
   mBraking = checkForAction(mActionButtons, mBrakeCombo);
   mStopping = checkForAction(mActionButtons, mStopCombo);
   mResetting = checkForAction(mActionButtons, mResetCombo);
   mRotating = checkForAction(mActionButtons, mRotateCombo);

   // Braking
   if ( mBraking )
   {
      mDamping = 0.85f;
   }
   else
   {
      mDamping = 1.0f;
   }

   // Stopping -- NOTE: This must go after braking
   if ( mStopping )
   {
      setDamping(0.0f);
   }

   // Accelerate Forward
   // TODO: add other directions to accelerate. (since it's hard coded to
   // forward (0,0,-x) here...)
   if ( mAcceleratingForward )
   {
      accelerate(gmtl::Vec3f(0.0f, 0.0f, -mAcceleration));
   }

   // Resetting
   if ( mResetting )
   {
      this->reset();
   }

   // Rotating
   gmtl::Matrix44f rot_mat = mNavWand->getData();
   //std::cout<<"1: "<<rot_mat<<"\n"<<std::flush;
   gmtl::setTrans(rot_mat, gmtl::Vec3f(0.0f, 0.0f, 0.0f));
   //std::cout<<"2: "<<rot_mat<<"\n=======\n\n"<<std::flush;

   setRotationalAcceleration(rot_mat);

   // Output visual feedback
   if ( mAcceleratingForward )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrCYAN,"velNav: Accelerating Forward")
         << "(Accel = " << mAcceleration << ")" << std::endl
         << vprDEBUG_FLUSH;
   }

   if ( mBraking )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrCYAN,"velNav: Braking") << std::endl
         << vprDEBUG_FLUSH;
   }

   if ( mStopping )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrCYAN,"velNav: Stopping") << std::endl
         << vprDEBUG_FLUSH;
   }

   if ( mResetting )
   {
      gmtl::Vec3f hpos;
      gmtl::setTrans(hpos, mHomePos);
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrCYAN,"velNav: Resetting") << " to "
         << hpos << std::endl << vprDEBUG_FLUSH;
   }

   if ( mRotating )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrCYAN,"velNav: Rotating") << std::endl
         << vprDEBUG_FLUSH;
   }
}