Saturday, February 17, 2007

Circular Plotting Function


GEN_PlotItemsOnCircle = function (numberOfItems, theRadius, startDegree) {
sliceSize = (360/numberOfItems);
theCoordinates = [];
for (i=0; i<(numberOfItems); i++) {
angle = startDegree*(Math.PI/180);
xPlot = theRadius*Math.cos(angle);
yPlot = theRadius*Math.sin(angle);
startDegree += sliceSize;
theCoordinates[i] = [xPlot, yPlot];
}
return theCoordinates;
};

1 comment:

Unknown said...

Nice script. Deserves at least one comment. Just a tip, use while instead of for, as it is much quicker