From: ShadowNinja Date: Sun, 7 Jul 2013 06:02:45 +0000 (-0400) Subject: Handle 0 vectors in vector.normalize() X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=07715b1b6adbdaeaa3f72591297ad59b443a0d9c;p=zefram%2Fminetest%2Fminetest_engine.git Handle 0 vectors in vector.normalize() --- diff --git a/builtin/vector.lua b/builtin/vector.lua index f534471c..839f139c 100644 --- a/builtin/vector.lua +++ b/builtin/vector.lua @@ -31,7 +31,12 @@ function vector.length(v) end function vector.normalize(v) - return vector.divide(v, vector.length(v)) + local len = vector.length(v) + if len == 0 then + return vector.new() + else + return vector.divide(v, len) + end end function vector.round(v)