vectorNormalized: Difference between revisions

From Bohemia Interactive Community
m (Text replacement - "v1\.[9-9]{2}\.[0-9]{6}" to "v2.00")
m (Some wiki formatting)
 
(38 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma3
|game1= arma3
|version1= 1.26


|1.26
|gr2= Math - Vectors


|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]] {{=}}{{=}} 1) of given vector. If given vector is 0 result is a 0 vector as well.
|s1= [[vectorNormalized]] vector


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


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


| [[Array]]
|x1= <sqf>
 
vectorNormalized [12345,7890,38383]; // [0.300481,0.192045,0.934254]
|x1= <code>[[vectorNormalized]] [12345,7890,38383]; {{cc|[0.300481,0.192045,0.934254]}}
vectorMagnitude [0.300481,0.192045,0.934254]; // 1
[[vectorMagnitude]] [0.300481,0.192045,0.934254]; {{cc|}}</code>
</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
<!-- Note Section BEGIN -->
|user= ffur2007slx2_5
<dd class="notedate">Posted on 19 Jul, 2014</dd>
|timestamp= 20140719151300
<dt class="note">[[User:ffur2007slx2_5| ffur2007slx2_5]]</dt>
|text= {{GVI|arma3|1.26}} Algorithm:
<dd class="note">
<sqf>
{{GVI|arma3|1.26}} Algorithm:
_vector = [x,y,z];
<code>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))];</code>
</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.
<!-- Note Section END -->
}}
</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.