Created
November 18, 2016 02:11
-
-
Save bq1990/2aec41e485e1f2e1ea2d22bd66ca0bb8 to your computer and use it in GitHub Desktop.
Plot a circle
This file contains hidden or 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 plotCircle(points, radius, x0, y0) { | |
coords = []; | |
var slice = 2 * Math.PI / points; //calculate the slice of the pie | |
for(var i = 0; i < points; i++) { | |
var angle = slice * i; | |
var x = x0 + radius * Math.cos(angle); | |
var y = y0 + radius * Math.sin(angle); | |
coords.push({x: x, y: y}); | |
} | |
return coords; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment