BIS fnc dirTo: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
 
(55 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:BIS_fnc_dirTo}}
{{RV|type=function
{{Function|=
____________________________________________________________________________________________


| arma2 |=
|game1= arma2
|1.00|=
|version1= 1.00


|arg= |= MPARGUMENTS
|game2= arma2oa
|version2= 1.50


|eff= |= MPEFFECTS
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| Function which returns vector direction from pos1 to pos2.
|game4= arma3
|version4= 0.50


|=
|gr1= Geometry
____________________________________________________________________________________________


| [param1, param2] call '''BIS_fnc_dirTo''' |=
|descr= Function which returns vector direction from pos1 to pos2.
{{Feature|arma3|Use <sqf inline>obj1 getDir obj2</sqf> instead of [[BIS_fnc_dirTo]].}}


|p1= param1 - vector starting point, [[Position]] '''or''' [[Object]] |=
|s1= [param1, param2] call [[BIS_fnc_dirTo]]


|p2= param1 - vector ending point, [[Position]] '''or''' [[Object]] |=
|p1= param1 - vector starting point, [[Position]] '''or''' [[Object]]


| [[Number]] |= Return value
|p2= param2 - vector ending point, [[Position]] '''or''' [[Object]]
 
|r1= [[Number]]


|x1= sets unit1 in the direction of unit2
|x1= sets unit1 in the direction of unit2
<code>unit1 [[setDir]] [unit1, unit2] [[call]] BIS_fnc_dirTo</code>|= EXAMPLE1
<sqf>unit1 setDir ([unit1, unit2] call BIS_fnc_dirTo);</sqf>
__________


| [[getDir]], [[BIS_fnc_help]] |= SEEALSO
|seealso= [[getDir]] [[setDir]]
}}


| |= MPBEHAVIOUR
{{Note
____________________________________________________________________________________________
|user= AgentRev
|timestamp= 20150121142000
|text= Be careful when using this function in conjunction with [[BIS_fnc_rotateVector2D]], which rotates vectors counterclockwise as per trigonometric conventions, while [[BIS_fnc_dirTo]] returns a clockwise angle.<br>
To counter this, simply negate the output of [[BIS_fnc_dirTo]]:
<sqf>[0,1,0], -([_unit, _vehicle] call BIS_fnc_dirTo)] call BIS_fnc_rotateVector2D;</sqf>
}}
}}
<h3 style='display:none'>Bottom Section</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
[[Category:Function Group: Geometry|{{uc:dirTo}}]]
[[Category:Functions|{{uc:dirTo}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:dirTo}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:dirTo}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:dirTo}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:dirTo}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on January 21, 2015 - 14:20 (UTC)</dd>
<dt class="note">[[User:AgentRevolution|AgentRevolution]]</dt>
<dd class="note">
Be careful when using this function in conjunction with [[BIS_fnc_rotateVector2D]]; the latter rotates vectors counterclockwise (mathematically correct), while BIS_fnc_dirTo returns a clockwise angle.
<br/>
To counter this, simply negate the output of BIS_fnc_dirTo:
<code>[<nowiki>[0,1,0]</nowiki>, '''-('''[_unit, _vehicle] [[call]] [[BIS_fnc_dirTo]]''')'''] [[call]] [[BIS_fnc_rotateVector2D]];</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on March 25, 2017 - 20:27 (UTC)</dd>
<dt class="note">[[User:Feint|Feint]]</dt>
<dd class="note">
Since Arma 3 v1.55.133361, an alternative syntax was added to [[getDir]] that allows one to get the heading from one object or position to another object or position, the equivalent of BIS_fnc_dirTo<br>
<br>
EXAMPLE:<br>
<code>_relPos = _caller [[getDir]] _helo;</code>
is equivalent to<br>
<code>_relPos = [_caller, _helo] [[call]] BIS_fnc_dirTo;</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 15:37, 13 July 2022

Hover & click on the images for description

Description

Description:
Function which returns vector direction from pos1 to pos2.
Arma 3
Use obj1 getDir obj2 instead of BIS_fnc_dirTo.
Execution:
call
Groups:
Geometry

Syntax

Syntax:
[param1, param2] call BIS_fnc_dirTo
Parameters:
param1 - vector starting point, Position or Object
param2 - vector ending point, Position or Object
Return Value:
Number

Examples

Example 1:
sets unit1 in the direction of unit2
unit1 setDir ([unit1, unit2] call BIS_fnc_dirTo);

Additional Information

See also:
getDir setDir

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
AgentRev - c
Posted on Jan 21, 2015 - 14:20 (UTC)
Be careful when using this function in conjunction with BIS_fnc_rotateVector2D, which rotates vectors counterclockwise as per trigonometric conventions, while BIS_fnc_dirTo returns a clockwise angle.
To counter this, simply negate the output of BIS_fnc_dirTo:
[0,1,0], -([_unit, _vehicle] call BIS_fnc_dirTo)] call BIS_fnc_rotateVector2D;