It is currently Mon Dec 18, 2017 12:03 am

All times are UTC - 5 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Physics VMK 5 - Forces
PostPosted: Sat Feb 23, 2008 5:45 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
In VMK 5A I discuss Newton's three laws of motion.

VMK 5B shows you how to calculate Gravitational, Spring and Damping forces.

VMK 5C shows you how to calculate Friction, Buoyancy and Drag forces.

In VMK 5D I show you how to derive the equations of motion for the cannon ball when wind is blowing in our scene.

I take the equations derived in VMK 5D and implement them into C++ in VMK 5E and VMK 5F.

The equations of motion including Gravity, Wind and Drag Forces are developed in VMK 5G. Then in VMK 5H I take these equations and implement them in C++.


Offline
 Profile  
 
 Post subject: Re: Physics VMK 5 - Forces
PostPosted: Fri Feb 03, 2012 7:18 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 450
Add this code to your HUD() function and check out the results :)

   // Show Physic Stats
   // Trajectories For X,Z Plane Are Displayed In Degrees N, NE, NW For Cannon And
   // N,E,S,W,NE,NW,SE,SW For The Wind
   // Trajectory For Cannon Pitch Is Displayed As Degees Above Horizontal(Ground)
   float fCannonXZ, fCannonY, fWindXZ;
   fCannonXZ = _pNT_CannonDirection->_fRotateAngle;
   fCannonY  = _pNT_CannonPitch1->_fRotateAngle;
   fWindXZ   = _pNT_Chicken->_fRotateAngle;

   char cCannon[3], cWind[3];
   cCannon[2] = NULL;
   cWind[2] = NULL;
   if ( fCannonXZ == 180.0f ) { cCannon[0] = 'N'; cCannon[1] = NULL; }
   if ( fCannonXZ < 180.0f  ) { cCannon[0] = 'N'; cCannon[1] = 'E';  }
   if ( fCannonXZ > 180.0f  ) { cCannon[0] = 'N'; cCannon[1] = 'W';  }

   if ( fWindXZ == 360.0f ) {
      fWindXZ = 0.0f;
   }

   if ( fWindXZ == 0.0f   ) { cWind[0] = 'S'; cWind[1] = NULL; }
   if ( fWindXZ == 90.0f  ) { cWind[0] = 'E'; cWind[1] = NULL; }
   if ( fWindXZ == 180.0f ) { cWind[0] = 'N'; cWind[1] = NULL; }
   if ( fWindXZ == 270.0f ) { cWind[0] = 'W'; cWind[1] = NULL; }
   if ( (fWindXZ > 0.0f) && (fWindXZ < 90.0f) ) {
      cWind[0] = 'S'; cWind[1] = 'E';
   }
   if ( (fWindXZ > 90.0f) && (fWindXZ < 180.0f) ) {
      cWind[0] = 'N'; cWind[1] = 'E';
   }
   if ( (fWindXZ > 180.0f) && (fWindXZ < 270.0f) ) {
      cWind[0] = 'N'; cWind[1] = 'W';
   }
   if ( (fWindXZ > 270.0f) && (fWindXZ <= 359.0f) ) {
      cWind[0] = 'S'; cWind[1] = 'W';
   }

   PrintText( 1, 10, (unsigned int)_consoleParam.fYMin + 4 + 64, ColorOGL( 0, 0, 0 ), 1.0f, "TRAJECTORIES" );
   PrintText( 1, 10, (unsigned int)_consoleParam.fYMin + 4 + 48, ColorOGL( 0, 0, 0 ), 1.0f, "[Cannon] XZ-Angle: %1.1f %s, Y-Angle: %1.1f", fCannonXZ, &cCannon[0], fCannonY );
   PrintText( 1, 10, (unsigned int)_consoleParam.fYMin + 4 + 32, ColorOGL( 0, 0, 0 ), 1.0f, "[Wind]    XZ-Angle: %1.1f %s", fWindXZ, &cWind[0] );


This works with the cannon and wind's trajectory angles mapped into Compass Coordinates.

Add this code inside of UpdateCannon() function after the ability to change the objects mass to reset all values.
   // Reset All Values
   if ( _pUserSettings->_bKeys[VK_NUMPAD0] ) {
      _pUserSettings->_bKeys[VK_NUMPAD0] = false;

      _fWindSpeed = 10.f;
      _cannonBall._fMass = 1.0f;
      _pNT_CannonDirection->_fRotateAngle = 180.0f;
      _pNT_CannonPitch1->_fRotateAngle = 0.0f;
      _pNT_Chicken->_fRotateAngle = 90.0f;
   }


Enjoy!


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron