summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/common/vector.lua9
-rw-r--r--doc/lua_api.txt3
2 files changed, 10 insertions, 2 deletions
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua
index e9ed3aab3..90ba3cc8b 100644
--- a/builtin/common/vector.lua
+++ b/builtin/common/vector.lua
@@ -31,6 +31,14 @@ function vector.normalize(v)
end
end
+function vector.floor(v)
+ return {
+ x = math.floor(v.x),
+ y = math.floor(v.y),
+ z = math.floor(v.z)
+ }
+end
+
function vector.round(v)
return {
x = math.floor(v.x + 0.5),
@@ -130,4 +138,3 @@ function vector.divide(a, b)
z = a.z / b}
end
end
-
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 8cb3f72bd..1e5084354 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1812,7 +1812,8 @@ Spatial Vectors
* `vector.distance(p1, p2)`: returns a number
* `vector.length(v)`: returns a number
* `vector.normalize(v)`: returns a vector
-* `vector.round(v)`: returns a vector, each dimension rounded to floor
+* `vector.floor(v)`: returns a vector, each dimension rounded down
+* `vector.round(v)`: returns a vector, each dimension rounded to nearest int
* `vector.apply(v, func)`: returns a vector
* `vector.equals(v1, v2)`: returns a boolean