Skip to content
Permalink
Browse files

Handle 0 vectors in vector.normalize()

  • Loading branch information
ShadowNinja authored and kwolekr committed Jul 7, 2013
1 parent 39ab220 commit 07715b1b6adbdaeaa3f72591297ad59b443a0d9c
Showing with 6 additions and 1 deletion.
  1. +6 −1 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)

0 comments on commit 07715b1

Please sign in to comment.