Difference between revisions of "VectorA:normalize"
From ComputerCraft Wiki
(Created page with "Returns a normal vector with a length of 1 Code representation: local a = vector.new(1, 2, 3) local len = a:length() local c = vector.new(a.x / len, a.y / len, a.z / l...") |
|||
Line 13: | Line 13: | ||
Code example: | Code example: | ||
local a = vector.new(1, 2, 3) | local a = vector.new(1, 2, 3) | ||
− | local c = a: | + | |
+ | local c = a:normalize() | ||
print(c.x) | print(c.x) |
Revision as of 11:03, 23 February 2013
Returns a normal vector with a length of 1
Code representation:
local a = vector.new(1, 2, 3) local len = a:length() local c = vector.new(a.x / len, a.y / len, a.z / len) --c.x = 0.26726124 --c.y = 0.5345225 --c.z = 0.80178374
Code example:
local a = vector.new(1, 2, 3) local c = a:normalize() print(c.x) print(c.y) print(c.z) print(c:length()) --0.26726124 --0.5345225 --0.80178374 --1