Tuesday, December 23, 2025
spot_img

Algorithm to distribute factors on the perimeter of a sq. (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 items are distributed on the perimeter of a field, spaced at a sure distance from one another (fairly frequent 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 making an attempt to determine generate factors on the perimeter of a field, given variety of factors and spacing distance between them.

I made a rapid 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.

Algorithm to distribute factors on the perimeter of a sq. (field unit formation)

Within the above sketch, for N of 1 by 4, the distances between factors round origin are 2D and $sqrt{2text{D}^2}$ from origin, however they do not must be that manner — they are often D distance away from one another and from origin, to make issues easier. So, it ought to look extra like this:
illustration showing some alternate distributions
The gap to the origin shouldn’t be lower than D and naturally will probably be larger as N grows, and distance between factors must be at least D, however will be larger 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

- Advertisement -spot_img

Latest Articles