-2 C
New York
Wednesday, December 17, 2025

arithmetic – Algorithm to distribute factors on the perimeter of a field (field unit formation)


I am engaged on a recreation the place a participant’s celebration can have varied formations. In the mean time, I am looking for an algorithm for field formation, the place models are distributed on the perimeter of a field, spaced at a sure distance from one another (fairly widespread in technique video games). For the needs of this query, I am not involved with the motion or rotation of the sq., as soon as it is fashioned — I am solely attempting to determine how you can generate factors on the perimeter of a field, given variety of factors and spacing distance between them.

I made a fast sketch of the way it would possibly look. Ideally, factors would get distributed as proven within the sketch (clockwise or counterclockwise), however even distribution is completely advantageous as nicely, so long as minimal distance is maintained between factors and away from origin.

Edit: Within the above sketch, for N of 1 via 4, the distances between factors round origin are 2D and sqrt(2D^2) from origin, however they do not should be that means — they are often D distance away from one another and from origin, to make issues easier. So, it ought to look extra like this:
enter image description here
The space to the origin shouldn’t be lower than D and naturally might be better as N grows, and distance between factors needs to be a minimum of D, however may be better if a aspect has much less factors than every other aspect.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles