aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)