Skip to content

Instantly share code, notes, and snippets.

@joeyklee
Created January 13, 2017 09:33
Show Gist options
  • Save joeyklee/e9f328e4c0c13a19eb1800caa97df9fb to your computer and use it in GitHub Desktop.
Save joeyklee/e9f328e4c0c13a19eb1800caa97df9fb to your computer and use it in GitHub Desktop.
Get the angle in radians between two points
function getAngleRad(p1, p2){
// returns the angle between 2 points in radians
// p1 = {x: 1, y: 2};
// p2 = {x: 3, y: 4};
return Math.atan2(p2.y - p1.y, p2.x - p1.x);
}
@joeyklee
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment