Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function getAngleRadians(x0, y0, x1, y1) {
  2. // radians = atan2(deltaY, deltaX)
  3. const y = y1 - y0;
  4. const x = x1 - x0;
  5. return Math.atan2(y, x);
  6. }
  7.  
  8. function getAngleDeg(x0, y0, x1, y1) {
  9. // degrees = atan2(deltaY, deltaX) * (180 / PI)
  10. const y = y1 - y0;
  11. const x = x1 - x0;
  12. return Math.atan2(y, x) * (180 / Math.PI);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement