Hello everyone, I encountered the following problem.

I am writing a program to automatically construct graphs on canvas (laboratory). I can not understand how to draw it.

We have a canvas of a given size, there are n points.

It is necessary to achieve the following: at an equal distance from the center of the canvas, draw n circles (canvas.DrawCircle (x, y, 10);), which will be at an equal distance from each other. n is constantly changing.

I broke my head, but I can’t think of an algorithm.

I believe that it is necessary to dance from dividing the circle into sectors, calculating the angle, and then further through the polar coordinates, but I don’t understand how to find the angle

  • I believe that it is necessary to dance from dividing the circle into sectors, calculating the angle, and then further through the polar coordinates, but I don’t understand how to find the angle - Bobby Kitten
  • What does each other mean? - Igor
  • @Igor evenly distributed on the circle - Bobby Kitten

1 answer 1

Place the points around the circle, the center coincides with the center of the canvas.

Divide 360 ​​degrees by n - this will be the increment of the angle.

Well and in a cycle from 0 to n draw circles.

The coordinates X, Y will be determined by trivial formulas:

X = X1 + Radius * cos (angle)

Y = Y1 + Radius * sin (angle)

Where X1, Y1 - coordinates center kanvas.

Example in JavaScript, see here , with the canvas and the calculation of coordinates.

enter image description here