Jump to content
ShadowRanger24

Points Around Circle Issue

Recommended Posts

So someone on Discord showed me how to generate points around a circle based on a given amount and center position. However it has an issue, for some reason the first and last position in every returned array is the same. I can't seem to figure out why. Here's the script:

params [
    ["_amount", 0, [0]],
    ["_origin", [], [[]]],
    ["_radius", 0, [0]]
];

private _positions = [];

for "_a" from 0 to 360 step (360 / (_amount - 1)) do {
    _positions pushBack (_origin getPos [_radius, _a]);
};

_positions

Thanks in advance.

Share this post


Link to post
Share on other sites

Getting positions for direction 0 and 360 will result in the same position.

Not really that hard to figure out.

:yay:

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites
5 minutes ago, Grumpy Old Man said:

Getting positions for direction 0 and 360 will result in the same position.

Not really that hard to figure out.

:yay:

 

Cheers

Yeah got it sorted, wasn't thinking properly. Cheers tho. For anyone curious to what needed to be changed for it to work:

params [
    ["_amount", 0, [0]],
    ["_origin", [], [[]]],
    ["_radius", 0, [0]]
];

private _positions = [];

for "_a" from 0 to 359 step (360 / _amount) do {
    _positions pushBack (_origin getPos [_radius, _a]);
};

_positions

 

Share this post


Link to post
Share on other sites

what about using step to get rid of the last element? if someone likes to get many points and step is smaller than one degree then u get a gap between 359 and 360.

 

params [
    ["_amount", 0, [0]],
    ["_origin", [], [[]]],
    ["_radius", 0, [0]]
];

private _positions = [];

_step = (360 / _amount);

for "_a" from 0 to (360 - _step) step _step do {
    _positions pushBack (_origin getPos [_radius, _a]);
};

_positions

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×