Jump to content
twisted

find futherest positions from each other in an array

Recommended Posts

Imagine a circle marker in arma3. Now at 30 degree intervals positions are marked (if they are not over water) and then they have  (_pos = [_posCenter, 0, _radiusToCheck, 1, 0, 15, 0] call BIS_fnc_findSafePos;) applied to them and the resulting pos is added to an array .

 

So sometimes you have a semi circle if the original circle marker is partially over water or if it is fully over land you get a full circle.

 

now how to determine which 2 points are the furthest from each other?

 

I can tell at a glance by looking but am stumped at how to use sqf to loop through the array twice and comparing each value.

 

Any help or hints welcomed.

 

- solved with

 



if (count _spawn_pos_array > 2) then {


for "_y" from 0 to ((count _spawn_pos_array)-1) step 1 do {

for "_x" from 0 to ((count _spawn_pos_array )-1) step 1 do {

_len = (_spawn_pos_array select _y) distance (_spawn_pos_array select _x);
if (_len > _maxLength) then {
    _maxLength = _len;
_pos1 = _spawn_pos_array select _y;
_pos2 = _spawn_pos_array select _x;


_spawn_pos_array pushBack _pos;
_spawn_pos_array pushBack _pos;
};
};
};
};

[/CODE]

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

×