Created
January 13, 2017 09:33
-
-
Save joeyklee/e9f328e4c0c13a19eb1800caa97df9fb to your computer and use it in GitHub Desktop.
Get the angle in radians between two points
This file contains 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 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); | |
} |
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