Skip to content

Instantly share code, notes, and snippets.

@Raisi
Created July 14, 2016 14:24
Show Gist options
  • Save Raisi/5d88fc0b21afcec883ea03e06f69be17 to your computer and use it in GitHub Desktop.
Save Raisi/5d88fc0b21afcec883ea03e06f69be17 to your computer and use it in GitHub Desktop.
Transform Polar to Cartsian Coordinats
/**
* Coordinates Transformations
*
* http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle
*
* @param centerX
* @param centerY
* @param radius
* @param angleInDegrees
* @returns {string}
*/
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
var x = centerX + (radius * Math.cos(angleInRadians));
var y = centerY + (radius * Math.sin(angleInRadians));
return `${x} ${y}`;
}
@Raisi
Copy link
Author

Raisi commented Jul 14, 2016

Useful when drawing an SVG Circle as Path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment