Place the points in random order without intersections

It is required to know the reference coordinates (for example (0,0)) arrange 30 points around it, so that they stand as if randomly, but do not overlap each other (i.e., so that there is some minimum distance between them, for example, 5). It should turn out something like this:

red - reference point

If you use the usual random in the aisles of the circle, then the elements can overlap + it is not known what size of the circle to choose, so that all the elements fit in and then At the same time, the circle was not too large, so that the points were not too far away. What algorithm can be used to get what is in the picture?

Author: Anton Shchyrov, 2018-09-12

1 answers

Imagine a spiral that you wind from the center.

enter a description of the image here

Start placing the points in this way , and you won't have to worry about finding the radius of the circle too large or too small.

In the loop, you will add point after point to the stack, and you will only have to check the location of the new point relative to the old ones, and not re-iterate the entire stack.

In general, the problem is not as simple as you think it seems. Read about how the engineer was looking for a solution to such a problem: The Nebraska problem

 3
Author: A K, 2018-09-12 12:42:50