Jump to content
Sign in to follow this  
dragonsyr

relative position from object (???)

Recommended Posts

Ok that fucks it, setting the Azi to 285 then anything over 255ish returns negative numbers.

Share this post


Link to post
Share on other sites
lol how can that be :/ the last two lines of bis_fnc_relativedirto are
//ensure return is between 0-360
if (_dir < 0) then {_dir = _dir + 360};
if (_dir > 360) then {_dir = _dir - 360};

Well, if you turn them to face west instead of north, they'll both return negative values.

IgN0isBl.jpg

I think something is either broken or inconsistent with BIS_fnc_relativeDirTo math, but I can't look into it now. :(

Share this post


Link to post
Share on other sites
lol how can that be :/ the last two lines of bis_fnc_relativedirto are
//ensure return is between 0-360
if (_dir < 0) then {_dir = _dir + 360};
if (_dir > 360) then {_dir = _dir - 360};

you mean that i need to put these two lines at the end of my ifs???

edit: ok ..... at last this working fine.......

_target = rwdir;    
_relDir = [_target, player] call BIS_fnc_relativeDirTo;
if (_reldir < 0) then {_reldir = _reldir + 360};
if (_reldir > 360) then {_reldir = _reldir - 360};
if ( _relDir >= 0 && _relDir <= 90 ) then {hint"you are frontright";sleep 1;hint format ["_relDir is %1", _relDir];sleep 1;};
if ( _relDir >= 90 && _relDir <= 180 ) then {hint"you are backright";sleep 1;hint format ["_relDir is %1", _relDir];sleep 1;};
if ( _relDir >= 180 && _relDir <= 270 ) then {hint"you are backleft";sleep 1;hint format ["_relDir is %1", _relDir];sleep 1;}; 
if ( _relDir >= 270 && _relDir <= 359 ) then {hint"you are frontleft";sleep 1;hint format ["_relDir is %1", _relDir];sleep 1;}; 

thank both of you guys !!! --what a mess.......!! ---

Edited by dragonsyr

Share this post


Link to post
Share on other sites

This line in BIS_fnc_dirTo is incorrect

_ret = ((_pos2 select 0) - (_pos1 select 0)) atan2 ((_pos2 select 1) - (_pos1 select 1));
_ret = _ret % 360; //ensure return is 0-360

atan2 returns -180 to 180 , the mod 360 of these values is still -180 to 180 not 0 - 360.

Compounding this by BIS_fnc_relativeDirTo subtracting the rotation of the object, leaves _dir over -360.

The lines

if (_dir < 0) then {_dir = _dir + 360};
if (_dir > 360) then {_dir = _dir - 360};

In BIS_fnc_relativeDirTo are never going to bring it back into a 0 - 360 range.

Edited by Larrow

Share this post


Link to post
Share on other sites

...

atan2 returns -180 to 180 , the mod 360 of these values is still -180 to 180 not 0 - 360

...

Nice find, that seems to be the issue. Modulo seems to have changed the way it operates since that function was written.

I suggest making a ticket on the FT for this. Seems a bit severe.

The correct line should be after the change to the way modulo works:

_ret = _ret - (360 * (floor (_ret / 360)));

Edited by Sniperwolf572

Share this post


Link to post
Share on other sites
I suggest making a ticket on the FT for this. Seems a bit severe.

Done vote up. 0016556

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
Sign in to follow this  

×