title: Move a point from A to B in 2D space
body: <p>I'm writing a small space game, but I'm stuck at moving my ship in a nice way from point A to point B in open 2D space.</p>
  
  <p>My first problem with the solution below is that my ship never comes to a complete stop. It gets close, but it keeps vibrating around point B forever.
  My second problem is that if I snap it to B when it gets close, the sudden stop looks fake and bad as well.</p>
  
  <p>I think I would like the ship to speed up, travel and slow down just before it stops exactly at point B without any bouncing, but I have no idea how to accomplish that in a good way. Also, if there is some "right" way to move a ship from point A to point B in 2D space that I haven't considered, other ideas are very welcome.</p>
  
  <pre><code>if(player.x &lt; destination.x) {
      if(player.velocityX &lt; player.speed) {
          player.velocityX += 10;         
      }
  } else {
      if(player.velocityX &gt; -player.speed) {
          player.velocityX -= 10;
      }
  }
  
  if(player.y &lt; destination.y) {
      if(player.velocityY &lt; player.speed) {
          player.velocityY += 10;         
      }
  } else {
      if(player.velocityY &gt; -player.speed) {
          player.velocityY -= 10;
      }
  }
  
  // Friction.
  player.velocityX *= 0.9;
  player.velocityY *= 0.9;
  
  player.x += player.velocityX;
  player.y += player.velocityY;
  </code></pre>
  
  <p>Note that this solution doesn't use trigonometric functions for a straight path from A to B yet, but that shouldn't affect the question I think.</p>
  
  <p>Any help would be very appreciated!</p>