Difference between revisions of "Vector.normalize"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2026.1<br/> '''Class:''' vector library<br/> === Description === Computes the normalized version (unit vector) of a given vector....") |
|||
| Line 6: | Line 6: | ||
Computes the normalized version (unit vector) of a given vector. | Computes the normalized version (unit vector) of a given vector. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
| − | ( | + | (vector) = vector.normalize(vec) |
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 13: | Line 13: | ||
=== Return values === | === Return values === | ||
| − | '''Returns''' ( | + | '''Returns''' (vector) the normalized version of the given vector<br/> |
=== Example === | === Example === | ||
Latest revision as of 10:08, 2 February 2026
Available since: Gideros 2026.1
Class: vector library
Description
Computes the normalized version (unit vector) of a given vector.
(vector) = vector.normalize(vec)
Parameters
vec: (vector) the vector to normalize
Return values
Returns (vector) the normalized version of the given vector
Example
local vec : vector = vector.create(1, 2, 3)
local vec2 : vector = vector.create(1, 1)
local norm : vector = vector.normalize(vec)
local norm2 : vector = vector.normalize(vec2)
print(norm)
print(norm2)