title: Calculate second point of line by length and slope
body: <p>I'm kinda stuck by this problem, where i try to change the length of a drawn line by moving the second point and keeping its slope. </p>
  
  <p>Note: all this is drawn on a canvas in wpf.</p>
  
  <p>I calculated the slope:</p>
  
  <pre><code>var slope = (point2Y - point1Y) / (point2X - point1X);
  </code></pre>
  
  <p>By using the arc tan function, i was able to calculate my <code>alpha</code> slope-angle.</p>
  
  <pre><code>var alpha = Math.Atan(slope);
  </code></pre>
  
  <p>Now i'm using <code>Math.Cos</code> and <code>Math.Sin</code> to get the cooridinates of my new point. </p>
  
  <pre><code>var xNew = point1X + length * Math.Cos(alpha);
  var yNew = point1Y + length * Math.Sin(alpha);
  </code></pre>
  
  <p>This turns out good in two of 4 cases.
  But in the other two cases, the points seem to get "placed on the wrong side".</p>
  
  <p>I'm no mathematician and cant find a proper solution after serveral trials.</p>
  
  <p>I appreaciate any help!</p>