title: Finding coordinates of a point on a line
body: <p>This should be an easy one. I am trying to find the coordinates of a point on a straight line. I am implementing in MATLAB. I know, the coordinates of the endpoints and the distance from one of the point.</p>
  
  <p>I am using the following formula for calculating the coordinates (please note, I cannot use mid-point formula, as the distance can vary). </p>
  
  <p><img src="https://i.stack.imgur.com/zXzzV.png" alt="enter image description here"></p>
  
  <p>I am getting the wrong results when the slope is negative. Can you please suggest, what are the conditions, that needs to be considered for using this formula? Am not aware of any other formula as well. </p>