daily pastebin goal
75%
SHARE
TWEET

angle

RandomGuy32 Oct 18th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. distance: function(x1, y1, x2, y2) {
  2.     return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
  3. },
  4. angle: function(x1, y1, x2, y2) {
  5.     var x = x1 - x2;
  6.     var y = y1 - y2;
  7.     var l = Util.distance(x1, y1, x2, y2);
  8.  
  9.     // var result = Math.atan(x / y) / (-Math.PI * 2);
  10.     // var result = (Math.acos(y / l) / (Math.PI * 2)) * 360;
  11.     var result = Math.acos(y / l);
  12.  
  13.     return result;
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top