aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2019-07-14 11:45:55 +0200
committersfan5 <sfan5@live.de>2019-07-16 21:44:42 +0200
commit41229696be5878effa53a9a754766857d70f417d (patch)
treefafac89f4327a87e309d68de07da99153adfbeaf /builtin/common
parent71db715ba56369c67aa3187315601e2ae25d719a (diff)
downloadminetest-41229696be5878effa53a9a754766857d70f417d.tar.gz
minetest-41229696be5878effa53a9a754766857d70f417d.tar.bz2
minetest-41229696be5878effa53a9a754766857d70f417d.zip
Use vector.dot and vector.cross in vector.angle
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/vector.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua
index 782c137d6..ca6541eb4 100644
--- a/builtin/common/vector.lua
+++ b/builtin/common/vector.lua
@@ -71,11 +71,9 @@ function vector.direction(pos1, pos2)
end
function vector.angle(a, b)
- local dotp = a.x * b.x + a.y * b.y + a.z * b.z
- local cpx = a.y * b.z - a.z * b.y
- local cpy = a.z * b.x - a.x * b.z
- local cpz = a.x * b.y - a.y * b.x
- local crossplen = math.sqrt(cpx ^ 2 + cpy ^ 2 + cpz ^ 2)
+ local dotp = vector.dot(a, b)
+ local cp = vector.cross(a, b)
+ local crossplen = vector.length(cp)
return math.atan2(crossplen, dotp)
end