Created
January 13, 2017 09:33
-
-
Save joeyklee/ad51bf8c142b39cec81c8f3e9fcc934e to your computer and use it in GitHub Desktop.
Get the angle in degrees from two points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from: https://gist.github.com/conorbuck/2606166