title: Getting the velocity vector from position vectors
body: <p>I looked at a bunch of similar questions, and I cannot seem to find one that particularly answers my question. I am coding a simple 3d game, and I am trying to allow the player to pick up and move entities around my map. I essentially want to get a velocity vector that will "push" the physics object a distance from the player's eyes, wherever they are looking. Here's <a href="http://assets.overclock.net.s3.amazonaws.com/3/37/37399354_vbattach170986.jpeg" rel="nofollow">an example</a> of this being done in another game (the player is holding a chair entity in front of his eyes).</p>
  
  <p>To do this, I find out the player's eye angles, then get the forward vector from the angles, then calculate the velocity of the object. Here is my <strong>working</strong> code:</p>
  
  <pre><code>void Player::PickupOtherEntity( Entity&amp; HoldingEntity )
  {
      QAngle eyeAngles = this-&gt;GetPlayerEyeAngles();
      Vector3 vecPos = this-&gt;GetEyePosition();
      Vector3 vecDir = eyeAngles.Forward();
  
      Vector3 holdingEntPos = HoldingEntity.GetLocation();
  
      // update object by holding it a distance away
      vecPos.x += vecDir.x * DISTANCE_TO_HOLD;
      vecPos.y += vecDir.y * DISTANCE_TO_HOLD;
      vecPos.z += vecDir.z * DISTANCE_TO_HOLD;
  
      Vector3 vecVel = vecPos - holdingEntPos;
      vecVel = vecVel.Scale(OBJECT_SPEED_TO_MOVE);
  
      // set the entity's velocity as to "push" it to be in front of the player's eyes
      // at a distance of DISTANCE_TO_HOLD away
      HoldingEntity.SetVelocity(vecVel);
  }
  </code></pre>
  
  <p>All that is great, but I want to convert my math so that I can apply an impulse. Instead of setting a completely new velocity to the object, I want to "add" some velocity to its existing velocity. So supposing I have its current velocity, what kind of math do I need to "add" velocity? This is essentially a game physics question. Thank you!</p>