[Math] How Do We Find Points On A Circle Equidistant from each other

circlesgeometrytrigonometry

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:

enter image description here

That's what I want to do. The points generated is the variable items.

Best Answer

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.

Related Question