title: Find the angle of a line with the x-axis, given the two co-ordinates
body: <p>I have the co-ordinates of a line. They are in the form x, y. I need to find the angle this line makes with the x axis. Both the points can be edited by the user in my application, hence I cannot hold one as the center of rotation. I have tried this:</p>
  
  <pre><code>theta = tan-inv((y2 - y1)/(x2 - x1))
  </code></pre>
  
  <p>I consider the right point as x2, y2 and the left point as x1, y1 always. But I'm not getting the right value. Also, I need to convert the value returned in such a way that I can apply it on the canvas (between 0 - 360).</p>
  
  <p>Note: I convert the values to degrees/radians whenever and wherever it is required.</p>
  
  <p>I have attached an image that should explain what I'm trying in more detail.</p>
  
  <p><img src="https://i.stack.imgur.com/0SRV6.png" alt="enter image description here"></p>