vectorNormalized: Difference between revisions
BrettMayson (talk | contribs) mNo edit summary |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
| Line 6: | Line 6: | ||
|gr2= Math - Vectors | |gr2= Math - Vectors | ||
|descr= Returns | |descr= Returns normalised vector (unit vector, [[vectorMagnitude]] {{=}}{{=}} 1) of given vector. If given vector is 0 result is a 0 vector as well. | ||
{{Feature| | {{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: [[ | |p1= vector: [[Array]] of [[Number]]s | ||
|r1= [[Vector3D]] | |r1= [[Array]] format [[Vector3D]] | ||
|x1= <sqf> | |x1= <sqf> | ||
| Line 25: | Line 27: | ||
}} | }} | ||
{{Note | |||
|user= ffur2007slx2_5 | |||
|timestamp= 20140719151300 | |||
|text= {{GVI|arma3|1.26}} Algorithm: | |||
{{GVI|arma3|1.26}} Algorithm: | |||
<sqf> | <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> | </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. | ||
}} | |||
Latest revision as of 15:56, 6 January 2026
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
- Posted on Jul 19, 2014 - 15:13 (UTC)
-
1.26 Algorithm:
In mathematics, a unit vector in a normed vector space is a vector whose length is 1.