vectorNormalized: Difference between revisions

From Bohemia Interactive Community
m (Text replacement - "\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "$1$2</code>")
m (Some wiki formatting)
 
(9 intermediate revisions by 3 users not shown)
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.
|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]]
}}


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


|p1= vector: [[Array]] - vector 3D or 2D (since Arma 3 v2.00, z coordinate is defaulted to 0)
|p1= vector: [[Array]] of [[Number]]s


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


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


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


<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>
<sqf>
<dd class="note">
_vector = [x,y,z];
{{GVI|arma3|1.26}} Algorithm:
_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))];
<code>Vector = [x,y,z];
</sqf>
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))];</code>
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.