title: how to check if mouse pointer is moving clockwise or anticlockwise in javascript
body: <p>I want to check if mouse is moving clockwise or counterclockwise on html5 canvas with javascript but not getting how to proceed.</p>
  
  <p><strong>UPDATE</strong><br/>
  What I did is I took 3 XY coordinates and calculated angle between 1st and last point as suggested on <strong><a href="https://stackoverflow.com/questions/3309617/calculating-degrees-between-2-points-with-inverse-y-axis">this</a></strong> and <strong><a href="https://stackoverflow.com/questions/7586063/how-to-calculate-the-angle-between-two-points-relative-to-the-horizontal-axis">this</a></strong> post. </p>
  
  <pre><code>var resultX = p2x - p1x;
  var resultY = p2y - p1y;
  var angle = Math.atan2(resultY, resultX) * 180 / Math.PI;
  </code></pre>
  
  <p>but what happens is that when I move mouse clockwise result comes positive till mouse moves south-east but when mouse goes south-west while going clockwise the angle becomes negative which should not happen as mouse is still moving clockwise.</p>
  
  <p>Any suggestion please.</p>