das attorney 857 Posted August 17, 2014 (edited) Hi, Add this to your list of functions. I never found a function that could normalise a direction into 0-360 properly so I wrote one and here it is in case you need to use a direction that may be out of 0-360 range. horde_fnc_normalDirection = { /*author: Das Attorney*/ private ["_dir"]; /*date: 17/08/2014*/ _dir = _this; call { if (_dir > 360) exitWith { _dir = _dir % 360; }; if (_dir < 0) exitWith { _dir = _dir % 360; if (_dir < 0) then { _dir = _dir + 360; }; }; }; if (_dir in [0,360]) then { _dir = 0; }; _dir }; Here is some inputs and outputs: INPUT: -800 OUTPUT: 280 INPUT: -723 OUTPUT: 357 INPUT: -720 OUTPUT: 0 INPUT: -540 OUTPUT: 180 INPUT: -360 OUTPUT: 0 INPUT: -167 OUTPUT: 193 INPUT: -0 OUTPUT: 0 INPUT: 37 OUTPUT: 37 INPUT: 367 OUTPUT: 7 INPUT: 720 OUTPUT: 0 INPUT: 800 OUTPUT: 80 Usage: _return = 800 call horde_fnc_normalDirection; _return = 720 call horde_fnc_normalDirection; _return = 360 call horde_fnc_normalDirection; _return = -0 call horde_fnc_normalDirection; Edited August 17, 2014 by Das Attorney Share this post Link to post Share on other sites
kremator 1064 Posted August 17, 2014 Is this going to be used in your new 'AllRoundDefence' for Arma 3? Hint! Share this post Link to post Share on other sites
das attorney 857 Posted August 17, 2014 Ha ha maybe, got some fish to fry first though! New shorter version thanks to Larrow :) fnc_dir = { private ["_dir"]; _dir = _this; _dir = _dir % 360; if (_dir < 0 ) then { _dir = _dir + 360 }; abs _dir }; Share this post Link to post Share on other sites
sttosin 67 Posted August 17, 2014 Is this going to be used in your new 'AllRoundDefence' for Arma 3? Hint! +1 on this one. Share this post Link to post Share on other sites