summaryrefslogtreecommitdiff
path: root/builtin/vector.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/vector.lua')
-rw-r--r--builtin/vector.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/builtin/vector.lua b/builtin/vector.lua
index f534471c2..839f139ca 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)