# How Do We Find Points On A Circle Equidistant from each other?

I'm a programmer and I saw this question on stackoverflow which exactly does my job: https://stackoverflow.com/questions/13608186/trying-to-plot-coordinates-around-the-edge-of-a-circle.

In this, the answer says that:

var items = 10; // say there are 10 points to be plotted.
var x0 = 40;
var y0 = 40;

// Remember top left pixel of computer screen is (0,0) and both axis go positive from left to right and top to bottom.

for(var i = 0; i < items; i++) {
var x = x0 + r * Math.cos(2 * Math.PI * i / items); // WHAT IS HAPPENING HERE?
var y = y0 + r * Math.sin(2 * Math.PI * i / items); // WHAT IS HAPPENING HERE?
}


I'm just undone about the code above. How is that happening. Why are we adding the x0 and y0 (coordinates of center of circle). How does it gives us exact points exactly equidistant from each other? Please explain how this math is working.

For e.g., the above code gives us like this: That's what I want to do. The points generated is the variable items.

• Could you please explain it in a better way? Check the edit I posted @Integrator – mehulmpt Nov 20 '14 at 11:41
• For circles centred at (0,0), (rcosθ, rsinθ), represents a point on the circle subtending an angle θ at the origin with the +ve x-axis. – Yaitzme Nov 20 '14 at 11:53
• Since the centre of the circle in your case is off-centre, we add the +ve offset to the centres of thee circle. – Yaitzme Nov 20 '14 at 11:54
• I am of reminded of $N^{th}$ roots of unity. That is, for a circle centered at the origin and unit radius, the $N^{th}$ roots of unity are equally spaced around the unit circle. – Jose Arnaldo Bebita-Dris Nov 20 '14 at 12:16

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);}


The equations translated:

$$x(n)=x(0)+r\cos\left(2\pi\frac{n}{N}\right)\\ y(n)=y(0)+r\sin\left(2\pi\frac{n}{N}\right)\\$$

Remember points on a circle with centre at $x_0,y_0$ with radius $r$ at an angle $\theta$ are: $$(x,y)\equiv(x_0+r\cos\theta,y_0+r\sin\theta)$$ The $360^\circ\equiv2\pi$ radians has been divided into $N$ parts and thus the angle between two adjacent points will be $2\pi/N$, I hope you can understand the rest.

• Is there any kind of name for these equations? – addison Aug 30 '15 at 23:16

I am reminded of $N^{th}$ roots of unity. That is, for a circle centered at the origin and unit radius, the $N^{th}$ roots of unity are equally spaced around the unit circle.