Skip to content

Instantly share code, notes, and snippets.

@xcoderzach
Created October 8, 2014 20:52
Show Gist options
  • Save xcoderzach/eda0a34f1003c116c2ac to your computer and use it in GitHub Desktop.
Save xcoderzach/eda0a34f1003c116c2ac to your computer and use it in GitHub Desktop.
like acos, except returns degrees, a domain of -Infinity to Infinity, and a range of 0 to 360
function f(x) {
x = ((((x + 2) % 4) + 4) % 4) - 2
if(x > 1) return 360 - Math.acos(2 - x) * (180/Math.PI)
if(x < -1) return 360 - Math.acos(-2 - x) * (180/Math.PI)
return Math.acos(x) * (180/Math.PI)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment