Description
Returns normalised vector (unit vector, vectorMagnitude == 1) of given vector. If given vector is 0 result is a 0 vector as well.
Note
- Arma 3 v2.14 any count of numbers is valid
- Arma 3 v2.00 now supports Vector2D (z defaulted to 0)
- Arma 3 v1.26 command introduction, only works with Vector3D
Syntax
vectorNormalized vector
Parameters:
Returns: Vector3D
Examples
Example 1
vectorNormalized [12345,7890,38383];
vectorMagnitude [0.300481,0.192045,0.934254];
See also
vectorDiff · vectorCrossProduct · vectorDotProduct · vectorCos · vectorMagnitude · vectorMagnitudeSqr · vectorMultiply · vectorDistance · vectorDistanceSqr · vectorDir · vectorUp · setVectorDir · setVectorUp · setVectorDirAndUp · vectorFromTo · matrixMultiply · matrixTranspose
Arma 3 v1.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.