Created
June 20, 2016 15:04
-
-
Save caryfuk/1621cd011933cee40de8420eb1077db7 to your computer and use it in GitHub Desktop.
compute angle on unit circle (alternative to built in Math.atan2)
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
const angle = (x, y) => { | |
let result = Math.atan(y / x); | |
if (x < 0) { | |
result += Math.PI; | |
} else if (y < 0) { | |
result += 2 * Math.PI; | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment