summaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2019-07-13 13:46:44 +0200
committersfan5 <sfan5@live.de>2019-07-16 21:44:42 +0200
commit71db715ba56369c67aa3187315601e2ae25d719a (patch)
treeee101fc14029406b72581f61696b12a996e580b1 /builtin/common
parent458f6175753314583637006f00c426ba22ba86d7 (diff)
downloadminetest-71db715ba56369c67aa3187315601e2ae25d719a.tar.gz
minetest-71db715ba56369c67aa3187315601e2ae25d719a.tar.bz2
minetest-71db715ba56369c67aa3187315601e2ae25d719a.zip
Add vector.dot and vector.cross
Mostly copied from MarkuBu's code
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/vector.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua
index 9a53409fa..782c137d6 100644
--- a/builtin/common/vector.lua
+++ b/builtin/common/vector.lua
@@ -79,6 +79,18 @@ function vector.angle(a, b)
return math.atan2(crossplen, dotp)
end
+function vector.dot(a, b)
+ return a.x * b.x + a.y * b.y + a.z * b.z
+end
+
+function vector.cross(a, b)
+ return {
+ x = a.y * b.z - a.z * b.y,
+ y = a.z * b.x - a.x * b.z,
+ z = a.x * b.y - a.y * b.x
+ }
+end
+
function vector.add(a, b)
if type(b) == "table" then
return {x = a.x + b.x,