Skip to content

Instantly share code, notes, and snippets.

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

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