vectorNormalized: Difference between revisions

From Bohemia Interactive Community
(Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3 |= Game name |1.24|= Game version ________________...")
 
m (Some wiki formatting)
 
(66 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 1.26


|1.24|= Game version
|gr2= Math - Vectors


____________________________________________________________________________________________
|descr= Returns normalised vector (unit vector, [[vectorMagnitude]] {{=}}{{=}} 1) of given vector. If given vector is 0 result is a 0 vector as well.
{{Feature|informative|
* {{GVI|arma3|2.14|size= 0.75}} any count of numbers is valid
* {{GVI|arma3|2.00|size= 0.75}} now supports [[Vector2D]] (z defaulted to 0)
* {{GVI|arma3|1.26|size= 0.75}} command introduction, only works with [[Vector3D]]
}}


| Returns normalized vector (unit vector, [[vectorMagnitude]] <nowiki>=</nowiki> 1) of given vector. If given vector is 0 result is a 0 vector as well.  |= Description
|s1= [[vectorNormalized]] vector
____________________________________________________________________________________________


| '''vectorNormalized''' vector |= Syntax
|p1= vector: [[Array]] of [[Number]]s


|p1= vector: [[Array]] |= Parameter 1
|r1= [[Array]] format [[Vector3D]]


| [[Array]] |= Return value
|x1= <sqf>
____________________________________________________________________________________________
vectorNormalized [12345,7890,38383]; // [0.300481,0.192045,0.934254]
 
vectorMagnitude [0.300481,0.192045,0.934254]; // 1
|x1= <code>[[vectorNormalized]] [12345,7890,38383]; //[0.300481,0.192045,0.934254]
</sqf>
[[vectorMagnitude]] [0.300481,0.192045,0.934254]; //1</code> |= Example 1
____________________________________________________________________________________________


| [[vectorDiff]], [[vectorCrossProduct]], [[vectorDotProduct]], [[vectorCos]], [[vectorMagnitude]], [[vectorMagnitudeSqr]], [[vectorMultiply]], [[vectorDistance]], [[vectorDistanceSqr]], [[vectorDir]], [[vectorUp]], [[setVectorDir]], [[setVectorUp]], [[setVectorDirAndUp]], [[vectorFromTo]] |= See also
|seealso= [[vectorDiff]] [[vectorCrossProduct]] [[vectorDotProduct]] [[vectorCos]] [[vectorMagnitude]] [[vectorMagnitudeSqr]] [[vectorMultiply]] [[vectorDistance]] [[vectorDistanceSqr]] [[vectorDir]] [[vectorUp]] [[setVectorDir]] [[setVectorUp]] [[setVectorDirAndUp]] [[vectorFromTo]] [[matrixMultiply]] [[matrixTranspose]]
}}


{{Note
|user= ffur2007slx2_5
|timestamp= 20140719151300
|text= {{GVI|arma3|1.26}} Algorithm:
<sqf>
_vector = [x,y,z];
_result = [x / (sqrt (x ^ 2 + y ^ 2 + z ^ 2)), y / (sqrt (x ^ 2 + y ^ 2 + z ^ 2)), z / (sqrt (x ^ 2 + y ^ 2 + z ^ 2))];
</sqf>
In mathematics, a unit vector in a normed vector space is a vector whose length is 1.
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 15:56, 6 January 2026

Hover & click on the images for description

Description

Description:
Returns normalised vector (unit vector, vectorMagnitude == 1) of given vector. If given vector is 0 result is a 0 vector as well.
Groups:
Math - Vectors

Syntax

Syntax:
vectorNormalized vector
Parameters:
vector: Array of Numbers
Return Value:
Array format Vector3D

Examples

Example 1:
vectorNormalized [12345,7890,38383]; // [0.300481,0.192045,0.934254] vectorMagnitude [0.300481,0.192045,0.934254]; // 1

Additional Information

See also:
vectorDiff vectorCrossProduct vectorDotProduct vectorCos vectorMagnitude vectorMagnitudeSqr vectorMultiply vectorDistance vectorDistanceSqr vectorDir vectorUp setVectorDir setVectorUp setVectorDirAndUp vectorFromTo matrixMultiply matrixTranspose

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord.
Only post proven facts here! Add Note
ffur2007slx2_5 - c
Posted on Jul 19, 2014 - 15:13 (UTC)
Arma 3 logo black.png 1.26 Algorithm:
_vector = [x,y,z]; _result = [x / (sqrt (x ^ 2 + y ^ 2 + z ^ 2)), y / (sqrt (x ^ 2 + y ^ 2 + z ^ 2)), z / (sqrt (x ^ 2 + y ^ 2 + z ^ 2))];
In mathematics, a unit vector in a normed vector space is a vector whose length is 1.