title: Java 2D: Moving a point P a certain distance closer to another point?
body: <p>What is the best way to go about moving a Point2D.Double x distance closer to another Point2D.Double? </p>
  
  <p>Edit: Tried to edit, but so went down for maintenance. No this is not homework</p>
  
  <p>I need to move a plane (A) towards the end of a runway (C) and point it in the correct direction (angle a).</p>
  
  <p><a href="http://img246.imageshack.us/img246/9707/planec.png" rel="noreferrer">alt text http://img246.imageshack.us/img246/9707/planec.png</a></p>
  
  <p>Here is what I have so far, but it seems messy, what is the usual way to go about doing something like this?</p>
  
  <pre><code>    //coordinate = plane coordinate (Point2D.Double)
      //Distance = max distance the plane can travel in this frame
  
      Triangle triangle = new Triangle(coordinate, new Coordinate(coordinate.x, landingCoordinate.y),  landingCoordinate);
  
      double angle = 0;
  
      //Above to the left
      if (coordinate.x &lt;= landingCoordinate.x &amp;&amp; coordinate.y &lt;= landingCoordinate.y)
      {
          angle = triangle.getAngleC();
          coordinate.rotate(angle, distance);
          angle = (Math.PI-angle);
      }
      //Above to the right
      else if (coordinate.x &gt;= landingCoordinate.x &amp;&amp; coordinate.y &lt;= landingCoordinate.y)
      {
          angle = triangle.getAngleC();
          coordinate.rotate(Math.PI-angle, distance);
          angle = (Math.PI*1.5-angle);
      }
  
      plane.setAngle(angle);
  </code></pre>
  
  <p>The triangle class can be found at <a href="http://pastebin.com/RtCB2kSZ" rel="noreferrer">http://pastebin.com/RtCB2kSZ</a></p>
  
  <p>Bearing in mind the plane can be in in any position around the runway point</p>