Skip to content

Instantly share code, notes, and snippets.

@ruthenium
Forked from cevherkarakoc/cartesianToPolar.js
Created February 24, 2017 17:19
Show Gist options
  • Save ruthenium/7910073d4016c65895d86c3457cdfdc6 to your computer and use it in GitHub Desktop.
Save ruthenium/7910073d4016c65895d86c3457cdfdc6 to your computer and use it in GitHub Desktop.
Converting cartesian coordinates to polar coordinates
function cartesianToPolar(x,y){
return {
radius: Math.sqrt( Math.pow(x, 2) + Math.pow(y, 2) ),
alpha: Math.atan2(y, x)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment