Trying to plot coordinates around the edge of a circle

I am trying to plot coordinates around a circle programmatically. Here it is hard-coded to show what I am after:

http://jsfiddle.net/jE26S/1/

var iteration = 4;
var left = [94,200,104,-6];
var top = [-6,94,200,94];    

for(var i=0; i<iteration; i++){

    $("#center").append("<div class='point' style='left:"+left[i]+"px;top:"+top[i]+"px'></div>");    

}

Math is definitely not my strong point.

I need to represent people as small Circles standing around a large circle. However, there will be random numbers of people and they all need to be equidistant. I'm not sure whether I should be working from a central point.

Answers


Assuming that (x0, y0) is the center of your circle, and r is the radius:

var items = 4;
for(var i = 0; i < items; i++) {

    var x = x0 + r * Math.cos(2 * Math.PI * i / items);
    var y = y0 + r * Math.sin(2 * Math.PI * i / items);   
    $("#center").append("<div class='point' style='left:"+ x +"px;top:"+ y +"px'></div>");    

}

Need Your Help

scala tuple unpacking

scala parameters tuples

I know this question has come up many times in different ways. But it is still not clear to me. Is there a way to achieve the following.

Which database engine to choose for Django app?

python database django sqlite

I'm new to Django and have only been using sqlite3 as a database engine in Django. Now one of the applications I'm working on is getting pretty big, both in terms of models' complexity and requests/