title: C++ 3D Angular Velocity
body: <p>I'm having a little trouble with my game. I'm trying to get a ball to move from one point to another. Heres my code:</p>
  
  <pre><code>void Create()
  {
      // Initialise points
      StartPosition - { 20, 0, 5 };
      EndPosition = { -20, 0, 5 };
  }
  
  void Calculate()
  {
      // Calculate difference in axis
      float X = EndPosition.x - StartPosition.x;
      float Z = EndPosition.z - StartPosition.z;
  
      // Calculate y-axis rotation
      float Rotation = atan2(Z, X) * (180 / M_PI); 
  
      // Calculate velocity
      Velocity.x = cos( Rotation ) * 5;
      Velocity.y = 0.0f;
      Velocity.z = sin( Rotation ) * 5;
  }
  </code></pre>
  
  <p>I know that the rotation is being calculated correctly (180), however it calculates the velocities wrong:</p>
  
  <pre><code>X: -2.9923
  Y: 0
  Z: -4.00576
  </code></pre>
  
  <p>Now seeing as both the start and end points are Z = 5, I would think the Z axis velocity should be 0?</p>
  
  <p>Have I completely missed something?</p>