vectorNormalized: Difference between revisions

From Bohemia Interactive Community
mNo edit summary
m (Some wiki formatting)
 
Line 6: Line 6:
|gr2= Math - Vectors
|gr2= Math - Vectors


|descr= Returns normalized vector (unit vector, [[vectorMagnitude]] {{=}}{{=}} 1) of given vector. If given vector is 0 result is a 0 vector as well.<br>
|descr= Returns normalised vector (unit vector, [[vectorMagnitude]] {{=}}{{=}} 1) of given vector. If given vector is 0 result is a 0 vector as well.
{{Feature|GVI|arma3|2.14|Since {{GVI|arma3|2.14|size= 0.75}} any count of numbers is valid.<br>
{{Feature|informative|
Before {{GVI|arma3|2.14|size= 0.75}}, the first argument had to be vector 3D, or {{GVI|arma3|2.00|size= 0.75}} 2D (Which still returned 3D result, with z coordinate defaulted to 0)}}  
* {{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]]
}}


|s1= [[vectorNormalized]] vector
|s1= [[vectorNormalized]] vector


|p1= vector: [[Vector3D]] or {{GVI|arma3|2.00}} [[Vector2D]] - z coordinate defaulted to 0
|p1= vector: [[Array]] of [[Number]]s


|r1= [[Vector3D]]
|r1= [[Array]] format [[Vector3D]]


|x1= <sqf>
|x1= <sqf>
Line 25: Line 27:
}}
}}


<dl class="command_description">
{{Note
 
|user= ffur2007slx2_5
<dt></dt>
|timestamp= 20140719151300
<dd class="notedate">Posted on 19 Jul, 2014</dd>
|text= {{GVI|arma3|1.26}} Algorithm:
<dt class="note">[[User:ffur2007slx2_5| ffur2007slx2_5]]</dt>
<dd class="note">
{{GVI|arma3|1.26}} Algorithm:
<sqf>
<sqf>
Vector = [x,y,z];
_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))];
_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>
</sqf>
In mathematics, a unit vector in a normed vector space is a vector whose length is 1.
In mathematics, a unit vector in a normed vector space is a vector whose length is 1.
</dl>
}}

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.