BIS fnc rotateVector2D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Generated by BIS_fnc_exportFunctionsToWiki)
 
(Created page with "<syntaxhighlight lang=javascript>scriptName "Functions\vectors\fn_rotateVector2D.sqf"; /************************************************************ Rotate 2D Vector By Andrew ...")
Line 1: Line 1:
 
<syntaxhighlight lang=javascript>scriptName "Functions\vectors\fn_rotateVector2D.sqf";
{{Function|= Comments
____________________________________________________________________________________________
 
| arma2 |= Game name
 
|1.00|= Game version
____________________________________________________________________________________________
 
| <pre>
/************************************************************
/************************************************************
Rotate 2D Vector
Rotate 2D Vector
By Andrew Barron


Parameters: [[vector], angle]
Parameters: [[vector], angle]
Line 19: Line 11:
************************************************************/
************************************************************/


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
private ["_v","_d","_x","_y"];
____________________________________________________________________________________________
 
| <!-- [] call [[BIS_fnc_rotateVector2D]]; --> |= Syntax
 
|p1= |= Parameter 1
 
| |= Return value
____________________________________________________________________________________________
 
|x1= <code></code> |=
____________________________________________________________________________________________
 
| |= See also


}}
//extract parameters
_v = +(_this select 0); //we don't want to modify the originally passed vector
_d = _this select 1;


<h3 style="display:none">Notes</h3>
//extract old x/y values
<dl class="command_description">
_x = _v select 0;
<!-- Note Section BEGIN -->
_y = _v select 1;


<!-- Note Section END -->
//if vector is 3d, we don't want to mess up the last element
</dl>
_v set [0, (cos _d)*_x - (sin _d)*_y];
_v set [1, (sin _d)*_x + (cos _d)*_y];


<h3 style="display:none">Bottom Section</h3>
//return new vector
[[Category:Function Group: Vectors|{{uc:rotateVector2D}}]]
_v
[[Category:Functions|{{uc:rotateVector2D}}]]
</syntaxhighlight>
[[Category:{{Name|arma2}}: Functions|{{uc:rotateVector2D}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:rotateVector2D}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:rotateVector2D}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:rotateVector2D}}]]

Revision as of 11:02, 23 October 2013

scriptName "Functions\vectors\fn_rotateVector2D.sqf";
/************************************************************
	Rotate 2D Vector
	By Andrew Barron

Parameters: [[vector], angle]
Returns: [vector]

This function returns a 2D vector rotated a specified number
of degrees around the origin.
************************************************************/

private ["_v","_d","_x","_y"];

//extract parameters
_v = +(_this select 0); //we don't want to modify the originally passed vector
_d = _this select 1;

//extract old x/y values
_x = _v select 0;
_y = _v select 1;

//if vector is 3d, we don't want to mess up the last element
_v set [0, (cos _d)*_x - (sin _d)*_y];
_v set [1, (sin _d)*_x + (cos _d)*_y];

//return new vector
_v